core.thread.osthread

The osthread module provides low-level, OS-dependent code for thread creation and management.

Types 1

This class encapsulates all threading functionality for the D programming language. As thread manipulation is a required facility for garbage collection, all user threads should derive from this class, and instances of this class should never be explicitly deleted. A new thread may be created using either derivation or composition, as in the following example.

Methods
Thread getThis() static @safe nothrow @nogcProvides a reference to the calling thread.
void[] savedRegisters() nothrow @nogc
Thread start() nothrowStarts the thread and invokes the function or delegate passed upon construction.
Throwable join( bool rethrow = true )Waits for this thread to complete. If the thread terminated as the result of an unhandled exception, this exception will be rethrown.
int priority() @propertyGets the scheduling priority for the associated thread.
void priority( int val ) @propertySets the scheduling priority for the associated thread.
bool isRunning() @property nothrow @nogcTests whether this thread is running.
void sleep( Duration val ) static @nogc nothrow @trustedSuspends the calling thread for at least the supplied period. This may result in multiple OS calls if period is greater than the maximum sleep duration supported by the operating system.
void yield() static @nogc nothrowForces a context switch to occur away from the calling thread.
Constructors
this( void function() fn, size_t sz = 0 )Initializes a thread object which is associated with a static D function.
this( void delegate() dg, size_t sz = 0 )Initializes a thread object which is associated with a dynamic D function.
this( size_t sz = 0 )
Destructors
~thisCleans up any remaining resources used by this object.

Functions 10

fnThread thread_attachThis() extern(C)Registers the calling thread for use with the D Runtime. If this routine is called for a thread which is already registered, no action is performed.
fnvoid callWithStackShell(scope callWithStackShellDg fn) extern(D) nothrow
fnvoid thread_preStopTheWorld() extern(C) nothrowRuns the necessary operations required before stopping the world.
fnvoid thread_suspendAll() extern(C) nothrowSuspend all threads but the calling thread for "stop the world" garbage collection runs. This function may be called multiple times, and must be followed by a matching number of calls to thread_re...
fnvoid thread_init() extern(C) @nogc nothrowInitializes the thread module. This function must be called by the garbage collector on startup and before any other thread routines are called.
fnvoid thread_term() extern(C) @nogc nothrowTerminates the thread module. No other thread routine may be called afterwards.
fnvoid rt_moduleTlsCtor() extern(C)
fnvoid rt_moduleTlsDtor() extern(C)
fnThreadID createLowLevelThread(void delegate() nothrow dg, uint stacksize = 0, void delegate() nothrow cbDllUnload = null) nothrow @nogcCreate a thread not under control of the runtime, i.e. TLS module constructors are not run and the GC does not suspend it during a collection.
fnvoid joinLowLevelThread(ThreadID tid) nothrow @nogcWait for a thread created with `createLowLevelThread` to terminate.

Variables 1

varMainThreadStore _mainThreadStore