Function Macro
GLibonce
since: 2.4
Declaration [src]
#define g_once (
once,
func,
arg
)
Description [src]
The first call to this routine by a process with a given GOnce
struct calls func with the given argument. Thereafter, subsequent
calls to g_once() with the same GOnce struct do not call func
again, but return the stored result of the first call. On return
from g_once(), the status of once will be G_ONCE_STATUS_READY.
For example, a mutex or a thread-specific data key must be created
exactly once. In a threaded environment, calling g_once() ensures
that the initialization is serialized across multiple threads.
Calling g_once() recursively on the same GOnce struct in
func will lead to a deadlock.
gpointer get_debug_flags(void) { staticGOncemy_once=G_ONCE_INIT; g_once(&my_once,parse_debug_flags,NULL); returnmy_once.retval; }
Available since: 2.4
This function is not directly available to language bindings.
Parameters
once-
Type:
-A
GOncestructure. func-
Type:
-The
GThreadFuncfunction associated toonce. This function is called only once, regardless of the number of times it and its associatedGOncestruct are passed to g_once(). arg-
Type:
-Data to be passed to
func.