/// This must be heap-constructed. There's probably a way to enforce that in
/// code but since this is just internal detail code and I don't know how
/// off-hand, I'm punting.
- Core() {}
+ Core() : result_(), fsm_(State::Start), attached_(2) {}
explicit Core(Try<T>&& t)
: result_(std::move(t)),
}, priority);
}
} catch (...) {
+ --attached_; // Account for extra ++attached_ before try
result_ = Try<T>(exception_wrapper(std::current_exception()));
callback_(std::move(*result_));
}
char lambdaBuf_[lambdaBufSize];
// place result_ next to increase the likelihood that the value will be
// contained entirely in one cache line
- folly::Optional<Try<T>> result_ {};
+ folly::Optional<Try<T>> result_;
std::function<void(Try<T>&&)> callback_ {nullptr};
- FSM<State> fsm_ {State::Start};
- std::atomic<unsigned char> attached_ {2};
+ FSM<State> fsm_;
+ std::atomic<unsigned char> attached_;
std::atomic<bool> active_ {true};
std::atomic<bool> interruptHandlerSet_ {false};
folly::MicroSpinLock interruptLock_ {0};
struct PriorityExecutor : public Executor {
void add(Func f) override {}
- void addWithPriority(Func, int8_t priority) override {
+ void addWithPriority(Func f, int8_t priority) override {
int mid = getNumPriorities() / 2;
int p = priority < 0 ?
std::max(0, mid + priority) :
} else if (p == 2) {
count2++;
}
+ f();
}
uint8_t getNumPriorities() const override {