druntime thread_needLock()

dsimcha dsimcha at yahoo.com
Fri Dec 5 21:02:44 PST 2008


According to both the docs and my own experiments, thread_needLock() in
core.thread returns a bool that depends on whether the current process has
*ever* been multithreaded at *any* point in its execution.  In Phobos's GC
(pre-druntime), a similar function existed, but it returned a bool based on
whether more than 1 thread was *currently* running.  It seems to me that
omitting locks should be safe if no more than 1 thread is currently running,
even if more than 1 was running at some point in the past.  Why is druntime's
thread_needLock() designed the way it is?



More information about the Digitalmars-d mailing list