25 using namespace folly;
27 using std::chrono::milliseconds;
29 TEST(Wait, waitImmediate) {
34 vector<int>
v{1, 2, 3};
39 vector<Future<Unit>> v_f;
45 vector<Future<bool>> v_fb;
49 auto done_v_fb =
std::move(fut.wait().value());
56 std::atomic<bool>
flag{
false};
57 std::atomic<int> result{1};
58 std::atomic<std::thread::id> id;
63 id = std::this_thread::get_id();
67 result.store(n.wait().value());
77 EXPECT_EQ(
id, std::this_thread::get_id());
91 TEST(Wait, waitReplacesSelf) {
108 f1.wait(milliseconds(1));
134 f.
wait(milliseconds(1));
143 f.
wait(milliseconds(1));
147 vector<Future<bool>> v_fb;
151 f.wait(milliseconds(1));
156 vector<Future<bool>> v_fb;
162 f.wait(milliseconds(1));
177 auto f = p.
getFuture().wait(milliseconds(100));
190 auto t = std::thread([&] {
192 std::this_thread::sleep_for(milliseconds(100));
196 auto f = p.
getFuture().wait(std::chrono::seconds(3600));
209 auto t = std::thread([&] {
211 std::this_thread::sleep_for(milliseconds(100));
216 f.wait(std::chrono::seconds(10));
234 auto t = std::thread([&] {
236 std::this_thread::sleep_for(milliseconds(100));
241 auto f2 =
std::move(f1).wait(std::chrono::seconds(10));
261 auto t = std::thread([&] {
263 std::this_thread::sleep_for(milliseconds(100));
276 for (
size_t i = 0;
i < 5; ++
i) {
278 f.wait(milliseconds(3));
303 auto continuation = 0;
305 std::move(
f).thenValue([&](
auto&&
v) { continuation =
v; }));
316 auto t = std::thread([&] {
318 std::this_thread::sleep_for(milliseconds(100));
326 auto continuation = 0;
328 std::move(
f).thenValue([&](
auto&&
v) { continuation =
v; }));
341 f.wait(std::chrono::seconds(10));
342 auto continuation = 0;
344 std::move(
f).thenValue([&](
auto&&
v) { continuation =
v; }));
355 auto t = std::thread([&] {
357 std::this_thread::sleep_for(milliseconds(100));
363 f.wait(std::chrono::seconds(10));
365 auto continuation = 0;
367 std::move(
f).thenValue([&](
auto&&
v) { continuation =
v; }));
377 f.wait(milliseconds(1));
378 auto continuation = 0;
380 std::move(
f).thenValue([&](
auto&&
v) { continuation =
v; }));
393 auto continuation = 0;
397 std::move(f2).thenValue([&](
auto&&
v) { continuation =
v; }));
408 auto t = std::thread([&] {
410 std::this_thread::sleep_for(milliseconds(100));
418 auto continuation = 0;
422 std::move(f2).thenValue([&](
auto&&
v) { continuation =
v; }));
#define EXPECT_NO_THROW(statement)
#define EXPECT_EQ(val1, val2)
Future< Unit > sleep(Duration dur, Timekeeper *tk)
std::chrono::steady_clock::time_point now()
constexpr detail::Map< Move > move
SemiFuture< std::tuple< Try< typename remove_cvref_t< Fs >::value_type >... > > collectAllSemiFuture(Fs &&...fs)
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
#define EXPECT_GE(val1, val2)
FOLLY_ALWAYS_INLINE void wait(const WaitOptions &opt=wait_options()) noexcept
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
Future< std::tuple< Try< typename remove_cvref_t< Fs >::value_type >... > > collectAll(Fs &&...fs)
#define EXPECT_TRUE(condition)
std::enable_if< std::is_same< Unit, B >::value, void >::type setValue()
SemiFuture< T > getSemiFuture()
MoveFlag(MoveFlag &&other) noexcept
#define EXPECT_FALSE(condition)
TEST(SequencedExecutor, CPUThreadPoolExecutor)
Future< typename std::decay< T >::type > makeFuture(T &&t)