License:
BSD style: see license.txtAuthors:
Sean Kelly, Fawzi MohamedExample:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | class DerivedThread : Thread { this() { super( &run ); } private : void run() { printf( "Derived thread running.\n" ); } } void threadFunc() { printf( "Composed thread running.\n" ); } // create instances of each type Thread derived = new DerivedThread(); Thread composed = new Thread( &threadFunc ); // start both threads derived.start(); composed.start(); |
Params:
fn | The thread function. |
sz | The stack size for this thread. |
In:
fn must not be null.Params:
dg | The thread function. |
sz | The stack size for this thread. |
In:
dg must not be null.In:
This routine may only be called once per thread instance.Throws:
ThreadException if the thread fails to start.Params:
rethrow | Rethrow any unhandled exception which may have caused this thread to terminate. |
Throws:
ThreadException if the operation fails. Any exception not handled by the joined thread.Returns:
Any exception not handled by this thread if rethrow = false, null otherwise.Returns:
The name of this thread.Params:
val | The new name of this thread. |
Returns:
true if this is a daemon thread.Params:
val | The new daemon status for this thread. |
Returns:
true if the thread is running, false if not.Returns:
The scheduling priority of this thread.Params:
val | The new scheduling priority of this thread. |
Params:
period | The minimum duration the calling thread should be suspended, in seconds. Sub-second durations are specified as fractional values. |
In:
period must be less than (uint.max - 1) milliseconds.Example:
1 2 | Thread.sleep( 0.05 ); // sleep for 50 milliseconds Thread.sleep( 5 ); // sleep for 5 seconds |
Returns:
The thread object representing the calling thread. The result of deleting this object is undefined.Returns:
An array containing references to all threads currently being tracked by the system. The result of deleting any contained objects is undefined.Params:
dg | The supplied code as a delegate. |
Returns:
Zero if all elemented are visited, nonzero if not.Returns:
A key representing the array offset of this memory location.Params:
key | The key to delete. |
Params:
key | The location which holds the desired data. |
Returns:
The data associated with the supplied key.Params:
key | The location to store the supplied data. |
val | The data to store. |
Returns:
A copy of the data which has just been stored.Returns:
True if Thread.start() has been called in this process.Throws:
ThreadException if the suspend operation fails for a running thread.In:
This routine must be preceded by a call to thread_suspendAll.Throws:
ThreadException if the resume operation fails for a running thread.Params:
scan | The scanner function. It should scan from p1 through p2 - 1. |
curStackTop | An optional pointer to the top of the calling thread's stack. |
In:
This routine must be preceded by a call to thread_suspendAll.Params:
def | The default value to return if no value has been explicitly set. |
Returns:
The stored value or def if no value is stored.Params:
newval | The value to set. |
Returns:
The value passed to this function.Params:
fn | The thread function. |
Returns:
A reference to the newly created thread.Params:
dg | The thread function. |
Returns:
A reference to the newly created thread.Params:
t | The thread to add. |
In:
t must not be null.Params:
t | The thread to remove. |
In:
t must not be null.Params:
rethrow | Rethrow any unhandled exception which may have caused the current thread to terminate. |
Throws:
Any exception not handled by the joined threads.Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | class DerivedFiber : Fiber { this() { super( &run ); } private : void run() { printf( "Derived fiber running.\n" ); } } void fiberFunc() { printf( "Composed fiber running.\n" ); Fiber.yield(); printf( "Composed fiber running.\n" ); } // create instances of each type Fiber derived = new DerivedFiber(); Fiber composed = new Fiber( &fiberFunc ); // call both fibers once derived.call(); composed.call(); printf( "Execution returned to calling context.\n" ); composed.call(); // since each fiber has run to completion, each should have state TERM assert( derived.state == Fiber.State.TERM ); assert( composed.state == Fiber.State.TERM ); |
Authors:
Based on a design by Mikola Lysenko.Params:
fn | The thread function. |
sz | The stack size for this fiber. |
In:
fn must not be null.Params:
dg | The thread function. |
sz | The stack size for this fiber. |
In:
dg must not be null.Params:
rethrow | Rethrow any unhandled exception which may have caused this fiber to terminate. |
In:
This fiber must be in state HOLD.Throws:
Any exception not handled by the joined thread.Returns:
Any exception not handled by this fiber if rethrow = false, null otherwise.In:
This fiber must be in state TERM, and have a valid function/delegate.Params:
fn | The thread function. |
In:
This fiber must be in state TERM. fn must not be null.Params:
dg | The thread function. |
In:
This fiber must be in state TERM. dg must not be null.In:
This fiber must be in state TERM.Returns:
The state of this fiber as an enumerated value.Params:
obj | The object to throw. |
In:
obj must not be null.Returns:
The fiber object representing the calling fiber or null if no fiber is currently active. The result of deleting this object is undefined.