std.thread
The thread module defines the class Thread.Thread is the basis for writing multithreaded applications. Each thread has a unique instance of class Thread associated with it. It is important to use the Thread class to create and manage threads as the garbage collector needs to know about all the threads.
Authors:
Walter Bright, Bartosz Milewski
- The type of the thread handle used by the operating system.
For Windows, it is equivalent to a HANDLE from windows.d.
- Thrown for errors.
- One of these is created for each thread.
- this(size_t stacksize = 0);
- Constructor used by classes derived from Thread that override main().
The optional stacksize parameter default value of 0 will cause threads
to be created with the default size for the executable - Dave Fladebo
- this(int function(void*) fp, void* arg, size_t stacksize = 0);
- Constructor used by classes derived from Thread that override run().
- this(int delegate() dg, size_t stacksize = 0);
- Constructor used by classes derived from Thread that override run().
- The handle to this thread assigned by the operating system. This is set
to thread_id.init if the thread hasn't been started yet.
- Create a new thread and start it running. The new thread initializes
itself and then calls run(). start() can only be called once.
- Entry point for a thread. If not overridden, it calls the function
pointer fp and argument arg passed in the constructor, or the delegate
dg.
Returns:
the thread exit code, which is normally 0.
- Wait for this thread to terminate.
Simply returns if thread has already terminated.
Throws:
ThreadError if the thread hasn't begun yet or is called on itself.
- Wait for this thread to terminate or until milliseconds time has
elapsed, whichever occurs first.
Simply returns if thread has already terminated.
Throws:
ThreadError if the thread hasn't begun yet or is called on itself.
- The state of a thread.
- The thread hasn't been started yet.
- The thread is running or paused.
- The thread has ended.
- The thread has been cleaned up
- Returns the state of a thread.
- The priority of a thread.
- Increase thread priority
- Decrease thread priority
- Assign thread low priority
- Assign thread high priority
- Adjust the priority of this thread.
Throws:
ThreadError if cannot set priority
- Returns true if this thread is the current thread.
- Returns a reference to the Thread for the thread that called the
function.
- Returns an array of all the threads currently running.
- Suspend execution of this thread.
- Resume execution of this thread.
- Suspend execution of all threads but this thread.
- Resume execution of all paused threads.
- Give up the remainder of this thread's time slice.
- Create a Thread for global main().
- Determine "bottom" of stack (actually the top on Win32 systems).