RUN_ONCE man page on NetBSD

Man page or keyword search:  
man Server   9087 pages
apropos Keyword Search (all sections)
Output format
NetBSD logo
[printable version]

RUN_ONCE(9)		 BSD Kernel Developer's Manual		   RUN_ONCE(9)

NAME
     RUN_ONCE — Run a function exactly once

SYNOPSIS
     #include <sys/once.h>

     ONCE_DECL(control);

     int
     RUN_ONCE(once_t *control, int (*init_func)(void));

DESCRIPTION
     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 successful execution,
     RUN_ONCE() will try again each time it is called.

     RUN_ONCE() can sleep if it's called concurrently.

RETURN VALUES
     On failure, RUN_ONCE() returns what init_func() returned.	Otherwise, it
     returns 0.

EXAMPLES
     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.

     static int
     init_func(void)
     {

	     /*
	      * do some initialization.
	      */

	     return 0; /* success */
     }

     int
     some_func(void)
     {
	     static ONCE_DECL(control);

	     RUN_ONCE(&control, init_func);

	     /*
	      * we are sure that init_func has already been completed here.
	      */
     }

SEE ALSO
     pthread_once(3), condvar(9), intro(9)

BSD				 July 7, 2010				   BSD
[top]
                             _         _         _ 
                            | |       | |       | |     
                            | |       | |       | |     
                         __ | | __ __ | | __ __ | | __  
                         \ \| |/ / \ \| |/ / \ \| |/ /  
                          \ \ / /   \ \ / /   \ \ / /   
                           \   /     \   /     \   /    
                            \_/       \_/       \_/ 
More information is available in HTML format for server NetBSD

List of man pages available for NetBSD

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net