Skip to content

Commit

Permalink
Add fiber_mutex_guard class for easily using fiber_mutex.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengshuxin committed Jan 17, 2023
1 parent 70e825f commit 8d719cb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib_fiber/cpp/include/fiber/fiber_mutex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,20 @@ class FIBER_CPP_API fiber_mutex
void operator=(const fiber_mutex&);
};

class FIBER_CPP_API fiber_mutex_guard
{
public:
fiber_mutex_guard(fiber_mutex& mutex) : mutex_(mutex) {
mutex_.lock();
}

~fiber_mutex_guard(void) {
mutex_.unlock();
}

private:
fiber_mutex& mutex_;

};

} // namespace acl

0 comments on commit 8d719cb

Please sign in to comment.