idealvin / gitalk

comments for Alvin's blog
0 stars 0 forks source link

Mutex Lock | Documents for Coost #101

Open idealvin opened 1 year ago

idealvin commented 1 year ago

https://coostdocs.github.io/en/co/concurrency/coroutine/mutex/

include: co/co.h.

co::mutex Starting from v3.0.1, co::mutex can be used in coroutines and non-coroutines. #constructor 1. mutex(); 2. mutex(mutex&& m); 3. mutex(const mutex& m); 1, default constructor. 2, move constructor. 3, copy constructor, only increases the internal reference count by 1. #lock void lock() const; Acquire the lock, will block until the lock is acquired. #try_lock bool try_lock() const; Acquire the lock, will not block, return true when the lock is successfully acquired, otherwise return false.