FingerprintTables.cpp \
futures/Barrier.cpp \
futures/Future.cpp \
+ futures/FutureException.cpp \
futures/ManualExecutor.cpp \
futures/QueuedImmediateExecutor.cpp \
futures/ThreadWheelTimekeeper.cpp \
template <class T>
void Future<T>::throwIfInvalid() const {
if (!core_)
- throw NoState();
+ throwNoState();
}
template <class T>
if (isReady()) {
return std::move(value());
} else {
- throw TimedOut();
+ throwTimedOut();
}
}
return this->then([p = std::forward<F>(predicate)](T val) {
T const& valConstRef = val;
if (!p(valConstRef)) {
- throw PredicateDoesNotObtain();
+ throwPredicateDoesNotObtain();
}
return val;
});
--- /dev/null
+/*
+ * Copyright 2017 Facebook, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <folly/futures/FutureException.h>
+
+namespace folly {
+
+[[noreturn]] void throwNoState() {
+ throw NoState();
+}
+
+[[noreturn]] void throwPromiseAlreadySatisfied() {
+ throw PromiseAlreadySatisfied();
+}
+
+[[noreturn]] void throwFutureNotReady() {
+ throw FutureNotReady();
+}
+
+[[noreturn]] void throwFutureAlreadyRetrieved() {
+ throw FutureAlreadyRetrieved();
+}
+
+[[noreturn]] void throwTimedOut() {
+ throw TimedOut();
+}
+
+[[noreturn]] void throwPredicateDoesNotObtain() {
+ throw PredicateDoesNotObtain();
+}
+
+[[noreturn]] void throwNoFutureInSplitter() {
+ throw NoFutureInSplitter();
+}
+}
NoState() : FutureException("No state") {}
};
+[[noreturn]] void throwNoState();
+
class PromiseAlreadySatisfied : public FutureException {
public:
PromiseAlreadySatisfied() : FutureException("Promise already satisfied") {}
};
+[[noreturn]] void throwPromiseAlreadySatisfied();
+
class FutureNotReady : public FutureException {
public:
FutureNotReady() : FutureException("Future not ready") {}
};
+[[noreturn]] void throwFutureNotReady();
+
class FutureAlreadyRetrieved : public FutureException {
public:
FutureAlreadyRetrieved() : FutureException("Future already retrieved") {}
};
+[[noreturn]] void throwFutureAlreadyRetrieved();
+
class FutureCancellation : public FutureException {
public:
FutureCancellation() : FutureException("Future was cancelled") {}
TimedOut() : FutureException("Timed out") {}
};
+[[noreturn]] void throwTimedOut();
+
class PredicateDoesNotObtain : public FutureException {
public:
PredicateDoesNotObtain() : FutureException("Predicate does not obtain") {}
};
+[[noreturn]] void throwPredicateDoesNotObtain();
+
struct NoFutureInSplitter : FutureException {
NoFutureInSplitter() : FutureException("No Future in this FutureSplitter") {}
};
+
+[[noreturn]] void throwNoFutureInSplitter();
}
* This can be called an unlimited number of times per FutureSplitter.
*/
Future<T> getFuture() {
- if (UNLIKELY(promise_ == nullptr)) {
- throw NoFutureInSplitter();
+ if (promise_ == nullptr) {
+ throwNoFutureInSplitter();
}
return promise_->getFuture();
}
template <class T>
void Promise<T>::throwIfFulfilled() {
- if (UNLIKELY(!core_)) {
- throw NoState();
+ if (!core_) {
+ throwNoState();
}
- if (UNLIKELY(core_->ready())) {
- throw PromiseAlreadySatisfied();
+ if (core_->ready()) {
+ throwPromiseAlreadySatisfied();
}
}
template <class T>
void Promise<T>::throwIfRetrieved() {
- if (UNLIKELY(retrieved_)) {
- throw FutureAlreadyRetrieved();
+ if (retrieved_) {
+ throwFutureAlreadyRetrieved();
}
}
#pragma once
-#include <folly/Executor.h>
#include <chrono>
#include <memory>
#include <stdexcept>
+#include <folly/Executor.h>
+#include <folly/portability/BitsFunctexcept.h>
+
namespace folly {
// An executor that supports timed scheduling. Like RxScheduler.
class ScheduledExecutor : public virtual Executor {
/// Schedule a Func to be executed at time t, or as soon afterward as
/// possible. Expect millisecond resolution at best. Must be threadsafe.
virtual void scheduleAt(Func&& /* a */, TimePoint const& /* t */) {
- throw std::logic_error("unimplemented");
+ std::__throw_logic_error("unimplemented");
}
/// Get this executor's notion of time. Must be threadsafe.
{
std::lock_guard<std::mutex> g(mutex_);
if (hasValue_) {
- throw PromiseAlreadySatisfied();
+ throwPromiseAlreadySatisfied();
}
hasValue_ = true;
try_ = std::move(t);
#include <folly/Utility.h>
#include <folly/futures/FutureException.h>
#include <folly/futures/detail/FSM.h>
+#include <folly/portability/BitsFunctexcept.h>
#include <folly/io/async/Request.h>
if (ready()) {
return *result_;
} else {
- throw FutureNotReady();
+ throwFutureNotReady();
}
}
case State::OnlyCallback:
case State::Armed:
case State::Done:
- throw std::logic_error("setCallback called twice");
+ std::__throw_logic_error("setCallback called twice");
FSM_END
// we could always call this, it is an optimization to only call it when
case State::OnlyResult:
case State::Armed:
case State::Done:
- throw std::logic_error("setResult called twice");
+ std::__throw_logic_error("setResult called twice");
FSM_END
if (transitionToArmed) {