Summary: Promise<T> has isFulFilled. This patch adds the corresponding functionality to shared promise.
Reviewed By: @jsedgwick
Differential Revision:
D2417631
}
}
+template <class T>
+bool SharedPromise<T>::isFulfilled() {
+ return hasValue_;
+}
+
}
template <class F>
void setWith(F&& func);
+ bool isFulfilled();
+
private:
std::mutex mutex_;
size_t size_{0};
p.setWith([]{ return 1; });
EXPECT_EQ(1, p.getFuture().value());
}
+
+TEST(SharedPromise, isFulfilled) {
+ SharedPromise<int> p;
+ EXPECT_FALSE(p.isFulfilled());
+ auto p2 = std::move(p);
+ EXPECT_FALSE(p2.isFulfilled());
+ p2.setValue(1);
+ EXPECT_TRUE(p2.isFulfilled());
+ p = std::move(p2);
+ EXPECT_TRUE(p.isFulfilled());
+}