|Linux & Unix Commands - Search Man Pages
RUN_ONCE(9) BSD Kernel Developer's Manual RUN_ONCE(9)
RUN_ONCE -- Run a function exactly once
RUN_ONCE(once_t *control, int (*init_func)(void));
RUN_ONCE() provides a functionality similar to pthread_once(3). It ensures that, for a
given control, init_func() is executed (successfully) exactly once. It is considered as a
successful execution if and only if init_func() returned 0. As long as there was no suc-
cessful execution, RUN_ONCE() will try again each time it is called.
RUN_ONCE() can sleep if it's called concurrently.
On failure, RUN_ONCE() returns what init_func() returned. Otherwise, it returns 0.
The following example shows how RUN_ONCE() is used. Regardless of how many times
some_func() is executed, init_func() will be executed exactly once.
* do some initialization.
return 0; /* success */
* we are sure that init_func has already been completed here.
pthread_once(3), condvar(9), intro(9)
BSD July 7, 2010 BSD
All times are GMT -4. The time now is 08:03 PM.