22 using namespace folly;
25 using std::unique_ptr;
74 #define DOIT(CREATION_EXPR) \ 76 auto p1 = (CREATION_EXPR); \ 77 EXPECT_TRUE(p1.valid()); \ 78 auto p2 = std::move(p1); \ 79 EXPECT_FALSE(p1.valid()); \ 80 EXPECT_TRUE(p2.valid()); \ 95 #define DOIT(CREATION_EXPR) \ 97 auto p1 = (CREATION_EXPR); \ 98 EXPECT_FALSE(p1.valid()); \ 99 auto p2 = std::move(p1); \ 100 EXPECT_FALSE(p1.valid()); \ 101 EXPECT_FALSE(p2.valid()); \ 116 auto p = makeValid(); \ 118 copy(std::move(p)); \ 119 EXPECT_NO_THROW(STMT); \ 124 DOIT(p.isFulfilled());
133 auto other = makeValid();
137 auto other = makeInvalid();
150 auto p = makeValid(); \ 151 EXPECT_NO_THROW(STMT); \ 152 copy(std::move(p)); \ 153 EXPECT_THROW(STMT, PromiseInvalid); \ 156 auto const except = std::logic_error(
"foo");
159 DOIT(p.getSemiFuture());
161 DOIT(p.setException(except));
162 DOIT(p.setException(ewrap));
163 DOIT(p.setInterruptHandler([](
auto&) {}));
164 DOIT(p.setValue(42));
167 DOIT(p.setWith([] { return 42; }));
177 auto p = makeValid(); \ 178 EXPECT_NO_THROW(STMT); \ 179 EXPECT_TRUE(p.valid()); \ 182 auto const swallow = [](
auto) {};
184 DOIT(swallow(p.valid()));
185 DOIT(swallow(p.isFulfilled()));
193 #define DOIT(CTOR, STMT) \ 196 EXPECT_NO_THROW(STMT); \ 197 EXPECT_FALSE(p.valid()); \ 206 auto other = makeValid();
210 auto other = makeInvalid();
213 DOIT(makeInvalid(), {
214 auto other = makeValid();
217 DOIT(makeInvalid(), {
218 auto other = makeInvalid();
224 auto const byval = [](
auto) {};
227 DOIT(makeInvalid(), {
228 auto const byval = [](
auto) {};
248 Foo
f = {
"the answer", 42};
250 Foo f2 = fpod.value();
257 Foo f3 = fpod.value();
263 mov.
setValue(std::make_unique<int>(42));
286 Foo
f = {
"the answer", 42};
288 Foo f2 = fpod.value();
295 Foo f3 = fpod.value();
301 mov.
setValue(std::make_unique<int>(42));
359 auto p = std::make_unique<Promise<int>>();
360 auto f = p->getFuture();
374 auto pInt = std::make_unique<Promise<int>>();
375 auto fInt = pInt->getFuture();
377 auto pFloat = std::make_unique<Promise<float>>();
378 auto fFloat = pFloat->getFuture();
383 auto whatInt = fInt.getTry().exception().what();
384 auto whatFloat = fFloat.getTry().exception().what();
#define EXPECT_THROW(statement, expected_exception)
static Promise< T > makeEmpty() noexcept
#define EXPECT_EQ(val1, val2)
constexpr detail::Map< Move > move
bool isFulfilled() const noexcept
void setException(exception_wrapper ew)
—— Concurrent Priority Queue Implementation ——
constexpr std::decay< T >::type copy(T &&value) noexcept(noexcept(typename std::decay< T >::type(std::forward< T >(value))))
static eggs_t eggs("eggs")
#define EXPECT_TRUE(condition)
std::enable_if< std::is_same< Unit, B >::value, void >::type setValue()
SemiFuture< T > getSemiFuture()
#define EXPECT_NE(val1, val2)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
#define EXPECT_FALSE(condition)
#define DOIT(CREATION_EXPR)
TEST(SequencedExecutor, CPUThreadPoolExecutor)