18 #ifndef __esynch_h_included 19 #define __esynch_h_included 24 #include <semaphore.h> 31 #define MAX_NOTIFYIDS 64 87 Void
init(Bool shared);
99 #if defined(NATIVE_IPC) 100 pthread_mutex_t &
mutex()
117 m_initialized =
False;
119 Bool enter(Bool wait =
True);
125 #if defined(NATIVE_IPC) 126 pthread_mutex_t m_mutex;
140 : m_acquire(acquire), m_mtx(mtx)
158 m_acquire = m_mtx.enter(wait);
193 Void *
operator new(size_t, Void *where) {
return where; }
208 ~EMutexDataPublic() {}
210 Int &mutexId() {
return m_mutexId; }
213 EMutexDataPublic() {}
214 Int &nextIndex() {
return m_nextIndex; }
247 Void attach(Int mutexid);
257 operator EMutexDataPublic &();
273 : m_initialized(
False),
283 : m_initialized(
False),
285 m_initCount(initcnt),
304 Bool Decrement(Bool wait =
True);
341 virtual Void
init(Long initcnt) = 0;
358 Bool &
shared() {
return getData().shared(); }
389 : m_data(initcnt,
False)
402 Void
init(Long initcnt) { m_data.initialCount() = initcnt; m_data.init(); }
425 ESemaphoreDataPublic(Long initcnt=0)
429 ~ESemaphoreDataPublic()
433 Int &semIndex() {
return m_semIndex; }
436 Int &nextIndex() {
return m_nextIndex; }
472 Void
init(Long initialCount);
482 Void attach(Int semid);
531 pthread_rwlock_t m_rwlock;
542 : m_rwlock( rwlock ),
560 return m_locked = m_rwlock.enter( ERWLock::Read, wait );
581 : m_rwlock( rwlock ),
599 return m_locked = m_rwlock.enter( ERWLock::Write, wait );
621 EEvent(
bool state =
false );
633 Bool wait(
int ms = -1 );
648 #endif // #define __esynch_h_included Bool & shared()
Retrieves a reference indicating if this is a shared semaphore (public).
Definition: esynch.h:314
Encapsulates and extends a std::string object.
#define True
True.
Definition: ebase.h:25
Request a read lock for the specified read-write lock object.
Definition: esynch.h:535
~ESemaphorePublic()
Class destructor.
Definition: esynch.h:465
Macros for various standard C library functions and standard includes.
ESemaphorePrivate(Long initcnt=0, Bool bInit=True)
Class constructor.
Definition: esynch.h:388
ESemaphorePublic()
Default constructor.
Definition: esynch.h:451
EWRLock(ERWLock &rwlock, Bool acq=true)
Class constructor.
Definition: esynch.h:580
Bool isLocked()
Retrieves the lock status.
Definition: esynch.h:564
Represents a public semaphore, the semaphore data is located in shared memory.
Definition: esynch.h:446
ESemaphoreData()
Default constructor.
Definition: esynch.h:272
Request a write lock for the specified read-write lock object.
Definition: esynch.h:574
Long & mutex()
Retrieves the underlying mutex object.
Definition: esynch.h:107
Bool Increment()
Increments the semaphore value.
Definition: esynch.h:351
Contains the base functionality for a semaphore.
Definition: esynch.h:331
Void destroy()
Destroyes the mutex data.
Allows read or write access.
~ESemaphorePrivate()
Class destructor.
Definition: esynch.h:395
Contains the data associated with a public or private mutex.
Definition: esynch.h:72
An object that can be waited on to be set in another thread.
Definition: esynch.h:616
Contains the data associated with a public or private semaphore.
Definition: esynch.h:268
Bool & shared()
Indicates if this object is to be shared between processes.
Definition: esynch.h:358
EMutexLock(EMutexData &mtx, Bool acquire=True)
Class constructor.
Definition: esynch.h:139
ESemaphorePublic(Long initcnt, Bool bInit=True)
Class constructor.
Definition: esynch.h:458
~EMutexData()
Class destructor.
Definition: esynch.h:80
#define False
False.
Definition: ebase.h:27
EMutexPublic(Bool bInit=True)
Default constructor.
Definition: esynch.h:228
A public mutex (the mutex data is located in shared memory).
Definition: esynch.h:223
DECLARE_ERROR_ADVANCED2(ERWLockError_LockAttrInitFailed)
~EMutexLock()
Class destructor. Unlocks the mutex if locked.
Definition: esynch.h:146
Defines base class for exceptions and declaration helper macros.
EMutexPrivate(Bool bInit=True)
Class constructor.
Definition: esynch.h:180
Bool acquire(Bool wait=true)
Acquires the lock.
Definition: esynch.h:597
~ERDLock()
Class destructor.
Definition: esynch.h:549
Int mutexId()
Retrieves the mutex ID associated with this public mutex.
Definition: esynch.h:253
Bool Decrement(Bool wait=True)
Decrements the semaphore value.
Definition: esynch.h:348
~EMutexPublic()
Class destructor.
Definition: esynch.h:235
Void init(Bool shared)
Initializes the mutex data.
Bool isSet()
Determines if the event has been set.
Definition: esynch.h:636
ESemaphoreBase()
Default constructor.
Definition: esynch.h:335
~ESemaphoreBase()
Class desctructor.
Definition: esynch.h:337
ERDLock(ERWLock &rwlock, Bool acq=true)
Class constructor.
Definition: esynch.h:541
Long & initialCount()
Retrieves the initial count of the semaphore.
Definition: esynch.h:317
Acquires and holds a lock on the specified mutex.
Definition: esynch.h:133
Long currCount()
Retrieves the current semaphore count.
Definition: esynch.h:320
Bool acquire(Bool wait=True)
Manually acquires a lock on the mutex.
Definition: esynch.h:155
~EMutexPrivate()
Class destructor.
Definition: esynch.h:187
#define DECLARE_ERROR(__e__)
Declares exception class derived from EError with no constructor parameters.
Definition: eerror.h:53
Used internally by EpcTools for managing access to public (shared memory) objects.
Definition: esynch2.h:41
Bool initialized()
Retrieves object initialization status.
Definition: esynch.h:93
~EWRLock()
Class destructor.
Definition: esynch.h:588
Bool initialized()
Retrieves the initialization status.
Definition: esynch.h:311
ESemaphoreData(Long initcnt, Bool shared)
Class constructor.
Definition: esynch.h:282
Void destroy()
Destroys the data associated with the semaphore.
Definition: esynch.h:404
Bool initialized()
Indicates the initialization status for this object.
Definition: esynch.h:355
Bool acquire(Bool wait=true)
Acquires the lock.
Definition: esynch.h:558
Represents a private semaphore, the semaphore data is allocated from either the stack or heap...
Definition: esynch.h:382
~ESemaphoreData()
Class destructor.
Definition: esynch.h:290
A private mutex (the mutex data is allocated from either the heap or stack).
Definition: esynch.h:175
Bool isLocked()
Retrieves the lock status.
Definition: esynch.h:603
#define DECLARE_ERROR_ADVANCED(__e__)
Declares exception class derived from EError with no constructor parameters and developer defined con...
Definition: eerror.h:61
Encapsulates a read-write lock object.
Definition: esynch.h:507
friend class EMutexLock
Definition: esynch.h:76
Long & initialCount()
Retrieves the initial semaphore value.
Definition: esynch.h:361
Long currCount()
Retrieves the current semaphore value.
Definition: esynch.h:364
Void init()
Definition: esynch.h:195
Void init(Long initcnt)
Initializes the data associated with the semaphore.
Definition: esynch.h:402