Nim is a compiled, garbage-collected systems programming language with a design that focuses on efficiency, expressiveness, and elegance (in that order of priority).
though we still need to consider the differences on different platforms.
On windows
The yield of execution is in effect for up to one thread-scheduling time slice on the processor of the calling thread. The operating system will not switch execution to another processor, even if that processor is idle or is running a thread of lower priority.
While on unix
they can switch to different processors.
Ref https://chromium.googlesource.com/chromium/src/third_party/WebKit/Source/wtf/+/823d62cdecdbd5f161634177e130e5ac01eb7b48/SpinLock.cpp
Since we already have
yieldProcessor
in the system module, we also needyieldThread
.On unix it is sched_yield, on windows it is SwitchToThread.
though we still need to consider the differences on different platforms.
On windows
While on unix they can switch to different processors.
see also https://www.generacodice.com/en/articolo/85065/SwitchToThread/Thread.Yield-vs.-Thread.Sleep(0)-vs.-Thead.Sleep(1)