Thread

The #GThread struct represents a running thread. This struct is returned by g_thread_new() or g_thread_try_new(). You can obtain the #GThread struct representing the current thread by calling g_thread_self().

GThread is refcounted, see g_thread_ref() and g_thread_unref(). The thread represented by it holds a reference while it is running, and g_thread_join() consumes the reference that it is given, so it is normally not necessary to manage GThread references explicitly.

The structure is opaque -- none of its fields may be directly accessed.

Constructors

this
this(GThread* gThread, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this(string name, GThreadFunc func, void* data)

This function is the same as g_thread_new() except that it allows for the possibility of failure.

Destructor

~this
~this()
Undocumented in source.

Members

Aliases

doref
alias doref = ref_
Undocumented in source.

Functions

getStruct
void* getStruct()

the main Gtk struct as a void*

getThreadStruct
GThread* getThreadStruct(bool transferOwnership)

Get the main Gtk struct

join
void* join()

Waits until @thread finishes, i.e. the function @func, as given to g_thread_new(), returns or g_thread_exit() is called. If @thread has already terminated, then g_thread_join() returns immediately.

ref_
Thread ref_()

Increase the reference count on @thread.

unref
void unref()

Decrease the reference count on @thread, possibly freeing all resources associated with it.

Static functions

bitLock
void bitLock(int* address, int lockBit)

Sets the indicated @lock_bit in @address. If the bit is already set, this call will block until g_bit_unlock() unsets the corresponding bit.

bitTrylock
bool bitTrylock(int* address, int lockBit)

Sets the indicated @lock_bit in @address, returning %TRUE if successful. If the bit is already set, returns %FALSE immediately.

bitUnlock
void bitUnlock(int* address, int lockBit)

Clears the indicated @lock_bit in @address. If another thread is currently blocked in g_bit_lock() on this same bit then it will be woken up.

errorQuark
GQuark errorQuark()
exit
void exit(void* retval)

Terminates the current thread.

getNumProcessors
uint getNumProcessors()

Determine the approximate number of threads that the system will schedule simultaneously for this process. This is intended to be used as a parameter to g_thread_pool_new() for CPU bound tasks and similar cases.

pointerBitLock
void pointerBitLock(void* address, int lockBit)

This is equivalent to g_bit_lock, but working on pointers (or other pointer-sized values).

pointerBitTrylock
bool pointerBitTrylock(void* address, int lockBit)

This is equivalent to g_bit_trylock, but working on pointers (or other pointer-sized values).

pointerBitUnlock
void pointerBitUnlock(void* address, int lockBit)

This is equivalent to g_bit_unlock, but working on pointers (or other pointer-sized values).

self
Thread self()

This function returns the #GThread corresponding to the current thread. Note that this function does not increase the reference count of the returned struct.

yield
void yield()

Causes the calling thread to voluntarily relinquish the CPU, so that other threads can run.

Variables

gThread
GThread* gThread;

the main Gtk struct

ownedRef
bool ownedRef;
Undocumented in source.

Meta