Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::base::OnceFlag Class Reference

OnceFlag ensures that a target function is only evaluated once. More...

#include "once.h"

Public Member Functions

 OnceFlag ()
 
void CallOnce (const std::function< void()> &target)
 If this OnceFlag instance has never executed a target function, CallOnce calls the target function. More...
 

Static Public Member Functions

static void CallChecked (const std::function< bool()> &target)
 

Detailed Description

OnceFlag ensures that a target function is only evaluated once.

Todo:
(user): Reimplement in terms of std::call_once once c++11 is available on all platforms, and/or deprecate. Note that even once it is available, caution may be advised as some platform implementations may be very bad...

Definition at line 38 of file once.h.

Constructor & Destructor Documentation

ion::base::OnceFlag::OnceFlag ( )
inline

Definition at line 40 of file once.h.

Member Function Documentation

static void ion::base::OnceFlag::CallChecked ( const std::function< bool()> &  target)
inlinestatic

Definition at line 49 of file once.h.

References ion::port::ERROR, and LOG.

void ion::base::OnceFlag::CallOnce ( const std::function< void()> &  target)
inline

If this OnceFlag instance has never executed a target function, CallOnce calls the target function.

Inlines.

Thread safe, and all side effects of a call to a target function are guaranteed to be visible when the call returns. This call is not exception safe - if a target throws or the thread terminates this instance becomes invalid.

Definition at line 94 of file once.h.

References ion::port::YieldThread().

Referenced by ion::base::Lazy< T >::Get().


The documentation for this class was generated from the following file: