digitalmars.D.learn - Single-thread processes
- Cecil Ward (8/8) Jun 28 2023 If your program is such that one process will never ever involve
- IGotD- (10/18) Jun 29 2023 I general, use globals as little as possible and definitely not
If your program is such that one process will never ever involve multiple threads, because it simply doesn’t apply in your situation, then would it be worthwhile to have a "version (D_SingleThread)" which would get rid of the all-statics in TLS thing and make __g shared into a respectable, fully-ok storage class modifier that is fine in safe code. What do you think? That way, you would be documenting what you’re doing and would not need to have any TLS-statics overhead?
Jun 28 2023
On Wednesday, 28 June 2023 at 23:46:17 UTC, Cecil Ward wrote:If your program is such that one process will never ever involve multiple threads, because it simply doesn’t apply in your situation, then would it be worthwhile to have a "version (D_SingleThread)" which would get rid of the all-statics in TLS thing and make __g shared into a respectable, fully-ok storage class modifier that is fine in safe code. What do you think? That way, you would be documenting what you’re doing and would not need to have any TLS-statics overhead?I general, use globals as little as possible and definitely not TLS. TLS is wart in computer technology that shouldn't be invented anyway. They should have stopped with per thread key/value storage which was available around the 2000s and let language runtimes handle that instead. In general I do not agree with D's making globals TLS as standard. It should be the other way around, TLS must be explicitly declared while traditional globals should be be declared just like in C.
Jun 29 2023