dispatch_once_f
Executes an application-defined function only once for the lifetime of an application.
Declaration
extern void dispatch_once_f(dispatch_once_t *predicate, void *context, dispatch_function_t function);Parameters
- predicate:
A pointer to a Dispatch_once_t structure that is used to test whether the block has completed or not.
- context:
The application-defined context parameter to pass to the function.
- function:
The application-defined function to invoke once on the target queue. The parameter passed to this function is the value in the
contextparameter. This parameter cannot beNULL.
Discussion
This function is useful for initialization of global data (singletons) in an application. Always call this function before using or testing any variables that are initialized by the function.
If called simultaneously from multiple threads, this function waits synchronously until the work function has completed.
The predicate must point to a variable stored in global or static scope. The result of using a predicate with automatic or dynamic storage (including Objective-C instance variables) is undefined.