...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
|
Boost.ThreadsHeader <boost/thread/once.hpp> |
Include the header <boost/thread/once.hpp>
to define the call_once
function, once_flag
type and
BOOST_ONCE_INIT
constant.
The call_once
function and once_flag
type (statically
initialized to BOOST_ONCE_INIT
) can be used to run a routine exactly
once. This can be used to initialize data in a
thread-safe manner.
#define BOOST_ONCE_INIT implementation defined
This is a constant value used to initialize once_flag
instances
to indicate that the logically associated routine has not been run yet.
typedef implementation defined once_flag;
This implementation defined type is used as a flag to insure a routine is called
only once. Instances of this type should be statically initialized to BOOST_ONCE_INIT
.
void call_once(void (*func)(), once_flag& flag);
func
shall not throw exceptions.if (flag == BOOST_ONCE_INIT) func();
flag != BOOST_ONCE_INIT
Revised 05 November, 2001
© Copyright William E. Kempf 2001-2002. All Rights Reserved.
Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. William E. Kempf makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.