core.thread.threadbase
Source core/thread/osthread.d
- classThreadException: object.Exception;
- Base class for thread exceptions.
- classThreadError: object.Error;
- Base class for thread errors to be used for function inside GC when allocations are unavailable.
- abstract classThreadBase;
- 
- pure nothrow @nogc @safe this(void function()fn, size_tsz= 0);
- package nothrow @nogc booldestructBeforeDtor();
- Cleans up any remaining resources used by this object.
- abstract Throwablejoin(boolrethrow= true);
- Waits for this thread to complete. If the thread terminated as the result of an unhandled exception, this exception will be rethrown.Parameters:bool rethrowRethrow 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.
- final @nogc @property @safe ThreadIDid();
- Gets the OS identifier for this thread.Returns:If the thread hasn't been started yet, returns ThreadID.init. Otherwise, returns the result of GetCurrentThreadId on Windows, and pthread_self on POSIX. The value is unique for the current process.
- final @nogc @property @safe stringname();
- Gets the user-readable label for this thread.Returns:The name of this thread.
- final @nogc @property @safe voidname(stringval);
- Sets the user-readable label for this thread.Parameters:string valThe new name of this thread. 
- final @nogc @property @safe boolisDaemon();
- Gets the daemon status for this thread. While the runtime will wait for all normal threads to complete before tearing down the process, daemon threads are effectively ignored and thus will not prevent the process from terminating. In effect, daemon threads will be terminated automatically by the OS when the process exits.Returns:true if this is a daemon thread.
- final @nogc @property @safe voidisDaemon(boolval);
- Sets the daemon status for this thread. While the runtime will wait for all normal threads to complete before tearing down the process, daemon threads are effectively ignored and thus will not prevent the process from terminating. In effect, daemon threads will be terminated automatically by the OS when the process exits.Parameters:bool valThe new daemon status for this thread. 
- final nothrow @nogc @property boolisMainThread();
- Tests whether this thread is the main thread, i.e. the thread that initialized the runtimeReturns:true if the thread is the main thread
- nothrow @nogc @property boolisRunning();
- Tests whether this thread is running.Returns:true if the thread is running, false if not.
- static nothrow @nogc @safe ThreadBasegetThis();
- Provides a reference to the calling thread.Returns:The thread object representing the calling thread. The result of deleting this object is undefined. If the current thread is not attached to the runtime, a null reference is returned.
- static ThreadBase[]getAll();
- Provides a list of all threads currently being tracked by the system. Note that threads in the returned array might no longer run (see ThreadBase.isRunning).Returns:An array containing references to all threads currently being tracked by the system. The result of deleting any contained objects is undefined.
- static intopApply(scope int delegate(ref ThreadBase)dg);
- Operates on all threads currently being tracked by the system. The result of deleting any Thread object is undefined. Note that threads passed to the callback might no longer run (see ThreadBase.isRunning).Parameters:int delegate(ref ThreadBase) dgThe supplied code as a delegate. Returns:Zero if all elemented are visited, nonzero if not.
- package pure nothrow @nogc @safe this(size_tsz= 0);
- package static nothrow @nogc voidsetThis(ThreadBaset);
- package(core.thread) final nothrow @nogc voidpushContext(StackContext*c);
- package(core.thread) static nothrow @nogc @property Mutexslock();
- package(core.thread) static nothrow @nogc voidadd(StackContext*c);
- package(core.thread) static nothrow @nogc voidadd(ThreadBaset, boolrmAboutToStart= true);
 
- nothrow @nogc voidthread_term_tpl(ThreadT, MainThreadStore)(ref MainThreadStore_mainThreadStore);
- Terminates the thread module. No other thread routine may be called afterwards.
- nothrow @nogc boolthread_isMainThread();
- ThreadTthread_attachThis_tpl(ThreadT)();
- 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.NOTE This routine does not run thread-local static constructors when called. If full functionality as a D thread is desired, the following function must be called after thread_attachThis: extern (C) void rt_moduleTlsCtor();
- nothrow @nogc voidthread_detachThis();
- Deregisters the calling thread from use with the runtime. If this routine is called for a thread which is not registered, the result is undefined.NOTE This routine does not run thread-local static destructors when called. If full functionality as a D thread is desired, the following function must be called before thread_detachThis, particularly if the thread is being detached at some indeterminate time before program termination: extern(C) void rt_moduleTlsDtor();See Also:
- voidthread_detachByAddr(ThreadIDaddr);
 nothrow @nogc voidthread_detachInstance(ThreadBaset);
