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

📄 sem.h

📁 一套linux下的C++开发库
💻 H
字号:
/***************************************************************************                          sem.h  -  description                             -------------------    begin                : Fri Jul 20 2001    copyright            : (C) 2001 by Mark    email                : alben@yeah.net ***************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * ***************************************************************************/#ifndef SEM_H#define SEM_H#include <sys/types.h>#include <sys/ipc.h>#include <sys/sem.h>#include <tinycxx/exception.h>#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)/* union semun is defined by including <sys/sem.h> */#else/* according to X/OPEN we have to define it ourselves */union semun {  int val;                    /* value for SETVAL */  struct semid_ds *buf;       /* buffer for IPC_STAT, IPC_SET */  unsigned short int *array;  /* array for GETALL, SETALL */  struct seminfo *__buf;      /* buffer for IPC_INFO */};#endifclass CSem{protected:	int m_iSems;	int m_iSemId;	key_t m_tKey;	bool m_bCreate;public: 	CSem(key_t tKey, int iSems = 1, int iMode = 0600);	virtual ~CSem();		void GetSem(int iMode = 0600);	void RemoveSem();	bool Lock();	void Unlock();	bool SemOpWithUndo(int iSems, ...);	bool SemOp(int iSems, ...);	void SetAll(int iSems, ...);	void SetValue(int iSemNum, int iValue);	void GetAll(unsigned short int* pusiArray);	int GetValue(int iSemNum);	bool IfCreate() { return m_bCreate; }	void InitSem();};	#endif

⌨️ 快捷键说明

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