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

📄 sem_sync.h

📁 用于使用moden进行传真的源代码
💻 H
字号:
/* Copyright (C) 2004 Chris VineThis program is distributed under the General Public Licence, version 2.For particulars of this and relevant disclaimers see the fileCOPYING distributed with the source files.*/#ifndef SEM_SYNC_H#define SEM_SYNC_H#include "prog_defs.h"#include <semaphore.h>class Sem_sync {  bool valid;  sem_t sem;public:    bool is_valid(void) const {return valid;}  int getvalue(void);  int post(void) {return sem_post(&sem);}  void wait(void) {sem_wait(&sem);}  Sem_sync(unsigned int init_count = 0);  ~Sem_sync(void);};inline int Sem_sync::getvalue(void) {  int count;  sem_getvalue(&sem, &count);  return count;}inline Sem_sync::Sem_sync(unsigned int init_count): valid(false) {  if(sem_init(&sem, 0, init_count) == 0) valid = true;}inline Sem_sync::~Sem_sync(void) {  while (!getvalue()) post();  sem_destroy(&sem);}#endif

⌨️ 快捷键说明

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