36#include "blocxx/BLOCXX_config.h"
38#ifdef BLOCXX_GNU_LINUX
47const int BLOCK_FOR_KEY = -1;
53IPCMutex::IPCMutex(
int semKey)
57 m_semid = semget((key_t)semKey, 1, 0666);
60 m_semid = semget((key_t)semKey, 1, IPC_CREAT | 0666);
64 "Unable to create semaphore");
68 if (semctl(m_semid, 0, SETVAL, m_arg) != 0)
80 m_sbuf.sem_op = BLOCK_FOR_KEY;
81 if (semop(m_semid, &m_sbuf, 1) != 0)
84 "Failed to wait on semaphore");
92 m_sbuf.sem_op = ADD_KEY;
93 if (semop(m_semid, &m_sbuf, 1) != 0)
96 "Failed to signal semaphore");
103IPCMutex::free(
int semKey)
105 int semid = semget((key_t)semKey, 1, 0666);
108 semctl(semid, 1, IPC_RMID, 0);
113IPCMutexLock::IPCMutexLock(IPCMutex& sem)
120IPCMutexLock::~IPCMutexLock()
#define BLOCXX_DEFINE_EXCEPTION_WITH_ID(NAME)
Define a new exception class named <NAME>Exception that derives from Exception.
#define BLOCXX_THROW(exType, msg)
Throw an exception using FILE and LINE.
#define BLOCXX_THROW_ERRNO_MSG(exType, msg)
Throw an exception using FILE, LINE, errno and strerror(errno)