C++编程之美-代码清单1-16

代码清单1-16

class Thread 
{
public:
     // initialize a thread and set the work function 
     Thread(void (*work_func)());	
     // once the object is destructed, the thread will be aborted
     ~Thread();
     // start the thread 
     void Start();
     // stop the thread
     void Abort();
};

class Semaphore 
{
public:
     // initialize semaphore counts 
     Semaphore(int count, int max_count);
     ~Semaphore();
     // consume a signal (count--), block current thread if count == 0
     void Unsignal();
     // raise a signal (count++)
     void Signal();
};

class Mutex 
{
public:
     // block thread until other threads release the mutex 
     WaitMutex();
     // release mutex to let other thread wait for it
     ReleaseMutex();
};
发布了1181 篇原创文章 · 获赞 951 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/weixin_42528266/article/details/104027248