proxygen
|
Public Member Functions | |
ManualSchedule ()=default | |
~ManualSchedule () | |
void | setCallback (std::function< void()> callback) |
void | removeCallbacks () |
void | wait (int id) |
void | post (int id) |
Static Public Member Functions | |
static void | beforeSharedAccess () |
static void | afterSharedAccess (bool) |
Private Attributes | |
Synchronized< std::unordered_map< std::thread::id, std::function< void()> > > | callbacks_ |
Synchronized< std::unordered_map< int, folly::Baton<> > > | batons_ |
Static Private Attributes | |
static Synchronized< std::unordered_map< std::thread::id, ManualSchedule * > > | schedules_ |
Like DeterministicSchedule, but allows setting callbacks that can be run for the current thread when an atomic access occurs, and after. This allows us to construct thread interleavings by hand
Constructing a ManualSchedule is required to ensure that we maintain per-test state for threads
This can also be used to order thread movement, as an alternative to maintaining condition variables and/or semaphores for the purposes of testing, for example
auto one = std::thread{[&]() { schedule.wait(1); two(); schedule.post(2); }};
auto two = std::thread{[&]() { one(); schedule.post(1); schedule.wait(2); three(); }};
The code above is guaranteed to call one(), then two(), and then three()
Definition at line 58 of file DistributedMutexTest.cpp.
|
default |
|
inline |
Definition at line 61 of file DistributedMutexTest.cpp.
References for_each().
|
inlinestatic |
Definition at line 95 of file DistributedMutexTest.cpp.
|
inlinestatic |
These will be invoked by DeterministicAtomic to signal atomic access before and after the operation
Definition at line 75 of file DistributedMutexTest.cpp.
References folly::get_ptr(), and folly::kIsDebug.
|
inline |
Definition at line 125 of file DistributedMutexTest.cpp.
References folly::kIsDebug.
|
inline |
Delete the callback set for this thread on atomic accesses
Definition at line 112 of file DistributedMutexTest.cpp.
|
inline |
Set a callback that will be called on every subsequent atomic access. This will be invoked before and after every atomic access, for the thread that called setCallback
Definition at line 104 of file DistributedMutexTest.cpp.
Referenced by folly::TEST().
|
inline |
wait() and post() for easy testing
Definition at line 119 of file DistributedMutexTest.cpp.
References folly::kIsDebug.
|
private |
Definition at line 141 of file DistributedMutexTest.cpp.
|
private |
Definition at line 138 of file DistributedMutexTest.cpp.
|
staticprivate |
Definition at line 135 of file DistributedMutexTest.cpp.