An alternative flag that can be used with call_once that uses only 1 byte. Uses a 3‐state std::atomic<uint8_t> with wait/notify for synchronization.

Synopsis

Declared in <folly/synchronization/CallOnce.h>

class compact_once_flag;

Member Functions

Name

Description

compact_once_flag [constructor]

Constructors

operator= [deleted]

Deleted copy assignment; once‐flags are not copyable.

Friends

Name

Description

folly::try_call_once

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

folly::set_once

Sets a flag, as if call_once(flag, []{}) was called.

folly::reset_once

Resets a flag.

folly::test_once

Tests whether any invocation to call_once with the given flag has succeeded.

folly::call_once

Drop‐in replacement for std::call_once.

Created with MrDocs