|
Robotics Library
0.7.0
|
Go to the documentation of this file.
27 #ifndef RL_UTIL_XENOMAI_CONDITION_VARIABLE_H
28 #define RL_UTIL_XENOMAI_CONDITION_VARIABLE_H
33 #include <native/cond.h>
56 int e = ::rt_cond_create(&this->
M_cond,
nullptr);
60 throw ::std::system_error(::std::error_code(-e, ::std::generic_category()));
66 int e = ::rt_cond_delete(&this->
M_cond);
70 throw ::std::system_error(::std::error_code(-e, ::std::generic_category()));
85 int e = ::rt_cond_signal(&this->
M_cond);
89 throw ::std::system_error(::std::error_code(-e, ::std::generic_category()));
95 int e = ::rt_cond_broadcast(&this->
M_cond);
99 throw ::std::system_error(::std::error_code(-e, ::std::generic_category()));
103 void wait(::std::unique_lock<mutex>& lock)
105 int e = ::rt_cond_wait(&this->
M_cond, lock.mutex()->native_handle(), TM_INFINITE);
109 throw ::std::system_error(::std::error_code(-e, ::std::generic_category()));
113 template<
typename Predicate>
114 void wait(::std::unique_lock<mutex>& lock, Predicate p)
122 template<
typename Duration>
123 ::std::cv_status
wait_until(::std::unique_lock<mutex>& lock, const ::std::chrono::time_point<clock_t, Duration>& atime)
125 ::std::chrono::time_point<clock_t, ::std::chrono::nanoseconds> ns = ::std::chrono::time_point_cast< ::std::chrono::nanoseconds>(atime);
126 int e = ::rt_cond_wait_until(&this->
M_cond, lock.mutex()->native_handle(), ::rt_timer_ns2ticks(ns.time_since_epoch().count()));
130 throw ::std::system_error(::std::error_code(-e, ::std::generic_category()));
133 return (
clock_t::now() < atime ? ::std::cv_status::no_timeout : ::std::cv_status::timeout);
136 template<
typename Clock,
typename Duration>
137 ::std::cv_status
wait_until(::std::unique_lock<mutex>& lock, const ::std::chrono::time_point<Clock, Duration>& atime)
139 const typename Clock::time_point c_entry = Clock::now();
141 const ::std::chrono::nanoseconds delta = atime - c_entry;
146 template<
typename Clock,
typename Duration,
typename Predicate>
147 bool wait_until(::std::unique_lock<mutex>& lock, const ::std::chrono::time_point<Clock, Duration>& atime, Predicate p)
151 if (this->
wait_until(lock, atime) == ::std::cv_status::timeout)
160 template<
typename Rep,
typename Period>
161 ::std::cv_status
wait_for(::std::unique_lock<mutex>& lock, const ::std::chrono::duration<Rep, Period>& rtime)
166 template<
typename Rep,
typename Period,
typename Predicate>
167 bool wait_for(::std::unique_lock<mutex>& lock, const ::std::chrono::duration<Rep, Period>& rtime, Predicate p)
204 ::std::lock_guard<mutex> lock(*this->
M_mutex);
210 ::std::lock_guard<mutex> lock(*this->
M_mutex);
214 template<
typename Lock>
217 ::std::shared_ptr<mutex> my_mutex = this->
M_mutex;
218 ::std::unique_lock<mutex> my_lock(*my_mutex);
220 ::std::unique_lock<mutex> my_lock2(::std::move(my_lock));
225 template<
typename Lock,
typename Predicate>
226 void wait(Lock& lock, Predicate p)
234 template<
typename Lock,
typename Clock,
typename Duration>
235 ::std::cv_status
wait_until(Lock& lock, const ::std::chrono::time_point<Clock, Duration>& atime)
237 ::std::shared_ptr<mutex> my_mutex = this->
M_mutex;
238 ::std::unique_lock<mutex> my_lock(*my_mutex);
240 ::std::unique_lock<mutex> my_lock2(::std::move(my_lock));
244 template<
typename Lock,
typename Clock,
typename Duration,
typename Predicate>
245 bool wait_until(Lock& lock, const ::std::chrono::time_point<Clock, Duration>& atime, Predicate p)
249 if (this->
wait_until(lock, atime) == ::std::cv_status::timeout)
258 template<
typename Lock,
typename Rep,
typename Period>
259 ::std::cv_status
wait_for(Lock& lock, const ::std::chrono::duration<Rep, Period>& rtime)
264 template<
typename Lock,
typename Rep,
typename Period,
typename Predicate>
265 bool wait_for(Lock& lock, const ::std::chrono::duration<Rep, Period>& rtime, Predicate p)
275 template<
typename Lock>
290 if (::std::uncaught_exception())
317 #endif // RL_UTIL_XENOMAI_CONDITION_VARIABLE_H
void notify_one()
Definition: condition_variable.h:83
void wait(::std::unique_lock< mutex > &lock)
Definition: condition_variable.h:103
::std::cv_status wait_until(Lock &lock, const ::std::chrono::time_point< Clock, Duration > &atime)
Definition: condition_variable.h:235
bool wait_until(::std::unique_lock< mutex > &lock, const ::std::chrono::time_point< Clock, Duration > &atime, Predicate p)
Definition: condition_variable.h:147
native_handle_type native_handle()
Definition: condition_variable.h:197
void wait(Lock &lock, Predicate p)
Definition: condition_variable.h:226
void wait(Lock &lock)
Definition: condition_variable.h:215
bool wait_for(Lock &lock, const ::std::chrono::duration< Rep, Period > &rtime, Predicate p)
Definition: condition_variable.h:265
Definition: condition_variable.h:179
void notify_one()
Definition: condition_variable.h:202
chrono::system_clock clock_t
Definition: condition_variable.h:173
Definition: condition_variable.h:47
native_type M_cond
Definition: condition_variable.h:175
void notify_all()
Definition: condition_variable.h:93
~condition_variable()
Definition: condition_variable.h:64
::std::cv_status wait_until(::std::unique_lock< mutex > &lock, const ::std::chrono::time_point< clock_t, Duration > &atime)
Definition: condition_variable.h:123
Lock & M_lock
Definition: condition_variable.h:306
condition_variable_any(const condition_variable_any &)=delete
bool wait_until(Lock &lock, const ::std::chrono::time_point< Clock, Duration > &atime, Predicate p)
Definition: condition_variable.h:245
native_handle_type native_handle()
Definition: condition_variable.h:78
condition_variable_any()
Definition: condition_variable.h:183
Definition: condition_variable.h:277
::std::cv_status wait_for(::std::unique_lock< mutex > &lock, const ::std::chrono::duration< Rep, Period > &rtime)
Definition: condition_variable.h:161
Unlock(const Unlock &)=delete
~condition_variable_any()
Definition: condition_variable.h:189
::std::cv_status wait_for(Lock &lock, const ::std::chrono::duration< Rep, Period > &rtime)
Definition: condition_variable.h:259
::std::cv_status wait_until(::std::unique_lock< mutex > &lock, const ::std::chrono::time_point< Clock, Duration > &atime)
Definition: condition_variable.h:137
RT_COND native_type
Definition: condition_variable.h:49
recursive_mutex mutex
Definition: condition_variable.h:44
void wait(::std::unique_lock< mutex > &lock, Predicate p)
Definition: condition_variable.h:114
condition_variable()
Definition: condition_variable.h:53
condition_variable M_cond
Definition: condition_variable.h:309
~Unlock() noexcept(false)
Definition: condition_variable.h:288
::std::shared_ptr< mutex > M_mutex
Definition: condition_variable.h:311
native_type * native_handle_type
Definition: condition_variable.h:51
::std::chrono::time_point< system_clock, duration > time_point
Definition: chrono.h:69
condition_variable_any & operator=(const condition_variable_any &)=delete
condition_variable(const condition_variable &)=delete
bool wait_for(::std::unique_lock< mutex > &lock, const ::std::chrono::duration< Rep, Period > &rtime, Predicate p)
Definition: condition_variable.h:167
Unlock(Lock &lk)
Definition: condition_variable.h:278
condition_variable & operator=(const condition_variable &)=delete
chrono::system_clock clock_t
Definition: condition_variable.h:273
void notify_all()
Definition: condition_variable.h:208
static time_point now()
Definition: chrono.h:75
condition_variable::native_handle_type native_handle_type
Definition: condition_variable.h:181
Unlock & operator=(const Unlock &)=delete
Robotics Library.
Definition: AnalogInput.cpp:30