idealvin / gitalk

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

Wait Group | Documents for Coost #102

Open idealvin opened 1 year ago

idealvin commented 1 year ago

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

include: co/co.h.

co::wait_group co::wait_group is similar to sync.WaitGroup in golang and can be used to wait for the exit of a coroutine or thread.

constructor 1. explicit wait_group(uint32 n); 2. wait_group(); 3. wait_group(wait_group&& wg); 4. wait_group(const wait_group& wg); 1, initializes the internal counter to n. 2, default constructor, initializes the internal counter to 0. 3, move constructor. 4, copy constructor, only increases the internal reference count by 1. #add void add(uint32 n=1) const; Increment internal counter by n, n defaults to 1.