/*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
template <class T>
void Promise<T>::throwIfFulfilled() {
- if (!core_)
+ if (UNLIKELY(!core_)) {
throw NoState();
- if (core_->ready())
+ }
+ if (UNLIKELY(core_->ready())) {
throw PromiseAlreadySatisfied();
+ }
}
template <class T>
void Promise<T>::throwIfRetrieved() {
- if (retrieved_)
+ if (UNLIKELY(retrieved_)) {
throw FutureAlreadyRetrieved();
+ }
}
template <class T>
setTry(makeTryWith(std::forward<F>(func)));
}
+template <class T>
+bool Promise<T>::isFulfilled() {
+ if (core_) {
+ return core_->hasResult();
+ }
+ return true;
+}
+
}