#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 TimesTest.cpp.
Referenced by TEST().
41 return [&]()
mutable {
42 auto p = std::make_shared<Promise<Unit>>();
43 p->setInterruptHandler(
49 return p->getFuture();
Definition at line 61 of file TimesTest.cpp.
References EXPECT_FALSE, EXPECT_TRUE, f, makeThunk(), mutex, popAndFulfillPromise(), and folly::times().
62 std::queue<std::shared_ptr<Promise<Unit>>> ps;
65 bool complete =
false;
68 auto thunk =
makeThunk(ps, interrupt, ps_mutex);
70 .thenValue([&](
auto&&)
mutable { complete =
true; })
#define EXPECT_TRUE(condition)
std::function< Future< Unit >void)> makeThunk(std::queue< std::shared_ptr< Promise< Unit >>> &ps, int &interrupt, std::mutex &ps_mutex)
#define EXPECT_FALSE(condition)
Future< Unit > times(const int n, F &&thunk)
void popAndFulfillPromise(std::queue< std::shared_ptr< Promise< Unit >>> &ps, std::mutex &ps_mutex)
Definition at line 87 of file TimesTest.cpp.
References eggs, EXPECT_FALSE, EXPECT_TRUE, f, makeThunk(), mutex, popAndFulfillPromise(), and folly::times().
88 std::queue<std::shared_ptr<Promise<Unit>>> ps;
91 bool complete =
false;
94 auto thunk =
makeThunk(ps, interrupt, ps_mutex);
96 .thenValue([&](
auto&&)
mutable { complete =
true; })
104 auto p2 = ps.front();
108 p2->setException(
eggs);
#define EXPECT_TRUE(condition)
static eggs_t eggs("eggs")
std::function< Future< Unit >void)> makeThunk(std::queue< std::shared_ptr< Promise< Unit >>> &ps, int &interrupt, std::mutex &ps_mutex)
#define EXPECT_FALSE(condition)
Future< Unit > times(const int n, F &&thunk)
void popAndFulfillPromise(std::queue< std::shared_ptr< Promise< Unit >>> &ps, std::mutex &ps_mutex)
| TEST |
( |
Times |
, |
|
|
interrupt |
|
|
) |
| |
Definition at line 115 of file TimesTest.cpp.
References eggs, EXPECT_EQ, f, i, makeThunk(), mutex, popAndFulfillPromise(), and folly::times().
116 std::queue<std::shared_ptr<Promise<Unit>>> ps;
119 bool complete =
false;
120 bool failure =
false;
122 auto thunk =
makeThunk(ps, interrupt, ps_mutex);
124 .thenValue([&](
auto&&)
mutable { complete =
true; })
132 for (
int i = 1;
i <= 3; ++
i) {
#define EXPECT_EQ(val1, val2)
static eggs_t eggs("eggs")
std::function< Future< Unit >void)> makeThunk(std::queue< std::shared_ptr< Promise< Unit >>> &ps, int &interrupt, std::mutex &ps_mutex)
Future< Unit > times(const int n, F &&thunk)
void popAndFulfillPromise(std::queue< std::shared_ptr< Promise< Unit >>> &ps, std::mutex &ps_mutex)