Like call_once, but using a boolean return type to signal pass/fail rather than throwing exceptions.
Declared in <folly/synchronization/CallOnce.h>
template<
typename OnceFlag,
typename F,
typename... Args>
[[nodiscard]]
bool
try_call_once(
OnceFlag& flag,
F&& f,
Args&&... args) noexcept;
Returns true if any previous call to try_call_once with the same once_flag has returned true or if any previous call to call_once with the same once_flag has completed without throwing an exception or if the function passed as an argument returns true; otherwise returns false.
Note: This has no parallel in the std::once_flag interface.
true if the flag is now set, otherwise false.
The return value should not be discarded.
| Name | Description |
|---|---|
| flag | The once-flag guarding the call. |
| f | The callable to invoke at most once; must be noexcept. |
| args | The arguments to forward to the callable. |