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.

struct GPrivate

Meta