#include <folly/detail/AtFork.h>
#include <folly/portability/GTest.h>
#include <glog/logging.h>
#include <atomic>
#include <mutex>
#include <thread>
Go to the source code of this file.
|
| TEST (ThreadLocal, AtFork) |
|
| TEST (ThreadLocal, AtForkOrdering) |
|
TEST |
( |
ThreadLocal |
, |
|
|
AtFork |
|
|
) |
| |
Definition at line 25 of file AtForkTest.cpp.
References EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, testing::gmock_matchers_test::foo, folly::detail::AtFork::registerHandler(), folly::detail::AtFork::unregisterHandler(), and folly::detail::distributed_mutex::wait().
39 auto pid2 =
wait(&status);
51 auto pid2 =
wait(&status);
#define EXPECT_EQ(val1, val2)
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
#define EXPECT_TRUE(condition)
static void unregisterHandler(void *object)
#define EXPECT_FALSE(condition)
static void registerHandler(void *object, folly::Function< bool()> prepare, folly::Function< void()> parent, folly::Function< void()> child)
TEST |
( |
ThreadLocal |
, |
|
|
AtForkOrdering |
|
|
) |
| |
Definition at line 60 of file AtForkTest.cpp.
References a, b, EXPECT_EQ, testing::gmock_matchers_test::foo, foo2(), g(), mutex, folly::detail::AtFork::registerHandler(), and folly::detail::distributed_mutex::wait().
61 std::atomic<bool> done{
false};
62 std::atomic<bool> started{
false};
69 [&] {
return a.try_lock(); },
74 [&] {
return b.try_lock(); },
78 auto thr = std::thread([&]() {
79 std::lock_guard<std::mutex>
g(a);
82 std::lock_guard<std::mutex> g2(b);
89 auto pid2 =
wait(&status);
#define EXPECT_EQ(val1, val2)
FOLLY_NOINLINE void foo2()
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
static void registerHandler(void *object, folly::Function< bool()> prepare, folly::Function< void()> parent, folly::Function< void()> child)