Changeset 857d4cc in mainline for uspace/lib/cpp/src/mutex.cpp
- Timestamp:
- 2018-07-05T21:41:20Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a97b838
- Parents:
- befead8
- git-author:
- Dzejrou <dzejrou@…> (2018-03-29 12:04:13)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:20)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/src/mutex.cpp
rbefead8 r857d4cc 69 69 } 70 70 71 bool recursive_mutex::try_lock() 71 bool recursive_mutex::try_lock() noexcept 72 72 { 73 73 if (owner_ != this_thread::get_id()) … … 129 129 return &mtx_; 130 130 } 131 132 recursive_timed_mutex::~recursive_timed_mutex() 133 { /* DUMMY BODY */ } 134 135 void recursive_timed_mutex::lock() 136 { 137 if (owner_ != this_thread::get_id()) 138 { 139 aux::threading::mutex::lock(mtx_); 140 owner_ = this_thread::get_id(); 141 lock_level_ = 1; 142 } 143 else 144 ++lock_level_; 145 } 146 147 bool recursive_timed_mutex::try_lock() 148 { 149 if (owner_ != this_thread::get_id()) 150 { 151 bool res = aux::threading::mutex::try_lock(mtx_); 152 if (res) 153 { 154 owner_ = this_thread::get_id(); 155 lock_level_ = 1; 156 } 157 158 return res; 159 } 160 else 161 ++lock_level_; 162 163 return true; 164 } 165 166 void recursive_timed_mutex::unlock() 167 { 168 if (owner_ != this_thread::get_id()) 169 return; 170 else if (--lock_level_ == 0) 171 aux::threading::mutex::unlock(mtx_); 172 } 173 174 recursive_timed_mutex::native_handle_type recursive_timed_mutex::native_handle() 175 { 176 return &mtx_; 177 } 131 178 }
Note:
See TracChangeset
for help on using the changeset viewer.