69 DISPENSO_REQUIRES(OnceCallableFunc<F>)
70 OnceFunction(F&& f) : ops_(detail::createOnceCallable(std::forward<F>(f), buf_)) {}
84#if defined DISPENSO_DEBUG
86 ops_->invoke ==
nullptr &&
87 "OnceFunction must be invoked or cleanupNotRun() before reassignment");
100#if defined DISPENSO_DEBUG
101 assert(ops_->invoke !=
nullptr &&
"Must not cleanup an invalid OnceFunction!");
103 consumeOps()->invoke(buf_,
false);
110 void operator()()
const {
111#if defined DISPENSO_DEBUG
112 assert(ops_->invoke !=
nullptr &&
"Must not use OnceFunction more than once!");
114 consumeOps()->invoke(buf_,
true);
124 if (DISPENSO_EXPECT(other.ops_->relocate ==
nullptr,
true)) {
125 std::memcpy(
static_cast<void*
>(
this), &other,
sizeof(
OnceFunction));
128 ops_->relocate(other.buf_, buf_);
130 other.ops_ = detail::emptyOps();
135 const detail::OnceCallableOps* consumeOps()
const {
136 const detail::OnceCallableOps* ops = ops_;
137 ops_ = detail::emptyOps();
141 alignas(64)
mutable char buf_[detail::kOnceFunctionInlineSize];
142 mutable const detail::OnceCallableOps* ops_;
144 template <
typename Result>
145 friend class detail::FutureBase;
146 template <
typename Result>
147 friend class detail::FutureImplBase;