View source code
Display the source code in core/thread/osthread.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Module core.thread.osthread

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

Functions

NameDescription
createLowLevelThread(dg, stacksize, cbDllUnload) Create 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.
joinLowLevelThread(tid) Wait for a thread created with createLowLevelThread to terminate.
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.
thread_init() Initializes the thread module. This function must be called by the garbage collector on startup and before any other thread routines are called.
thread_setGCSignals(suspendSignalNo, resumeSignalNo) Instruct the thread module, when initialized, to use a different set of signals besides SIGUSR1 and SIGUSR2 for suspension and resumption of threads. This function should be called at most once, prior to thread_init(). This function is Posix-only.
thread_suspendAll() Suspend 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_resumeAll before processing is resumed.
thread_term() Terminates the thread module. No other thread routine may be called afterwards.

Classes

NameDescription
Thread 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.

Aliases

NameTypeDescription
getpid core.sys.posix.unistd.getpid Returns the process ID of the calling process, which is guaranteed to be unique on the system. This call is always successful.

Authors

Sean Kelly, Walter Bright, Alex Rønne Petersen, Martin Nowak

License

Distributed under the Boost Software License 1.0. (See accompanying file LICENSE)