gtkc.gthreadtypes

Undocumented in source.

Public Imports

gtkc.glibtypes
public import gtkc.glibtypes;
Undocumented in source.

Members

Aliases

GThreadFunc
alias GThreadFunc = void* function(void* data)
Undocumented in source.
OnceStatus
alias OnceStatus = GOnceStatus
Undocumented in source.
ThreadError
alias ThreadError = GThreadError
Undocumented in source.
ThreadPriority
alias ThreadPriority = GThreadPriority
Undocumented in source.

Enums

GOnceStatus
enum GOnceStatus

The possible statuses of a one-time initialization function controlled by a GOnce struct. G_ONCE_STATUS_NOTCALLED the function has not been called yet. G_ONCE_STATUS_PROGRESS the function call is currently in progress. G_ONCE_STATUS_READY the function has been called. Since 2.4

GThreadError
enum GThreadError

Possible errors of thread related functions. G_THREAD_ERROR_AGAIN a thread couldn't be created due to resource shortage. Try again later.

GThreadPriority
enum GThreadPriority

Specifies the priority of a thread. Note It is not guaranteed that threads with different priorities really behave accordingly. On some systems (e.g. Linux) there are no thread priorities. On other systems (e.g. Solaris) there doesn't seem to be different scheduling for different priorities. All in all try to avoid being dependent on priorities. G_THREAD_PRIORITY_LOW a priority lower than normal G_THREAD_PRIORITY_NORMAL the default priority G_THREAD_PRIORITY_HIGH a priority higher than normal G_THREAD_PRIORITY_URGENT the highest priority

Structs

GCond
struct GCond

The GCond struct is an opaque data structure that represents a condition. Threads can block on a GCond if they find a certain condition to be false. If other threads change the state of this condition they signal the GCond, and that causes the waiting threads to be woken up. Whenever a thread calls pop_data() now, it will wait until current_data is non-NULL, i.e. until some other thread has called push_data(). Note It is important to use the g_cond_wait() and g_cond_timed_wait() functions only inside a loop which checks for the condition to be true. It is not guaranteed that the waiting thread will find the condition fulfilled after it wakes up, even if the signaling thread left the condition in that state: another thread may have altered the condition before the waiting thread got the chance to be woken up, even if the condition itself is protected by a GMutex, like above. A GCond should only be accessed via the following functions. Note All of the g_cond_* functions are actually macros. Apart from taking their addresses, you can however use them as if they were functions.

GMutex
struct GMutex

The GMutex struct is an opaque data structure to represent a mutex (mutual exclusion). It can be used to protect data against shared access. Take for example the following function: It is easy to see that this won't work in a multi-threaded application. There current_number must be protected against shared access. A first naive implementation would be: This looks like it would work, but there is a race condition while constructing the mutex and this code cannot work reliable. Please do not use such constructs in your own programs! One working solution is: GStaticMutex provides a simpler and safer way of doing this. If you want to use a mutex, and your code should also work without calling g_thread_init() first, then you can not use a GMutex, as g_mutex_new() requires that the thread system be initialized. Use a GStaticMutex instead. A GMutex should only be accessed via the following functions. Note All of the g_mutex_* functions are actually macros. Apart from taking their addresses, you can however use them as if they were functions.

GOnce
struct GOnce

A GOnce struct controls a one-time initialization function. Any one-time initialization function must have its own unique GOnce struct. volatile GOnceStatus status; the status of the GOnce volatile gpointer retval; the value returned by the call to the function, if status is G_ONCE_STATUS_READY Since 2.4

GPrivate
struct GPrivate

The GPrivate struct is an opaque data structure to represent a thread private data key. Threads can thereby obtain and set a pointer which is private to the current thread. Take our give_me_next_number() example from above. Suppose we don't want current_number to be shared between the threads, but instead to be private to each thread. This can be done as follows: Here the pointer belonging to the key current_number_key is read. If it is NULL, it has not been set yet. Then get memory for an integer value, assign this memory to the pointer and write the pointer back. Now we have an integer value that is private to the current thread. The GPrivate struct should only be accessed via the following functions. Note All of the g_private_* functions are actually macros. Apart from taking their addresses, you can however use them as if they were functions.

GStaticMutex
struct GStaticMutex

A GStaticMutex works like a GMutex, but it has one significant advantage. It doesn't need to be created at run-time like a GMutex, but can be defined at compile-time. Here is a shorter, easier and safer version of our give_me_next_number()

GStaticPrivate
struct GStaticPrivate

A GStaticPrivate works almost like a GPrivate, but it has one significant advantage. It doesn't need to be created at run-time like a GPrivate, but can be defined at compile-time. This is similar to the difference between GMutex and GStaticMutex. Now look at our give_me_next_number() example with GStaticPrivate:

GStaticRWLock
struct GStaticRWLock

The GStaticRWLock struct represents a read-write lock. A read-write lock can be used for protecting data that some portions of code only read from, while others also write. In such situations it is desirable that several readers can read at once, whereas of course only one writer may write at a time. Take a look at the following

GStaticRecMutex
struct GStaticRecMutex

A GStaticRecMutex works like a GStaticMutex, but it can be locked multiple times by one thread. If you enter it n times, you have to unlock it n times again to let other threads lock it. An exception is the function g_static_rec_mutex_unlock_full(): that allows you to unlock a GStaticRecMutex completely returning the depth, (i.e. the number of times this mutex was locked). The depth can later be used to restore the state of the GStaticRecMutex by calling g_static_rec_mutex_lock_full(). Even though GStaticRecMutex is not opaque, it should only be used with the following functions. All of the g_static_rec_mutex_* functions can be used even if g_thread_init() has not been called. Then they do nothing, apart from g_static_rec_mutex_trylock, which does nothing but returning TRUE.

GThread
struct GThread

Main Gtk struct. The GThread struct represents a running thread. It has three public read-only members, but the underlying struct is bigger, so you must not copy this struct. Note Resources for a joinable thread are not fully released until g_thread_join() is called for that thread.

GThreadFunctions
struct GThreadFunctions

This function table is used by g_thread_init() to initialize the thread system. The functions in the table are directly used by their g_* prepended counterparts (described in this document). For example, if you call g_mutex_new() then mutex_new() from the table provided to g_thread_init() will be called. Note Do not use this struct unless you know what you are doing. mutex_new () virtual function pointer for g_mutex_new() mutex_lock () virtual function pointer for g_mutex_lock() mutex_trylock () virtual function pointer for g_mutex_trylock() mutex_unlock () virtual function pointer for g_mutex_unlock() mutex_free () virtual function pointer for g_mutex_free() cond_new () virtual function pointer for g_cond_new() cond_signal () virtual function pointer for g_cond_signal() cond_broadcast () virtual function pointer for g_cond_broadcast() cond_wait () virtual function pointer for g_cond_wait() cond_timed_wait () virtual function pointer for g_cond_timed_wait() cond_free () virtual function pointer for g_cond_free() private_new () virtual function pointer for g_private_new() private_get () virtual function pointer for g_private_get() private_set () virtual function pointer for g_private_set() thread_create () virtual function pointer for g_thread_create() thread_yield () virtual function pointer for g_thread_yield() thread_join () virtual function pointer for g_thread_join() thread_exit () virtual function pointer for g_thread_exit() thread_set_priority () virtual function pointer for g_thread_set_priority() thread_self () virtual function pointer for g_thread_self() thread_equal () used internally by recursive mutex locks and by some assertion checks

Meta