D
Language
Phobos
Comparisons
object
std
std.base64
std.boxer
std.compiler
std.conv
std.cover
std.ctype
std.date
std.demangle
std.file
std.format
std.gc
std.intrinsic
std.math
std.md5
std.mmfile
std.openrj
std.outbuffer
std.path
std.process
std.random
std.recls
std.regexp
std.socket
std.socketstream
std.stdint
std.stdio
std.cstream
std.stream
std.string
std.system
std.thread
std.uni
std.uri
std.utf
std.zip
std.zlib
std.c.fenv
std.c.math
std.c.process
std.c.stdarg
std.c.stddef
std.c.stdio
std.c.stdlib
std.c.string
std.c.time
std.c.wcharh
std.windows.charset
std.windows
std.linux
std.c.windows
std.c.linux
|
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.
- class ThreadError: object.Error;
- Thrown for errors.
- class Thread;
- One of these is created for each thread.
- this();
- Constructor used by classes derived from Thread that override main().
- this(int(* fp)(void*), void* arg);
- Constructor used by classes derived from Thread that override run().
- this(int delegate() dg);
- Constructor used by classes derived from Thread that override run().
- HANDLE hdl;
- 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.
- void start();
- Create a new thread and start it running. The new thread initializes
itself and then calls run(). start() can only be called once.
- int run();
- 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.
- void wait();
- 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.
- void wait(uint milliseconds);
- 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.
- enum TS;
- The state of a thread.
- INITIAL
- The thread hasn't been started yet.
- RUNNING
- The thread is running or paused.
- TERMINATED
- The thread has ended.
- TS getState();
- Returns the state of a thread.
- enum PRIORITY;
- The priority of a thread.
- INCREASE
- Increase thread priority
- DECREASE
- Decrease thread priority
- IDLE
- Assign thread low priority
- CRITICAL
- Assign thread high priority
- void setPriority(PRIORITY p);
- Adjust the priority of this thread.
Throws:
ThreadError if cannot set priority
- static Thread getThis();
- Returns a reference to the Thread for the thread that called the
function.
- static Thread[] getAll();
- Returns an array of all the threads currently running.
- void pause();
- Suspend execution of this thread.
- void resume();
- Resume execution of this thread.
- static void pauseAll();
- Suspend execution of all threads but this thread.
- static void resumeAll();
- Resume execution of all paused threads.
- static void yield();
- Give up the remainder of this thread's time slice.
- static uint nthreads;
- void* os_query_stackBottom();
- Determine "bottom" of stack (actually the top on Win32 systems).
|