5 #ifndef FLUTTER_IMPELLER_BASE_THREAD_H_
6 #define FLUTTER_IMPELLER_BASE_THREAD_H_
9 #include <condition_variable>
15 #include "flutter/fml/synchronization/shared_mutex.h"
20 class ConditionVariable;
37 Mutex(
const Mutex&) =
delete;
39 Mutex(Mutex&&) =
delete;
41 Mutex& operator=(
const Mutex&) =
delete;
43 Mutex& operator=(Mutex&&) =
delete;
49 : mutex_(
std::unique_ptr<fml::SharedMutex>(fml::SharedMutex::Create())) {}
62 std::unique_ptr<fml::SharedMutex> mutex_;
64 RWMutex(
const RWMutex&) =
delete;
66 RWMutex(RWMutex&&) =
delete;
68 RWMutex& operator=(
const RWMutex&) =
delete;
70 RWMutex& operator=(RWMutex&&) =
delete;
88 Lock& operator=(
const Lock&) =
delete;
189 template <
class Clock,
class Duration>
191 const std::chrono::time_point<Clock, Duration>& time_point,
193 std::unique_lock lock(mutex.mutex_, std::adopt_lock);
194 const auto result = cv_.wait_until(lock, time_point, should_stop_waiting);
228 template <
class Representation,
class Period>
230 const std::chrono::duration<Representation, Period>& duration,
232 return WaitUntil(mutex, std::chrono::steady_clock::now() + duration,
233 should_stop_waiting);
260 std::unique_lock lock(mutex.mutex_, std::adopt_lock);
261 cv_.wait(lock, should_stop_waiting);
266 std::condition_variable cv_;
271 #endif // FLUTTER_IMPELLER_BASE_THREAD_H_