⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 countingsemaphore.cpp

📁 Generic template class library for message queue implementation, uses pthread mutex.
💻 CPP
字号:
#include "CountingSemaphore.h"#include <cassert>CountingSemaphore::CountingSemaphore(    unsigned long value){  int sysCallResult;  sysCallResult = sem_init( &posixSemaphore, 0, value );  assert( sysCallResult != -1 );}CountingSemaphore::~CountingSemaphore(){  int sysCallResult;  sysCallResult = sem_destroy( &posixSemaphore );  assert( sysCallResult != -1 );}void CountingSemaphore::post(){  int sysCallResult;  sysCallResult = sem_post( &posixSemaphore );  assert( sysCallResult != -1 );}void CountingSemaphore::wait(){  int sysCallResult;  sysCallResult = sem_wait( &posixSemaphore );  assert( sysCallResult != -1 );}bool CountingSemaphore::trywait(){  int sysCallResult;  bool returnValue;  sysCallResult = sem_wait( &posixSemaphore );  if ( sysCallResult == 0 )    {      returnValue = true;    }  else    {      returnValue = false;    }  return returnValue;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -