folly::try_call_once

try_call_once overloads

Synopses

Declared in <folly/synchronization/CallOnce.h>

Grants the free try_call_once access to the flag internals.

bool
try_call_once(
    OnceFlag&,
    F&&,
    Args&&...) noexcept;
» more...

Like call_once, but using a boolean return type to signal pass/fail rather than throwing exceptions.

template<
    typename OnceFlag,
    typename F,
    typename... Args>
[[nodiscard]]
bool
try_call_once(
    OnceFlag& flag,
    F&& f,
    Args&&... args) noexcept;
» more...

Return Value

true if the flag is now set, otherwise false.

Parameters

NameDescription
flagThe once-flag guarding the call.
fThe callable to invoke at most once; must be noexcept.
argsThe arguments to forward to the callable.