You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Timur Gafarov edited this page Apr 26, 2017
·
6 revisions
dlib.core.thread
This module provides a platform-independent multithreading API. For now, it supports Windows and Posix threads (pthreads). The interface is greatly inspired by core.thread from Phobos, but dlib.core.thread is fully GC-free and can be used with dlib.core.memory allocators.
Implementation notes:
No TLS support, sorry. Any global variables should be marked with __gshared for correct access from threads.
Internals of Thread class are platform-dependent, so be aware of that when inheriting.
class Thread
Base class for creating threads.
Methods:
this(void function() func) - initialize with a function pointer
this(void delegate() func) - initialize with a delegate
void start() - start the thread. This method returns immediately
void join() - wait for the thread to terminate
bool isRunning() - check if the thread is running
void terminate() - terminate the thread immediately. This functionality is unsafe, use with care.
Usage example
voidthreadFunc()
{
// do some job
}
Thread t = New!Thread(&threadFunc);
t.start();