8 namespace onnxruntime {
21 SRWLOCK data_ = SRWLOCK_INIT;
38 CONDITION_VARIABLE native_cv_object = CONDITION_VARIABLE_INIT;
47 void notify_one() noexcept { WakeConditionVariable(&native_cv_object); }
48 void notify_all() noexcept { WakeAllConditionVariable(&native_cv_object); }
50 void wait(std::unique_lock<OrtMutex>& lk) {
51 if (SleepConditionVariableSRW(&native_cv_object, lk.mutex()->native_handle(), INFINITE, 0) != TRUE) {
55 template <
class _Predicate>
56 void wait(std::unique_lock<OrtMutex>& __lk, _Predicate __pred);
66 template <
class Rep,
class Period>
67 std::cv_status
wait_for(std::unique_lock<OrtMutex>& cond_mutex,
const std::chrono::duration<Rep, Period>& rel_time);
73 void timed_wait_impl(std::unique_lock<OrtMutex>& __lk,
74 std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>);
77 template <
class _Predicate>
79 while (!__pred())
wait(__lk);
82 template <
class Rep,
class Period>
84 const std::chrono::duration<Rep, Period>& rel_time) {
86 using namespace std::chrono;
89 using SystemTimePointFloat = time_point<system_clock, duration<long double, std::nano> >;
90 using SystemTimePoint = time_point<system_clock, nanoseconds>;
92 steady_clock::time_point steady_now = steady_clock::now();
93 system_clock::time_point system_now = system_clock::now();
94 if (max_time - rel_time > system_now) {
95 nanoseconds remain = duration_cast<nanoseconds>(rel_time);
96 if (remain < rel_time)
98 timed_wait_impl(cond_mutex, system_now + remain);
107 #include <condition_variable>
108 namespace onnxruntime {
111 nsync::nsync_mu data_ = NSYNC_MU_INIT;
119 void lock() { nsync::nsync_mu_lock(&data_); }
120 bool try_lock() noexcept {
return nsync::nsync_mu_trylock(&data_) == 0; }
121 void unlock() noexcept { nsync::nsync_mu_unlock(&data_); }
128 nsync::nsync_cv native_cv_object = NSYNC_CV_INIT;
137 void notify_one() noexcept { nsync::nsync_cv_signal(&native_cv_object); }
138 void notify_all() noexcept { nsync::nsync_cv_broadcast(&native_cv_object); }
140 void wait(std::unique_lock<OrtMutex>& lk);
141 template <
class _Predicate>
142 void wait(std::unique_lock<OrtMutex>& __lk, _Predicate __pred);
152 template <
class Rep,
class Period>
153 std::cv_status
wait_for(std::unique_lock<OrtMutex>& cond_mutex,
const std::chrono::duration<Rep, Period>& rel_time);
158 void timed_wait_impl(std::unique_lock<OrtMutex>& __lk,
159 std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>);
162 template <
class _Predicate>
164 while (!__pred())
wait(__lk);
167 template <
class Rep,
class Period>
169 const std::chrono::duration<Rep, Period>& rel_time) {
171 using namespace std::chrono;
174 using SystemTimePointFloat = time_point<system_clock, duration<long double, std::nano> >;
175 using SystemTimePoint = time_point<system_clock, nanoseconds>;
177 steady_clock::time_point steady_now = steady_clock::now();
178 system_clock::time_point system_now = system_clock::now();
179 if (max_time - rel_time > system_now) {
180 nanoseconds remain = duration_cast<nanoseconds>(rel_time);
181 if (remain < rel_time)
183 timed_wait_impl(cond_mutex, system_now + remain);
void notify_all() noexcept
native_handle_type native_handle()
native_handle_type native_handle()
constexpr OrtCondVar() noexcept=default
OrtCondVar & operator=(const OrtCondVar &)=delete
constexpr OrtMutex()=default
nsync::nsync_cv * native_handle_type
nsync::nsync_mu * native_handle_type
GLbitfield GLuint64 timeout
void wait(std::unique_lock< OrtMutex > &lk)
OrtMutex & operator=(const OrtMutex &)=delete
std::cv_status wait_for(std::unique_lock< OrtMutex > &cond_mutex, const std::chrono::duration< Rep, Period > &rel_time)
void notify_one() noexcept
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
ImageBuf OIIO_API zero(ROI roi, int nthreads=0)