diff options
Diffstat (limited to 'dep/src/zthread/Status.h')
-rw-r--r-- | dep/src/zthread/Status.h | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/dep/src/zthread/Status.h b/dep/src/zthread/Status.h index 4735e352861..a56d505a8f4 100644 --- a/dep/src/zthread/Status.h +++ b/dep/src/zthread/Status.h @@ -37,22 +37,22 @@ namespace ZThread { class Status { public: //! Aggregate of pending status changes - volatile unsigned short _pending; - - //! Interest mask + volatile unsigned short _pending; + + //! Interest mask volatile unsigned short _mask; public: - + //! State for the monitor typedef enum { - + // Default INVALID = 0x00, // Valid states SIGNALED = 0x01, - INTERRUPTED = 0x02, + INTERRUPTED = 0x02, TIMEDOUT = 0x04, CANCELED = 0x08, @@ -62,10 +62,10 @@ namespace ZThread { } STATE; Status() : _pending((unsigned short)INVALID), _mask((unsigned short)ANYTHING) { } - + /** * Set the mask for the STATE's that next() will report. - * STATE's not covered by the interest mask can still be + * STATE's not covered by the interest mask can still be * set, they just aren't reported until the mask is changed * to cover that STATE. * @@ -87,19 +87,19 @@ namespace ZThread { * * @param unsigned short * @pre accessed ONLY by the owning thread. - */ + */ bool pending(unsigned short mask) { - + assert(mask != INVALID); return ((_pending & _mask) & mask) != INVALID; } /** - * Check the state without the interest mask. + * Check the state without the interest mask. * - * @param state - * @return true if the flag is set + * @param state + * @return true if the flag is set * @pre access must be serial */ bool examine(STATE state) { @@ -113,12 +113,12 @@ namespace ZThread { * @pre access must be serial */ void push(STATE interest) { - _pending |= interest; + _pending |= interest; } /** * Clear the flags from the current state - * + * * @param interest - the flags to clear from the current state. * @pre access must be serial */ @@ -129,16 +129,16 @@ namespace ZThread { assert(interest != CANCELED); _pending &= ~interest; - + } /** * Get the next state from set that has accumulated. The order STATES are - * reported in is SIGNALED, TIMEOUT, or INTERRUPTED. Setting the - * intrest mask allows certain state to be selectively ignored for + * reported in is SIGNALED, TIMEOUT, or INTERRUPTED. Setting the + * intrest mask allows certain state to be selectively ignored for * a time - but not lost. The states will become visible again as soon - * as the interest mask is changed appropriately. The interest mask is - * generally used to create uninterruptable waits (waiting for threads + * as the interest mask is changed appropriately. The interest mask is + * generally used to create uninterruptable waits (waiting for threads * to start, reacquiring a conditions predicate lock, etc) * * @return STATE @@ -147,29 +147,29 @@ namespace ZThread { STATE next() { STATE state = INVALID; - + if(((_pending & _mask) & SIGNALED) != 0) { - + // Absorb the timeout if it happens when a signal // is available at the same time _pending &= ~(SIGNALED|TIMEDOUT); state = SIGNALED; - + } else if(((_pending & _mask) & TIMEDOUT) != 0) { _pending &= ~TIMEDOUT; state = TIMEDOUT; } else if(((_pending & _mask) & INTERRUPTED) != 0) { - + _pending &= ~INTERRUPTED; state = INTERRUPTED; - - } - + + } + assert(state != INVALID); return state; - + } }; |