Struct

GLibThread

Description

struct GThread {
  /* No available fields */
}

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

g_thread_new

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 g_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 g_thread_join().

since: 2.32

g_thread_try_new

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

since: 2.32

Functions

g_thread_create

This function creates a new thread.

deprecated: 2.32 

g_thread_create_full

This function creates a new thread.

deprecated: 2.32 

g_thread_error_quark
No description available.

g_thread_exit

Terminates the current thread.

g_thread_foreach

Call thread_func on all GThreads that have been created with g_thread_create().

deprecated: 2.32 since: 2.10

g_thread_get_initialized

Indicates if g_thread_init() has been called.

since: 2.20

g_thread_init

If you use GLib from more than one thread, you must initialize the thread system by calling g_thread_init().

deprecated: 2.32 

g_thread_init_with_errorcheck_mutexes
No description available.

g_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.

g_thread_yield

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

Instance methods

g_thread_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.

g_thread_ref

Increase the reference count on thread.

since: 2.32

g_thread_set_priority

This function does nothing.

deprecated: 2.32 

g_thread_unref

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

since: 2.32