Changeset 771d162 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:
- da6bcc0
- Parents:
- 4e484b5
- git-author:
- Dzejrou <dzejrou@…> (2018-03-29 15:25:36)
- 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
r4e484b5 r771d162 30 30 #define LIBCPP_MUTEX 31 31 32 #include <functional> 32 33 #include <internal/common.hpp> 33 34 #include <internal/thread.hpp> … … 49 50 } 50 51 51 ~mutex() ;52 ~mutex() = default; 52 53 53 54 mutex(const mutex&) = delete; … … 712 713 struct once_flag 713 714 { 714 constexpr once_flag() noexcept; 715 constexpr once_flag() noexcept 716 : called_{false}, mtx_{} 717 { /* DUMMY BODY */ } 715 718 716 719 once_flag(const once_flag&) = delete; 717 720 once_flag& operator=(const once_flag&) = delete; 721 722 private: 723 bool called_; 724 mutex mtx_; 725 726 template<class Callable, class... Args> 727 friend void call_once(once_flag&, Callable&&, Args&&...); 718 728 }; 719 729 720 730 template<class Callable, class... Args> 721 void call_once(once_flag& flag, Callable&& func, Args&&... args); 731 void call_once(once_flag& flag, Callable&& func, Args&&... args) 732 { 733 flag.mtx_.lock(); 734 if (!flag.called_) 735 { 736 // TODO: exception handling 737 738 aux::invoke(forward<Callable>(func), forward<Args>(args)...); 739 flag.called_ = true; 740 } 741 flag.mtx_.unlock(); 742 } 722 743 } 723 744 -
uspace/lib/cpp/src/mutex.cpp
r4e484b5 r771d162 31 31 namespace std 32 32 { 33 mutex::~mutex()34 { /* DUMMY BODY */ }35 36 33 void mutex::lock() 37 34 {
Note:
See TracChangeset
for help on using the changeset viewer.