26 template <
typename Fn,
typename... Args>
28 auto state = fState.load(std::memory_order_acquire);
35 if (
state == NotStarted && fState.compare_exchange_strong(
state, Claimed,
36 std::memory_order_relaxed,
37 std::memory_order_relaxed)) {
39 fn(std::forward<Args>(
args)...);
40 return fState.store(Done, std::memory_order_release);
46 while (fState.load(std::memory_order_acquire) != Done) { }
51 enum State : uint8_t { NotStarted, Claimed, Done};
52 std::atomic<uint8_t> fState{NotStarted};
#define SK_POTENTIALLY_BLOCKING_REGION_END
#define SK_POTENTIALLY_BLOCKING_REGION_BEGIN
void operator()(Fn &&fn, Args &&... args)
constexpr SkOnce()=default
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args