setTry(makeTryWith(std::forward<F>(func)));
}
+template <class T>
+bool Promise<T>::isFulfilled() {
+ if (core_) {
+ return core_->hasResult();
+ }
+ return true;
+}
+
}
template <class F>
void setWith(F&& func);
+ bool isFulfilled();
+
private:
typedef typename Future<T>::corePtr corePtr;
EXPECT_TRUE(collect(fs2).isReady());
}
+
+TEST(Promise, isFulfilled) {
+ Promise<int> p;
+
+ EXPECT_FALSE(p.isFulfilled());
+ p.setValue(42);
+ EXPECT_TRUE(p.isFulfilled());
+}
+
+TEST(Promise, isFulfilledWithFuture) {
+ Promise<int> p;
+ auto f = p.getFuture(); // so core_ will become null
+
+ EXPECT_FALSE(p.isFulfilled());
+ p.setValue(42); // after here
+ EXPECT_TRUE(p.isFulfilled());
+}