Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
SemaphoreManager Class ReferenceIdeally, this would be SEMMSL, but that is hard to portably determine at compile time. More...
Detailed DescriptionIdeally, this would be SEMMSL, but that is hard to portably determine at compile time. If you can't increase your system's SEMMSL (and possibly SEMMNS), you may want to consider decreasing this. initializes, manages, and releases a set of System V style semaphores Should be initialized pre-fork into a shared region Definition at line 21 of file SemaphoreManager.h.
Member Typedef Documentationshorthand for the semaphore indexing type Definition at line 30 of file SemaphoreManager.h.
shorthand for the type of sems Definition at line 23 of file SemaphoreManager.h. Member Enumeration Documentationspecify options for how to handle EINTR (signal occurred) error condition during a semaphore operation, see setInterruptPolicy()
Definition at line 32 of file SemaphoreManager.h. Constructor & Destructor Documentation
Creates a SemaphoreManager with room for sems_t::MAX_ENTRIES entries. 2 of these entries are reserved for internal use, so user code will actually only have access to sems_t::MAX_ENTRIES-2 entries. Use available() to determine this value at runtime. Definition at line 34 of file SemaphoreManager.cc.
Creates a SemaphoreManager with room for numRequest entries. adds 2 for SemaphoreManager's own reference count and mutex lock, so you'll actually have numRequest semaphores available Definition at line 38 of file SemaphoreManager.cc.
copy supported Definition at line 134 of file SemaphoreManager.cc.
destructor Definition at line 195 of file SemaphoreManager.cc. Member Function Documentation
call this on semaphores in shared memory regions if a fork is about to occur so reference counts can be updated for the other process Definition at line 218 of file SemaphoreManager.cc.
adds x to the semaphore's value, optionally blocking in the case that x is negative and larger than the semaphore's value. After adding, test whether the semaphore is zero, optionally blocking again until it is. If no blocking is required (e.g. x is positive) then the add and test should be an atomic pair. If a thread cancellation occurs, the operation WILL NOT be undone before the call unwinds, as adding to the count can unblock threads which can't be recalled.
Definition at line 441 of file SemaphoreManager.cc.
adds x to the semaphore's value, optionally blocking in the case that x1 is negative and larger than the semaphore's value. After adding, test whether the semaphore is zero, optionally blocking again until it is, and then adding x2 If no blocking is required (e.g. x is positive) then the add and test should be an atomic pair. If a thread cancellation occurs, the operation WILL NOT be undone before the call unwinds, as adding to the count can unblock threads which can't be recalled.
Definition at line 497 of file SemaphoreManager.cc.
returns the number of semaphores currently available in the set Definition at line 111 of file SemaphoreManager.h.
call this if semaphores need to be released during an emergency shutdown (otherwise semaphore sets can leak past process shutdown -- bad system design IMHO!) Definition at line 222 of file SemaphoreManager.cc.
return the semaphore's interrupt policy (doesn't check id validity) Definition at line 70 of file SemaphoreManager.h.
return the number of threads/processes which are blocking for the indicated semaphore to hit zero Definition at line 317 of file SemaphoreManager.cc.
returns a new semaphore id, or invalid() if none are available Definition at line 230 of file SemaphoreManager.cc. Referenced by MessageQueue< MAX_UNREAD, MAX_RECEIVERS, MAX_SENDERS >::addReadStatusListener(), and MessageQueue< MAX_UNREAD, MAX_RECEIVERS, MAX_SENDERS >::addReceiver().
returns the semaphore's value Definition at line 303 of file SemaphoreManager.cc. Referenced by MessageQueueStatusThread::run().
returns true if semid is invalid, indicating further semaphore operations are bogus Definition at line 62 of file SemaphoreManager.h.
basic initialization called by the constructor -- don't call twice Definition at line 42 of file SemaphoreManager.cc. Referenced by SemaphoreManager().
returns the "invalid" id value, for testing against getSemaphore Definition at line 118 of file SemaphoreManager.h. Referenced by MessageQueue< MAX_UNREAD, MAX_RECEIVERS, MAX_SENDERS >::addReadStatusListener(), MessageQueue< MAX_UNREAD, MAX_RECEIVERS, MAX_SENDERS >::addReceiver(), MessageQueueStatusThread::addStatusListener(), MessageQueueStatusThread::cancelled(), MessageReceiver::finish(), MessageReceiver::launched(), MessageReceiver::MessageReceiver(), MessageQueueStatusThread::stop(), and MessageReceiver::~MessageReceiver().
Lowers a semaphore's value by x, optionally blocking if the value would go negative until it is raised enough to succeed. Returns true if the semaphore was successfully lowered. If a thread cancellation occurs, the operation WILL NOT be undone before the call unwinds, as hitting zero can unblock threads which can't be recalled. Definition at line 245 of file SemaphoreManager.cc. Referenced by getSemaphore(), operator=(), releaseSemaphore(), MessageQueueStatusThread::run(), MessageReceiver::runloop(), SemaphoreManager(), testZero_add(), MessageReceiver::waitNextMessage(), and ~SemaphoreManager().
assignment supported Definition at line 145 of file SemaphoreManager.cc.
raises a semaphore's value by x Definition at line 297 of file SemaphoreManager.cc. Referenced by MessageReceiver::markRead(), MessageQueue< MAX_UNREAD, MAX_RECEIVERS, MAX_SENDERS >::markRead(), operator=(), MessageQueue< MAX_UNREAD, MAX_RECEIVERS, MAX_SENDERS >::readMessage(), MessageQueue< MAX_UNREAD, MAX_RECEIVERS, MAX_SENDERS >::removeReceiver(), MessageQueue< MAX_UNREAD, MAX_RECEIVERS, MAX_SENDERS >::sendMessage(), MessageReceiver::stop(), and MessageQueueStatusThread::stop().
marks a semaphore as available for reassignment Definition at line 239 of file SemaphoreManager.cc. Referenced by MessageQueue< MAX_UNREAD, MAX_RECEIVERS, MAX_SENDERS >::addReadStatusListener(), MessageQueue< MAX_UNREAD, MAX_RECEIVERS, MAX_SENDERS >::addReceiver(), MessageQueue< MAX_UNREAD, MAX_RECEIVERS, MAX_SENDERS >::removeReadStatusListener(), and MessageQueue< MAX_UNREAD, MAX_RECEIVERS, MAX_SENDERS >::removeReceiver().
set the semaphore's interrupt policy (doesn't check id validity) Definition at line 72 of file SemaphoreManager.h.
sets the semaphore's value Definition at line 309 of file SemaphoreManager.cc. Referenced by getSemaphore(), and init().
tests if the semaphore's value is zero, optionally blocking until it is returns true if the semaphore's value is zero.
Definition at line 323 of file SemaphoreManager.cc.
tests if the semaphore's value is zero, optionally blocking until it is, and then adding x If x is negative, then addblock will cause it to block again until someone else raises the semaphore. Otherwise, the add should be performed as an atomic unit with the test. If x is non-negative, then the add should never block. If a thread cancellation occurs, the operation WILL be undone before the call unwinds, as this usage is exclusive to other threads.
Definition at line 375 of file SemaphoreManager.cc.
returns the number of semaphores which have been used the SemaphoreManager requires 2 semaphores from the set, one for reference counting and one for mutual exclusion during function calls Definition at line 116 of file SemaphoreManager.h. Member Data Documentation
interrupt policy for each semaphore Definition at line 128 of file SemaphoreManager.h. Referenced by add_testZero(), add_testZero_add(), getInterruptPolicy(), getSemaphore(), lower(), setInterruptPolicy(), testZero(), and testZero_add().
wouldn't want to claim the entire system's worth, even if we could Definition at line 27 of file SemaphoreManager.h.
a lock semaphore for management operations on the set (handing out or taking back semaphores from clients) Definition at line 126 of file SemaphoreManager.h. Referenced by getSemaphore(), init(), operator=(), releaseSemaphore(), SemaphoreManager(), and ~SemaphoreManager().
number of real semaphores in the set obtained from the system Definition at line 124 of file SemaphoreManager.h. Referenced by init(), operator=(), and used().
a reference count of this semaphore set -- when it goes back to 0, the set is released from the system Definition at line 127 of file SemaphoreManager.h. Referenced by aboutToFork(), init(), operator=(), SemaphoreManager(), and ~SemaphoreManager().
the system's identifier for the set Definition at line 125 of file SemaphoreManager.h. Referenced by add_testZero(), add_testZero_add(), faultShutdown(), getNumZeroBlockers(), getValue(), hadFault(), init(), lower(), operator=(), raise(), SemaphoreManager(), setValue(), testZero(), testZero_add(), and ~SemaphoreManager().
tracks which semaphores have been handed out; the bool value isn't actually used Definition at line 123 of file SemaphoreManager.h. Referenced by available(), getSemaphore(), init(), invalid(), operator=(), releaseSemaphore(), SemaphoreManager(), and used(). The documentation for this class was generated from the following files: |
Tekkotsu v5.1CVS |
Generated Mon May 9 04:59:16 2016 by Doxygen 1.6.3 |