#include <memory>
#include <mutex>
#include <queue>
#include <folly/futures/Future.h>
#include <folly/futures/Promise.h>
#include <folly/portability/GTest.h>
Go to the source code of this file.
std::function<bool(void)> makePred |
( |
int & |
i | ) |
|
|
inline |
Definition at line 37 of file WhileDoTest.cpp.
Referenced by TEST().
41 return [&]()
mutable {
42 auto p = std::make_shared<Promise<Unit>>();
43 p->setInterruptHandler(
49 return p->getFuture();
TEST |
( |
WhileDo |
, |
|
|
success |
|
|
) |
| |
Definition at line 61 of file WhileDoTest.cpp.
References EXPECT_FALSE, EXPECT_TRUE, f, i, makePred(), makeThunk(), mutex, popAndFulfillPromise(), and folly::whileDo().
62 std::queue<std::shared_ptr<Promise<Unit>>> ps;
66 bool complete =
false;
70 auto thunk =
makeThunk(ps, interrupt, ps_mutex);
72 .thenValue([&](
auto&&)
mutable { complete =
true; })
Future< Unit > whileDo(P &&predicate, F &&thunk)
std::function< Future< Unit >void)> makeThunk(std::queue< std::shared_ptr< Promise< Unit >>> &ps, int &interrupt, std::mutex &ps_mutex)
#define EXPECT_TRUE(condition)
void popAndFulfillPromise(std::queue< std::shared_ptr< Promise< Unit >>> &ps, std::mutex &ps_mutex)
#define EXPECT_FALSE(condition)
std::function< bool(void)> makePred(int &i)
TEST |
( |
WhileDo |
, |
|
|
failure |
|
|
) |
| |
Definition at line 89 of file WhileDoTest.cpp.
References eggs, EXPECT_FALSE, EXPECT_TRUE, f, i, makePred(), makeThunk(), mutex, popAndFulfillPromise(), and folly::whileDo().
90 std::queue<std::shared_ptr<Promise<Unit>>> ps;
94 bool complete =
false;
98 auto thunk =
makeThunk(ps, interrupt, ps_mutex);
100 .thenValue([&](
auto&&)
mutable { complete =
true; })
108 auto p2 = ps.front();
112 p2->setException(
eggs);
Future< Unit > whileDo(P &&predicate, F &&thunk)
std::function< Future< Unit >void)> makeThunk(std::queue< std::shared_ptr< Promise< Unit >>> &ps, int &interrupt, std::mutex &ps_mutex)
#define EXPECT_TRUE(condition)
static eggs_t eggs("eggs")
void popAndFulfillPromise(std::queue< std::shared_ptr< Promise< Unit >>> &ps, std::mutex &ps_mutex)
#define EXPECT_FALSE(condition)
std::function< bool(void)> makePred(int &i)
TEST |
( |
WhileDo |
, |
|
|
interrupt |
|
|
) |
| |
Definition at line 119 of file WhileDoTest.cpp.
References eggs, EXPECT_EQ, f, i, makePred(), makeThunk(), mutex, popAndFulfillPromise(), and folly::whileDo().
120 std::queue<std::shared_ptr<Promise<Unit>>> ps;
123 bool complete =
false;
124 bool failure =
false;
128 auto thunk =
makeThunk(ps, interrupt, ps_mutex);
130 .thenValue([&](
auto&&)
mutable { complete =
true; })
138 for (
int j = 1; j <= 3; ++j) {
Future< Unit > whileDo(P &&predicate, F &&thunk)
#define EXPECT_EQ(val1, val2)
std::function< Future< Unit >void)> makeThunk(std::queue< std::shared_ptr< Promise< Unit >>> &ps, int &interrupt, std::mutex &ps_mutex)
static eggs_t eggs("eggs")
void popAndFulfillPromise(std::queue< std::shared_ptr< Promise< Unit >>> &ps, std::mutex &ps_mutex)
std::function< bool(void)> makePred(int &i)