std.thread Mon Jan 23 22:57:00 2006 2006 DDOC = Ares - std.thread
Last update Mon Jan 23 22:57:00 2006
std
 std.atomic
 std.exception
 std.intrinsic
 std.thread

std.thread

DDOC = Ares - std.thread
Last update Mon Jan 23 22:57:00 2006
std
 std.atomic
 std.exception
 std.intrinsic
 std.thread

std.thread

class ThreadError: object.Exception; All exceptions thrown from this module derive from this class. class 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. this(); Initializes a thread object which has no associated executable function. this(void(* fn)()); Initialized a thread object which is associated with a static D function. void(* fn)() The thread function. this(void delegate() dg); Initializes a thread object which is associated with a dynamic D function. void delegate() dg The thread function. final char[] name(); Gets the user-readable label for this thread. The name of this thread. final void name(char[] n); Sets the user-readable label for this thread. char[] n The new name for this thread. final void start(); Starts the thread with run() as the target method. The default behavior of this is to run the function or delegate passed upon construction.
This routine may only be called once per thread instance.
ThreadError if the thread fails to start.
final bit isRunning(); Tests whether this thread is running. This function should be callable from anywhere within the application without a risk of deadlock. true if the thread is running, false if not. final void join(); Waits for this thread to complete. ThreadError if the operation fails. final void suspend(); Suspends thread execution and loads stack and register data for use by the suspending thread. Registers should be stored in the order they would typically appear when pushed onto the execution stack. This function is reentrant, but resume must be called once for each call to suspend. ThreadError if the thread is not currently running or if the thread can not be suspended. final void resume(); Resumes thread execution and frees stack and register data. This function is reentrant and must be called once for every call to suspend before the thread is resumed. ThreadError if the thread is not currently running or if the thread can not be resumed. final void* stackTop(); Should be preceded by a call to suspend. A pointer to the logical top of the execution stack for this thread. Note that on some operating systems the address may be less than the address returned by stackBottom. final void* stackBottom(); Should be preceded by a call to suspend. A pointer to the logical bottom of the execution stack for this thread. Note that on some operating systems the address may be greater than the address returned by stackTop. final void* regFirst(); Should be preceded by a call to suspend. A pointer to the beginning of an inclusive range of registers stored by suspend. For example, if a system has registers X, Y, Z, and they are typically pushed onto the stack in that order, then this function will point to the value of X on systems where the stack grows up, or Z on systems where the stack grows down. final void* regLast(); Should be preceded by a call to suspend. A pointer to the end of an inclusive range of registers stored by suspend. For example, if a system has registers X, Y, Z, and they are typically pushed onto the stack in that order, then this function will point to the value of Z on systems where the stack grows up, or X on systems where the stack grows down. static void sleep(uint milliseconds); Suspends the calling thread for at least the supplied time. uint milliseconds The minimum duration the calling thread should be suspended. static void yield(); Forces a context switch to occur away from the calling thread. static void suspendAll(); Calls suspend on all running threads. static void resumeAll(); Calls resume on all running threads. static Thread getThis(); The calling thread. The thread object representing the calling thread. The result of deleting this object is undefined. static Thread[] getAll(); This function is not intended to be used by the garbage collector, so memory allocation is allowed. An array containing references to all threads currently being tracked by the system. The result of deleting any contained objects is undefined. static int opApply(int delegate(inout Thread) dg); Operates on all threads currently tracked by the system. const uint LOCAL_MAX; Indicates the number of local storage pointers available at program startup. It is recommended that this number be at least 64. static uint createLocal(); Reserves a local storage pointer for use and initializes this location to null for all running threads. A key representing the array offset of this memory location. static void deleteLocal(uint key); Marks the supplied key as available and sets the associated location to null for all running threads. It is assumed that any key passed to this function is valid. The result of calling this function for a key which is still in use is undefined. uint key The key to delete. static void* getLocal(uint key); Gets the data associated with the supplied key value. It is assumed that any key passed to this function is valid. uint key The location which holds the desired data. The data associated with the supplied key. static void* setLocal(uint key, void* val); Stores the supplied value in the specified location. It is assumed that any key passed to this function is valid. uint key The location to store the supplied data. void* val The data to store. A copy of the data which has just been stored. protected void run(); This is the entry point for the newly invoked thread. Default behavior is to invoke the function or delegate passed on object construction. This function may be overridden to create custom thread objects via subclassing.
bitC multiThreaded(); This function is used to determine whether the the process is multi-threaded. Optimizations may only be performed on this value if the programmer can guarantee that no path from the enclosed code will start a thread. True if Thread.start() has been called in this process. voidC suspendAllThreads(); Identical to Thread.suspendAll(). voidC resumeAllThreads(); Identical to Thread.resumeAll(). voidC scanAllThreads(void delegate(void*, void*) fn); The main entry point for garbage collection. The supplied delegate will be passed ranges representing both stack and register values. void delegate(void*, void*) fn The scanner function. It should scan from p1 through p2 - 1.