📄 group.h
字号:
//// spectral toolkit // copyright (c) 2005 university corporation for atmospheric research// licensed under the gnu general public license//#ifndef __group__#define __group__#include <pthread.h>namespace spectral{ class group; int sync(group*); int lock(group*); int unlock(group*); int size(group*); int sync(group&); int lock(group&); int unlock(group&); int size(group&); /// Thread syncronization object. Represents a mutex lock and /// condition variable object that can be shared among a collection /// or group of threads in order to provide syncronization and locking. /// Typically, a reference or pointer to a group object is passed to each /// thread in the group upon instantiation of the thread. The group size /// is an internal counter to keep track of the number of members of the group /// which can be dynamically increased or decreased with the ++ and -- operators. /// \sa sync lock unlock size fiber class group { public: group(); group(int); ~group(); void operator++(int); void operator--(int); private: /// Internal mutex lock used for sync function. pthread_mutex_t mutex; /// Internal mutex lock used for lock/unlock functions. pthread_mutex_t mutex_lock; /// Internal condition variable used for sync function. pthread_cond_t cond; /// Internal counter used for sync. int block; /// Internal counter used for sync. int count; /// Internal counter that keeps track of the group size. int threads; friend int sync(group*); friend int lock(group*); friend int unlock(group*); friend int size(group*); };}#endif// Local Variables:// mode:C++// End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -