2 .\" This file and its contents are supplied under the terms of the
3 .\" Common Development and Distribution License ("CDDL"), version 1.0.
4 .\" You may only use this file in accordance with the terms of version
7 .\" A full copy of the text of the CDDL should have accompanied this
8 .\" source. A copy of the CDDL is also available via the Internet at
9 .\" http://www.illumos.org/license/CDDL.
12 .\" Copyright 2016 Joyent, Inc.
19 .Nd ensure function is only called once
22 .Vt "once_flag once = ONCE_FLAG_INIT;"
26 .Fa "void (*func)(void)"
31 function is used to ensure that an operation occurs only once, even
32 across multiple threads.
33 Each instance of a properly initialized
37 function; however, only a single caller will successfully execute the
40 This ensures that the argument
45 is the only thing used as a point of synchronization.
46 If multiple callers use the same pointer for
48 but use different values for
50 then only one of the functions will be successfully called.
54 should always be initialized to the symbol
58 Failure to do so will result in undefined behavior.
64 function is not itself a cancellation point; however, if the thread
67 encounters a cancellation point and is cancelled, then the value pointed
72 had not been called, as
74 had not completed successfully.
78 function does not return any values.
79 Upon its completion, it is guaranteed that
81 will have been called at most once across the liftime of the
84 .Sh INTERFACE STABILITY