Thread

The #GThread struct represents a running thread. This struct is returned by glib.thread.Thread.new_ or glib.thread.Thread.tryNew. You can obtain the #GThread struct representing the current thread by calling glib.thread.Thread.self.

GThread is refcounted, see glib.thread.Thread.ref_ and glib.thread.Thread.unref. The thread represented by it holds a reference while it is running, and glib.thread.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(string name, glib.types.ThreadFunc func)

This function creates a new thread. The new thread starts by invoking func with the argument data. The thread will run until func returns or until glib.thread.Thread.exit is called from the new thread. The return value of func becomes the return value of the thread, which can be obtained with glib.thread.Thread.join.

Members

Functions

join
void* join()

Waits until thread finishes, i.e. the function func, as given to glib.thread.Thread.new_, returns or glib.thread.Thread.exit is called. If thread has already terminated, then glib.thread.Thread.join returns immediately.

Static functions

errorQuark
glib.types.Quark errorQuark()
exit
void exit(void* retval)

Terminates the current thread.

self
glib.thread.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.

tryNew
glib.thread.Thread tryNew(string name, glib.types.ThreadFunc func)

This function is the same as glib.thread.Thread.new_ except that it allows for the possibility of failure.

yield
void yield()

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

Inherited Members

From Boxed

cInstancePtr
void* cInstancePtr;

Pointer to the C boxed value

getType
GType getType()

Get the GType of this boxed type.

gType
GType gType [@property getter]

Boxed GType property.

self
Boxed self()

Convenience method to return this cast to a type. For use in D with statements.

copy_
void* copy_()

Make a copy of the wrapped C boxed data.

boxedCopy
void* boxedCopy(void* cBoxed)

Copy a C boxed value using g_boxed_copy.

boxedFree
void boxedFree(void* cBoxed)

Free a C boxed value using g_boxed_free.