#include <folly/test/DeterministicSchedule.h>
#include <algorithm>
#include <cassert>
#include <list>
#include <mutex>
#include <random>
#include <unordered_map>
#include <utility>
#include <folly/Random.h>
#include <folly/SingletonThreadLocal.h>
namespace folly {
namespace test {
Sem;
AuxChk DeterministicSchedule::aux_chk;
static std::unordered_map<
const detail::Futex<DeterministicAtomic>*,
std::list<std::pair<uint32_t, bool*>>>
futexQueues;
static std::mutex futexLock;
void ThreadTimestamps::sync(const ThreadTimestamps& src) { … }
DSchedTimestamp ThreadTimestamps::advance(DSchedThreadId tid) { … }
void ThreadTimestamps::setIfNotPresent(DSchedThreadId tid, DSchedTimestamp ts) { … }
void ThreadTimestamps::clear() { … }
bool ThreadTimestamps::atLeastAsRecentAs(
DSchedThreadId tid, DSchedTimestamp ts) const { … }
bool ThreadTimestamps::atLeastAsRecentAsAny(const ThreadTimestamps& src) const { … }
void ThreadSyncVar::acquire() { … }
void ThreadSyncVar::release() { … }
void ThreadSyncVar::acq_rel() { … }
namespace {
struct PerThreadState { … };
TLState;
}
DeterministicSchedule::DeterministicSchedule(
std::function<size_t(size_t)> scheduler)
: … { … }
DeterministicSchedule::~DeterministicSchedule() { … }
std::function<size_t(size_t)> DeterministicSchedule::uniform(uint64_t seed) { … }
struct UniformSubset { … };
bool DeterministicSchedule::isCurrentThreadExiting() { … }
bool DeterministicSchedule::isActive() { … }
DSchedThreadId DeterministicSchedule::getThreadId() { … }
DeterministicSchedule* DeterministicSchedule::getCurrentSchedule() { … }
std::function<size_t(size_t)> DeterministicSchedule::uniformSubset(
uint64_t seed, size_t n, size_t m) { … }
void DeterministicSchedule::beforeSharedAccess() { … }
void DeterministicSchedule::afterSharedAccess() { … }
void DeterministicSchedule::afterSharedAccess(bool success) { … }
size_t DeterministicSchedule::getRandNumber(size_t n) { … }
int DeterministicSchedule::getcpu(
unsigned* cpu, unsigned* node, void* ) { … }
void DeterministicSchedule::setAuxAct(AuxAct& aux) { … }
void DeterministicSchedule::setAuxChk(AuxChk& aux) { … }
void DeterministicSchedule::clearAuxChk() { … }
void DeterministicSchedule::reschedule(Sem* sem) { … }
Sem* DeterministicSchedule::descheduleCurrentThread() { … }
Sem* DeterministicSchedule::beforeThreadCreate() { … }
void DeterministicSchedule::afterThreadCreate(Sem* sem) { … }
void DeterministicSchedule::beforeThreadExit() { … }
void DeterministicSchedule::waitForBeforeThreadExit(std::thread& child) { … }
void DeterministicSchedule::joinAll(std::vector<std::thread>& children) { … }
void DeterministicSchedule::join(std::thread& child) { … }
void DeterministicSchedule::callAux(bool success) { … }
static std::unordered_map<Sem*, std::unique_ptr<ThreadSyncVar>> semSyncVar;
void DeterministicSchedule::post(Sem* sem) { … }
bool DeterministicSchedule::tryWait(Sem* sem) { … }
void DeterministicSchedule::wait(Sem* sem) { … }
ThreadInfo& DeterministicSchedule::getCurrentThreadInfo() { … }
void DeterministicSchedule::atomic_thread_fence(std::memory_order mo) { … }
detail::FutexResult futexWaitImpl(
const detail::Futex<DeterministicAtomic>* futex,
uint32_t expected,
std::chrono::system_clock::time_point const* absSystemTimeout,
std::chrono::steady_clock::time_point const* absSteadyTimeout,
uint32_t waitMask) { … }
int futexWakeImpl(
const detail::Futex<DeterministicAtomic>* futex,
int count,
uint32_t wakeMask) { … }
}
}
namespace folly {
template <>
CacheLocality const& CacheLocality::system<test::DeterministicAtomic>() { … }
template <>
Getcpu::Func AccessSpreader<test::DeterministicAtomic>::pickGetcpuFunc() { … }
}