Belle II Software  release-05-02-19
SemaphoreLocker.h
1 #pragma once
2 
3 #include <sys/types.h>
4 
5 namespace Belle2 {
18  public:
20  explicit SemaphoreLocker(int semId): m_id(semId) { lock(); }
23 
25  static int create(key_t semkey);
27  static void destroy(int semId);
28 
34  static bool isLocked(int semId);
35 
40  void lock();
42  void unlock();
43 
44  private:
45  int m_id;
46  };
48 }
Belle2::SemaphoreLocker::~SemaphoreLocker
~SemaphoreLocker()
Unlock.
Definition: SemaphoreLocker.h:22
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SemaphoreLocker::m_id
int m_id
semaphore id, see semget(2).
Definition: SemaphoreLocker.h:45
Belle2::SemaphoreLocker
Handles creation, locking and unlocking of System V semaphores.
Definition: SemaphoreLocker.h:17
Belle2::SemaphoreLocker::unlock
void unlock()
Unlock the semaphore.
Definition: SemaphoreLocker.cc:70
Belle2::SemaphoreLocker::SemaphoreLocker
SemaphoreLocker(int semId)
Lock the given semaphore.
Definition: SemaphoreLocker.h:20
Belle2::SemaphoreLocker::lock
void lock()
Lock the semaphore.
Definition: SemaphoreLocker.cc:65
Belle2::SemaphoreLocker::isLocked
static bool isLocked(int semId)
Return true if the given semaphore is locked.
Definition: SemaphoreLocker.cc:39
Belle2::SemaphoreLocker::create
static int create(key_t semkey)
Create a new semaphore and initialize it.
Definition: SemaphoreLocker.cc:12
Belle2::SemaphoreLocker::destroy
static void destroy(int semId)
Destroy the given semaphore.
Definition: SemaphoreLocker.cc:32