Changeset d350175 in mainline
- Timestamp:
- 2018-07-05T21:41:20Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2be40c81
- Parents:
- da6bcc0
- git-author:
- Dzejrou <dzejrou@…> (2018-03-29 16:04:53)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:20)
- Location:
- uspace/lib/cpp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/mutex.hpp
rda6bcc0 rd350175 202 202 */ 203 203 204 // TODO: implement 205 class shared_timed_mutex; 204 class shared_timed_mutex 205 { 206 public: 207 shared_timed_mutex() noexcept; 208 ~shared_timed_mutex(); 209 210 shared_timed_mutex(const shared_timed_mutex&) = delete; 211 shared_timed_mutex& operator=(const shared_timed_mutex&) = delete; 212 213 void lock(); 214 bool try_lock(); 215 void unlock(); 216 217 template<class Rep, class Period> 218 bool try_lock_for(const chrono::duration<Rep, Period>& rel_time) 219 { 220 auto time = aux::threading::time::convert(rel_time); 221 222 return aux::threading::shared_mutex::try_lock_for(time); 223 } 224 225 template<class Clock, class Duration> 226 bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time) 227 { 228 auto dur = (abs_time - Clock::now()); 229 auto time = aux::threading::time::convert(dur); 230 231 return aux::threading::shared_mutex::try_lock_for(time); 232 } 233 234 void lock_shared(); 235 bool try_lock_shared(); 236 void unlock_shared(); 237 238 template<class Rep, class Period> 239 bool try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time) 240 { 241 auto time = aux::threading::time::convert(rel_time); 242 243 return aux::threading::shared_mutex::try_lock_shared_for(time); 244 } 245 246 template<class Clock, class Duration> 247 bool try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time) 248 { 249 auto dur = (abs_time - Clock::now()); 250 auto time = aux::threading::time::convert(dur); 251 252 return aux::threading::shared_mutex::try_lock_shared_for(time); 253 } 254 255 using native_handle_type = aux::shared_mutex_t*; 256 native_handle_type native_handle(); 257 258 private: 259 aux::shared_mutex_t mtx_; 260 }; 206 261 207 262 struct defer_lock_t -
uspace/lib/cpp/src/mutex.cpp
rda6bcc0 rd350175 173 173 return &mtx_; 174 174 } 175 176 shared_timed_mutex::shared_timed_mutex() noexcept 177 : mtx_{} 178 { 179 aux::threading::shared_mutex::init(mtx_); 180 } 181 182 shared_timed_mutex::~shared_timed_mutex() 183 { /* DUMMY BODY */ } 184 185 void shared_timed_mutex::lock() 186 { 187 aux::threading::shared_mutex::lock(mtx_); 188 } 189 190 bool shared_timed_mutex::try_lock() 191 { 192 return aux::threading::shared_mutex::try_lock(mtx_); 193 } 194 195 void shared_timed_mutex::unlock() 196 { 197 aux::threading::shared_mutex::unlock(mtx_); 198 } 199 200 void shared_timed_mutex::lock_shared() 201 { 202 aux::threading::shared_mutex::lock_shared(mtx_); 203 } 204 205 bool shared_timed_mutex::try_lock_shared() 206 { 207 return aux::threading::shared_mutex::try_lock_shared(mtx_); 208 } 209 210 void shared_timed_mutex::unlock_shared() 211 { 212 aux::threading::shared_mutex::unlock_shared(mtx_); 213 } 214 215 shared_timed_mutex::native_handle_type shared_timed_mutex::native_handle() 216 { 217 return &mtx_; 218 } 175 219 }
Note:
See TracChangeset
for help on using the changeset viewer.