19 #if FOLLY_HAS_COROUTINES 33 using namespace folly;
46 std::unique_lock<coro::Mutex>
lock{
m, std::try_to_lock};
47 CHECK(
lock.owns_lock());
50 std::unique_lock<coro::Mutex> lock2{
m, std::try_to_lock};
51 CHECK(!lock2.owns_lock());
76 auto f1 = makeTask(b1).scheduleOn(&inlineExecutor).start();
80 auto f2 = makeTask(b2).scheduleOn(&inlineExecutor).start();
113 auto f1 = makeTask(b1).scheduleOn(&inlineExecutor).start();
117 auto f2 = makeTask(b2).scheduleOn(&inlineExecutor).start();
136 2, std::make_shared<NamedThreadFactory>(
"CPUThreadPool")};
142 for (
int i = 0;
i < 10
'000; ++i) { 143 auto lock = co_await mutex.co_scoped_lock(); 148 auto f1 = makeTask().scheduleOn(&threadPool).start(); 149 auto f2 = makeTask().scheduleOn(&threadPool).start(); 150 auto f3 = makeTask().scheduleOn(&threadPool).start(); 156 CHECK_EQ(30'000,
value);
161 std::timed_mutex stdMutex;
163 std::thread thread1([&] {
167 std::this_thread::sleep_for(std::chrono::milliseconds{200});
175 }(coroMutex, stdMutex));
178 std::thread thread2([&] {
181 std::this_thread::sleep_for(std::chrono::milliseconds{100});
183 EXPECT_FALSE(stdMutex.try_lock_for(std::chrono::milliseconds{500}));
185 }(coroMutex, stdMutex));
LockOperation co_lock() noexcept
—— Concurrent Priority Queue Implementation ——
FOLLY_ATTR_VISIBILITY_HIDDEN static FOLLY_ALWAYS_INLINE InlineExecutor & instance() noexcept
auto lock(Synchronized< D, M > &synchronized, Args &&...args)
static map< string, int > m
ScopedLockOperation co_scoped_lock() noexcept
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
#define EXPECT_FALSE(condition)
TEST(SequencedExecutor, CPUThreadPoolExecutor)
auto blockingWait(Awaitable &&awaitable) -> detail::decay_rvalue_reference_t< await_result_t< Awaitable >>