5 #ifndef FLUTTER_IMPELLER_BASE_THREAD_H_
6 #define FLUTTER_IMPELLER_BASE_THREAD_H_
9 #include <condition_variable>
13 #include <shared_mutex>
20 class ConditionVariable;
37 Mutex(
const Mutex&) =
delete;
39 Mutex(Mutex&&) =
delete;
41 Mutex& operator=(
const Mutex&) =
delete;
43 Mutex& operator=(Mutex&&) =
delete;
61 std::shared_mutex mutex_;
63 RWMutex(
const RWMutex&) =
delete;
65 RWMutex(RWMutex&&) =
delete;
67 RWMutex& operator=(
const RWMutex&) =
delete;
69 RWMutex& operator=(RWMutex&&) =
delete;
87 Lock& operator=(
const Lock&) =
delete;
188 template <
class Clock,
class Duration>
190 const std::chrono::time_point<Clock, Duration>& time_point,
192 std::unique_lock lock(mutex.mutex_, std::adopt_lock);
193 const auto result = cv_.wait_until(lock, time_point, should_stop_waiting);
227 template <
class Representation,
class Period>
229 const std::chrono::duration<Representation, Period>& duration,
231 return WaitUntil(mutex, std::chrono::steady_clock::now() + duration,
232 should_stop_waiting);
259 std::unique_lock lock(mutex.mutex_, std::adopt_lock);
260 cv_.wait(lock, should_stop_waiting);
265 std::condition_variable cv_;
270 #endif // FLUTTER_IMPELLER_BASE_THREAD_H_