core.thread.osthread

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

Types 2

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
private void run()
Thread getThis() @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 ) @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() @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.
private aliasMainThreadStore = void[__traits(classInstanceSize, Thread)]

Functions 23

private fnvoid * _d_eh_swapContext(void * newContext) nothrow @nogcHook for whatever EH implementation is used to save/restore some data per stack.
private fnThread toThread(return scope ThreadBase t) @trusted nothrow @nogc pure
private fnvoid thread_yield() @nogc nothrow
private fnThreadBase attachThread(ThreadBase _thisThread) @nogc nothrow
fnThread thread_attachThis()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) nothrow
private fnvoid * getStackTop() nothrow @nogc
private fnvoid * getStackBottom() nothrow @nogc
private fnbool suspend( Thread t ) nothrow @nogcSuspend the specified thread and load stack and register information for use by thread_scanAll. If the supplied thread is the calling thread, stack and register information will be loaded but the ...
fnvoid thread_preStopTheWorld() nothrowRuns the necessary operations required before stopping the world.
fnvoid thread_suspendAll() 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...
private fnvoid resume(ThreadBase _t) nothrow @nogcResume the specified thread and unload stack and register information. If the supplied thread is the calling thread, stack and register information will be unloaded but the thread will not be resum...
fnvoid thread_init() @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() @nogc nothrowTerminates the thread module. No other thread routine may be called afterwards.
private fnvoid monitorDLLRefCnt() nothrow
fnint ll_getDLLRefCount() nothrow @nogc
fnbool ll_startDLLUnloadThread() nothrow @nogc
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 4

varMainThreadStore _mainThreadStore
varbool thread_DLLProcessDetaching

set during termination of a DLL on Windows, i.e. while executing DllMain(DLL_PROCESS_DETACH)

varHMODULE ll_dllModule
varThreadID ll_dllMonitorThread