Single-thread processes

IGotD- nise at nise.com
Thu Jun 29 12:41:47 UTC 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.


More information about the Digitalmars-d-learn mailing list