5#ifndef FLUTTER_IMPELLER_BASE_THREAD_H_
6#define FLUTTER_IMPELLER_BASE_THREAD_H_
9#include <condition_variable>
15#include "flutter/fml/logging.h"
16#include "flutter/fml/macros.h"
17#include "flutter/fml/synchronization/shared_mutex.h"
39 Mutex(
const Mutex&) =
delete;
41 Mutex(Mutex&&) =
delete;
43 Mutex& operator=(
const Mutex&) =
delete;
45 Mutex& operator=(Mutex&&) =
delete;
64 std::unique_ptr<fml::SharedMutex> mutex_;
66 RWMutex(
const RWMutex&) =
delete;
68 RWMutex(RWMutex&&) =
delete;
70 RWMutex& operator=(
const RWMutex&) =
delete;
72 RWMutex& operator=(RWMutex&&) =
delete;
90 Lock& operator=(
const Lock&) =
delete;
191 template <
class Clock,
class Duration>
193 const std::chrono::time_point<Clock, Duration>& time_point,
195 std::unique_lock lock(mutex.mutex_, std::adopt_lock);
196 const auto result = cv_.wait_until(lock, time_point, should_stop_waiting);
230 template <
class Representation,
class Period>
232 const std::chrono::duration<Representation, Period>&
duration,
235 should_stop_waiting);
262 std::unique_lock lock(mutex.mutex_, std::adopt_lock);
263 cv_.wait(lock, should_stop_waiting);
268 std::condition_variable cv_;
static SharedMutex * Create()
A condition variable exactly similar to the one in libcxx with two major differences:
ConditionVariable & operator=(const ConditionVariable &)=delete
bool WaitFor(Mutex &mutex, const std::chrono::duration< Representation, Period > &duration, const Predicate &should_stop_waiting) IPLR_REQUIRES(mutex)
Atomically unlocks the mutex and waits on the condition variable for a designated duration....
bool WaitUntil(Mutex &mutex, const std::chrono::time_point< Clock, Duration > &time_point, const Predicate &should_stop_waiting) IPLR_REQUIRES(mutex)
Atomically unlocks the mutex and waits on the condition variable up to a specified time point....
ConditionVariable(const ConditionVariable &)=delete
void Wait(Mutex &mutex, const Predicate &should_stop_waiting) IPLR_REQUIRES(mutex)
Atomically unlocks the mutex and waits on the condition variable indefinitely till the predicate dete...
std::function< bool()> Predicate
~ConditionVariable()=default
ConditionVariable()=default
Lock(Mutex &mutex) IPLR_ACQUIRE(mutex)
~ReaderLock() IPLR_RELEASE()
ReaderLock(RWMutex &mutex) IPLR_ACQUIRE_SHARED(mutex)
~WriterLock() IPLR_RELEASE()
WriterLock(RWMutex &mutex) IPLR_ACQUIRE(mutex)
#define IPLR_REQUIRES(...)
#define IPLR_ACQUIRE_SHARED(...)
#define IPLR_ACQUIRE(...)
#define IPLR_RELEASE(...)
#define IPLR_CAPABILITY(x)
#define IPLR_RELEASE_SHARED(...)
#define IPLR_SCOPED_CAPABILITY