- Deregisters the given thread from use with the runtime. If this routine is called for a thread which is not registered, the result is undefined.NOTE This routine does not run thread-local static destructors when called. If full functionality as a D thread is desired, the following function must be called by the detached thread, particularly if the thread is being detached at some indeterminate time before program termination: extern(C) void rt_moduleTlsDtor();
- static ThreadBasethread_findByAddr(ThreadIDaddr);
- Search the list of all threads for a thread with the given thread identifier.Parameters:ThreadID addrThe thread identifier to search for. Returns:The thread object associated with the thread identifier, null if not found.
- nothrow @nogc voidthread_setThis(ThreadBaset);
- Sets the current thread to a specific reference. Only to be used when dealing with externally-created threads (in e.g. C code). The primary use of this function is when ThreadBase.getThis() must return a sensible value in, for example, TLS destructors. In other words, don't touch this unless you know what you're doing.Parameters:ThreadBase tA reference to the current thread. May be null. 
- voidthread_joinAll();
- Joins all non-daemon threads that are currently running. This is done by performing successive scans through the thread list until a scan consists of only daemon threads.
- nothrow voidthread_resumeAll();
- Resume all threads but the calling thread for "stop the world" garbage collection runs. This function must be called once for each preceding call to thread_suspendAll before the threads are actually resumed.In This routine must be preceded by a call to thread_suspendAll. Throws:ThreadError if the resume operation fails for a running thread.
- enumScanType: int;
- Indicates the kind of scan being performed by thread_scanAllType.- stack
- The stack and/or registers are being scanned.
- tls
- TLS data is being scanned.
 
- aliasScanAllThreadsFn= void delegate(void*, void*) nothrow;
 aliasScanAllThreadsTypeFn= void delegate(ScanType, void*, void*) nothrow;
- The scanning function.
- nothrow voidthread_scanAllType(scope ScanAllThreadsTypeFnscan);
- The main entry point for garbage collection. The supplied delegate will be passed ranges representing both stack and register values.Parameters:ScanAllThreadsTypeFn scanThe scanner function. It should scan from p1 through p2 - 1. In This routine must be preceded by a call to thread_suspendAll. 
- nothrow voidthread_scanAll(scope ScanAllThreadsFnscan);
- The main entry point for garbage collection. The supplied delegate will be passed ranges representing both stack and register values.Parameters:ScanAllThreadsFn scanThe scanner function. It should scan from p1 through p2 - 1. In This routine must be preceded by a call to thread_suspendAll. 
- @nogc voidthread_enterCriticalRegion();
- Signals that the code following this call is a critical region. Any code in this region must finish running before the calling thread can be suspended by a call to thread_suspendAll.This function is, in particular, meant to help maintain garbage collector invariants when a lock is not used. A critical region is exited with thread_exitCriticalRegion. Warning: Using critical regions is extremely error-prone. For instance, using locks inside a critical region can easily result in a deadlock when another thread holding the lock already got suspended. The term and concept of a 'critical region' comes from Mono's SGen garbage collector.In The calling thread must be attached to the runtime. 
- @nogc voidthread_exitCriticalRegion();
- Signals that the calling thread is no longer in a critical region. Following a call to this function, the thread can once again be suspended.In The calling thread must be attached to the runtime. 
- @nogc boolthread_inCriticalRegion();
- Returns true if the current thread is in a critical region; otherwise, false.In The calling thread must be attached to the runtime. 
- package nothrow @nogc voidonThreadError(stringmsg);
- A callback for thread errors in D during collections. Since an allocation is not possible a preallocated ThreadError will be used as the Error instanceReturns:never returnsThrows:ThreadError.
- enumIsMarked: int;
- Indicates whether an address has been marked by the GC.- no
- Address is not marked.
- yes
- Address is marked.
- unknown
- Address is not managed by the GC.
 
- aliasIsMarkedDg= int delegate(void* addr) nothrow;
- The isMarked callback function.
- nothrow voidthread_processGCMarks(scope IsMarkedDgisMarked);
- This routine allows the runtime to process any special per-thread handling for the GC. This is needed for taking into account any memory that is referenced by non-scanned pointers but is about to be freed. That currently means the array append cache.Parameters:IsMarkedDg isMarkedThe function used to check if addr is marked. In This routine must be called just prior to resuming all threads. 
- nothrow @nogc void*thread_stackTop();
- Returns the stack top of the currently active stack within the calling thread.In The calling thread must be attached to the runtime. Returns:The address of the stack top.
- nothrow @nogc void*thread_stackBottom();
- Returns the stack bottom of the currently active stack within the calling thread.In The calling thread must be attached to the runtime. Returns:The address of the stack bottom.
- package size_tll_nThreads;
- package ll_ThreadData*ll_pThreads;
- package void[mutexClassInstanceSize]ll_lock;
- package nothrow @nogc @property MutexlowlevelLock();
- package nothrow @nogc voidinitLowlevelThreads();
- package nothrow @nogc voidtermLowlevelThreads();
- package nothrow @nogc voidll_removeThread(ThreadIDtid);
- nothrow @nogc boolfindLowLevelThread(ThreadIDtid);
- Check whether a thread was created by createLowLevelThread.Parameters:ThreadID tidthe platform specific thread ID. Returns:true if the thread was created by createLowLevelThread and is still running.