23 using namespace folly;
24 using std::chrono::milliseconds;
26 std::chrono::milliseconds
const zero_ms(0);
27 std::chrono::milliseconds
const one_ms(1);
28 std::chrono::milliseconds
const awhile(10);
29 std::chrono::seconds
const too_long(10);
31 std::chrono::steady_clock::time_point
now() {
43 auto f = timeLord_->after(
awhile);
53 auto t = std::thread([&] { p.
setValue(42); });
60 auto t = std::thread([&] { p.
setValue(42); });
114 .thenValue([=](
auto&&) {
return now() - t1; })
125 .thenValue([=](
auto&&) {
return now() - t1; })
135 .thenValue([=](
auto&&) {
return now() - t1; })
147 std::thread::id get_thread_id() {
148 return thread_.get_id();
152 std::thread::id timekeeper_thread_id = tk.get_thread_id();
153 std::thread::id task_thread_id{};
156 .thenValue([=, &task_thread_id](
auto&&) {
157 task_thread_id = std::this_thread::get_id();
163 EXPECT_EQ(timekeeper_thread_id, task_thread_id);
170 std::thread::id driver_thread_id{};
171 std::thread::id first_task_thread_id{};
172 std::thread::id second_task_thread_id{};
174 std::atomic<bool> stop_signal{
false};
175 std::thread me_driver{[&me, &driver_thread_id, &stop_signal] {
176 driver_thread_id = std::this_thread::get_id();
177 while (!stop_signal) {
183 .thenValue([&first_task_thread_id](
auto&&) {
184 first_task_thread_id = std::this_thread::get_id();
187 .thenValue([=, &second_task_thread_id](
auto&&) {
188 second_task_thread_id = std::this_thread::get_id();
195 EXPECT_EQ(driver_thread_id, first_task_thread_id);
196 EXPECT_EQ(driver_thread_id, second_task_thread_id);
233 .within(std::chrono::minutes(1))
243 .within(std::chrono::minutes(1))
315 return makeFuture<Unit>(std::runtime_error(
"expected"));
328 futures::sleep(milliseconds(100)).thenValue([&](
auto&&) { test =
true; });
342 auto f = p.
getFuture().within(milliseconds(100));
365 class ExecutorTester :
public Executor {
371 std::atomic<int>
count{0};
375 ExecutorTester tester;
376 auto f = p.
getFuture().via(&tester).within(
one_ms).thenValue([&](
auto&&) {});
404 auto f = timeLord_->after(
405 std::chrono::duration_cast<Duration>(std::chrono::nanoseconds(1)));
411 auto f = tk->
after(std::chrono::seconds(10));
void setInterruptHandler(F &&fn)
void handle(CatchFns...fns)
#define EXPECT_THROW(statement, expected_exception)
std::shared_ptr< Timekeeper > getTimekeeperSingleton()
static void make_mock(std::nullptr_t=nullptr, typename Singleton< T >::TeardownFunc t=nullptr)
#define EXPECT_EQ(val1, val2)
Future< Unit > sleep(Duration dur, Timekeeper *tk)
constexpr detail::Map< Move > move
std::chrono::steady_clock::time_point now()
void setException(exception_wrapper ew)
—— Concurrent Priority Queue Implementation ——
std::chrono::seconds const too_long(10)
#define EXPECT_GE(val1, val2)
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
std::shared_ptr< Timekeeper > timeLord_
std::chrono::milliseconds const one_ms(1)
std::chrono::milliseconds const zero_ms(0)
Value & emplace(Args &&...args)
TEST_F(AsyncSSLSocketWriteTest, write_coalescing1)
#define EXPECT_TRUE(condition)
std::enable_if< std::is_same< Unit, B >::value, void >::type setValue()
SemiFuture< T > getSemiFuture()
#define EXPECT_FALSE(condition)
Future< Unit > after(Duration) override
std::chrono::milliseconds const awhile(10)
TEST(SequencedExecutor, CPUThreadPoolExecutor)
Future< typename std::decay< T >::type > makeFuture(T &&t)
SemiFuture< typename std::decay< T >::type > makeSemiFuture(T &&t)