set_once()nightly-2022.10.12
commitc3876d4a4c6fe06baf3780d38091ca7c3af1e42f
authorGiuseppe Ottaviano <[email protected]>
Wed, 12 Oct 2022 01:52:11 +0000 (11 18:52 -0700)
committerFacebook GitHub Bot <[email protected]>
Wed, 12 Oct 2022 01:52:11 +0000 (11 18:52 -0700)
tree82954eeaa7420ee4cae782114933af289420b729
parenta97b7ec17f9b8cd278edb4de18f7bceb54314282
set_once()

Summary:
Counterpart to `reset_once()`. This is useful in constructors (for example copy constructors, or when laziness is conditional) where synchronization is not needed.

Besides being more self-documenting than `call_once(flag, [] {})`, it saves one (uncontended) lock acquisition.

Reviewed By: aary

Differential Revision: D40258125

fbshipit-source-id: afada56089c2958ecd930c525954b6989a40c6c3
third-party/folly/src/folly/synchronization/CallOnce.h
third-party/folly/src/folly/synchronization/test/CallOnceTest.cpp