text
stringlengths 0
2.2M
|
---|
nestedExecutor.get()->detach();
|
}
|
}
|
auto state = state_.load(std::memory_order_acquire);
|
if (state == State::EMPTY &&
|
folly::atomic_compare_exchange_strong_explicit(
|
&state_,
|
&state,
|
State::DETACHED,
|
std::memory_order_release,
|
std::memory_order_acquire)) {
|
return;
|
}
|
DCHECK(state == State::HAS_FUNCTION);
|
state_.store(State::DETACHED, std::memory_order_release);
|
std::exchange(func_, nullptr);
|
}
|
DeferredWrapper DeferredExecutor::copy() {
|
acquire();
|
return DeferredWrapper(this);
|
}
|
/* static */ DeferredWrapper DeferredExecutor::create() {
|
return DeferredWrapper(new DeferredExecutor{});
|
}
|
DeferredExecutor::DeferredExecutor() {}
|
void DeferredExecutor::acquire() {
|
auto keepAliveCount = keepAliveCount_.fetch_add(1, std::memory_order_relaxed);
|
DCHECK_GT(keepAliveCount, 0);
|
}
|
void DeferredExecutor::release() {
|
auto keepAliveCount = keepAliveCount_.fetch_sub(1, std::memory_order_acq_rel);
|
DCHECK_GT(keepAliveCount, 0);
|
if (keepAliveCount == 1) {
|
delete this;
|
}
|
}
|
InterruptHandler::~InterruptHandler() = default;
|
void InterruptHandler::acquire() {
|
auto refCount = refCount_.fetch_add(1, std::memory_order_relaxed);
|
DCHECK_GT(refCount, 0);
|
}
|
void InterruptHandler::release() {
|
auto refCount = refCount_.fetch_sub(1, std::memory_order_acq_rel);
|
DCHECK_GT(refCount, 0);
|
if (refCount == 1) {
|
delete this;
|
}
|
}
|
bool CoreBase::hasResult() const noexcept {
|
constexpr auto allowed = State::OnlyResult | State::Done;
|
auto core = this;
|
auto state = core->state_.load(std::memory_order_acquire);
|
while (state == State::Proxy) {
|
core = core->proxy_;
|
state = core->state_.load(std::memory_order_acquire);
|
}
|
return State() != (state & allowed);
|
}
|
Executor* CoreBase::getExecutor() const {
|
if (!executor_.isKeepAlive()) {
|
return nullptr;
|
}
|
return executor_.getKeepAliveExecutor();
|
}
|
DeferredExecutor* CoreBase::getDeferredExecutor() const {
|
if (!executor_.isDeferred()) {
|
return {};
|
}
|
return executor_.getDeferredExecutor();
|
}
|
DeferredWrapper CoreBase::stealDeferredExecutor() {
|
if (executor_.isKeepAlive()) {
|
return {};
|
}
|
return std::move(executor_).stealDeferred();
|
}
|
void CoreBase::raise(exception_wrapper e) {
|
if (hasResult()) {
|
return;
|
}
|
auto interrupt = interrupt_.load(std::memory_order_acquire);
|
switch (interrupt & InterruptMask) {
|
case InterruptInitial: { // store the object
|
assert(!interrupt);
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.