diff options
author | Paradox <none@none> | 2009-02-09 08:16:34 -0500 |
---|---|---|
committer | Paradox <none@none> | 2009-02-09 08:16:34 -0500 |
commit | d230302b16474ff22a35243ffed6236ef4fc7fb9 (patch) | |
tree | e3679ad841a47b275756f2721f9aa24a3ee548a6 /dep/include/zthread/Barrier.h | |
parent | b0694d7e5e794b361fa178d55fefdb98cf47e9ca (diff) |
Replace tabs with spaces in more files.
--HG--
branch : trunk
Diffstat (limited to 'dep/include/zthread/Barrier.h')
-rw-r--r-- | dep/include/zthread/Barrier.h | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/dep/include/zthread/Barrier.h b/dep/include/zthread/Barrier.h index 6aaafa93678..ec0d9fc8bb8 100644 --- a/dep/include/zthread/Barrier.h +++ b/dep/include/zthread/Barrier.h @@ -33,25 +33,25 @@ namespace ZThread { /** * @class Barrier * @author Eric Crahen <http://www.code-foo.com> - * @date <2003-07-16T09:54:01-0400> + * @date <2003-07-16T09:54:01-0400> * @version 2.2.1 * - * A Barrier is a Waitable object that serves as synchronization points for + * A Barrier is a Waitable object that serves as synchronization points for * a set of threads. A Barrier is constructed for a fixed number (<i>N</i>) of threads. * Threads attempting to wait() on a Barrier (<i> 1 - N</i>) will block until the <i>N</i>th * thread arrives. The <i>N</i>th thread will awaken all the the others. - * + * * An optional Runnable command may be associated with the Barrier. This will be run() * when the <i>N</i>th thread arrives and Barrier is not broken. * * <b>Error Checking</b> * - * A Barrier uses an all-or-nothing. All threads involved must successfully - * meet at Barrier. If any one of those threads leaves before all the threads - * have (as the result of an error or exception) then all threads present at + * A Barrier uses an all-or-nothing. All threads involved must successfully + * meet at Barrier. If any one of those threads leaves before all the threads + * have (as the result of an error or exception) then all threads present at * the Barrier will throw BrokenBarrier_Exception. * - * A broken Barrier will cause all threads attempting to wait() on it to + * A broken Barrier will cause all threads attempting to wait() on it to * throw a BrokenBarrier_Exception. * * A Barrier will remain 'broken', until it is manually reset(). @@ -77,7 +77,7 @@ namespace ZThread { public: //! Create a Barrier - Barrier() + Barrier() : _broken(false), _haveTask(false), _count(Count), _generation(0), _arrived(_lock), _task(0) { } /** @@ -86,8 +86,8 @@ namespace ZThread { * * @param task Task to associate with this Barrier */ - Barrier(const Task& task) - : _broken(false), _haveTask(true), _count(Count), _generation(0), _arrived(_lock), + Barrier(const Task& task) + : _broken(false), _haveTask(true), _count(Count), _generation(0), _arrived(_lock), _task(task) { } //! Destroy this Barrier @@ -97,7 +97,7 @@ namespace ZThread { * Enter barrier and wait for the other threads to arrive. This can block for an indefinite * amount of time. * - * @exception BrokenBarrier_Exception thrown when any thread has left a wait on this + * @exception BrokenBarrier_Exception thrown when any thread has left a wait on this * Barrier as a result of an error. * @exception Interrupted_Exception thrown when the calling thread is interrupted. * A thread may be interrupted at any time, prematurely ending a wait @@ -111,13 +111,13 @@ namespace ZThread { virtual void wait() { Guard<LockType> g(_lock); - - if(_broken) + + if(_broken) throw BrokenBarrier_Exception(); // Break the barrier if an arriving thread is interrupted if(Thread::interrupted()) { - + // Release the other waiter, propagate the exception _arrived.broadcast(); _broken = true; @@ -125,14 +125,14 @@ namespace ZThread { throw Interrupted_Exception(); } - + if(--_count == 0) { - - // Wake the other threads if this was the last + + // Wake the other threads if this was the last // arriving thread _arrived.broadcast(); - - // Try to run the associated task, if it throws then + + // Try to run the associated task, if it throws then // break the barrier and propagate the exception try { @@ -159,8 +159,8 @@ namespace ZThread { } catch(Interrupted_Exception&) { - // Its possible for a thread to be interrupted before the - // last thread arrives. If the interrupted thread hasn't + // Its possible for a thread to be interrupted before the + // last thread arrives. If the interrupted thread hasn't // resumed, then just propagate the interruption if(myGeneration != _generation) @@ -175,13 +175,13 @@ namespace ZThread { throw; } - + // If the thread woke because it was notified by the thread // that broke the barrier, throw. - if(_broken) + if(_broken) throw BrokenBarrier_Exception(); - - } + + } } @@ -190,14 +190,14 @@ namespace ZThread { * amount of time specified with the timeout parameter. The barrier will not break * if a thread leaves this function due to a timeout. * - * @param timeout maximum amount of time, in milliseconds, to wait before + * @param timeout maximum amount of time, in milliseconds, to wait before * - * @return - * - <em>true</em> if the set of tasks being wait for complete before + * @return + * - <em>true</em> if the set of tasks being wait for complete before * <i>timeout</i> milliseconds elapse. * - <em>false</em> otherwise. * - * @exception BrokenBarrier_Exception thrown when any thread has left a wait on this + * @exception BrokenBarrier_Exception thrown when any thread has left a wait on this * Barrier as a result of an error. * @exception Interrupted_Exception thrown when the calling thread is interrupted. * A thread may be interrupted at any time, prematurely ending a wait @@ -211,13 +211,13 @@ namespace ZThread { virtual bool wait(unsigned long timeout) { Guard<LockType> g(_lock); - - if(_broken) + + if(_broken) throw BrokenBarrier_Exception(); // Break the barrier if an arriving thread is interrupted if(Thread::interrupted()) { - + // Release the other waiter, propagate the exception _arrived.broadcast(); _broken = true; @@ -226,14 +226,14 @@ namespace ZThread { } - + if(--_count == 0) { - - // Wake the other threads if this was the last + + // Wake the other threads if this was the last // arriving thread _arrived.broadcast(); - - // Try to run the associated task, if it throws then + + // Try to run the associated task, if it throws then // break the barrier and propagate the exception try { @@ -261,8 +261,8 @@ namespace ZThread { } catch(Interrupted_Exception&) { - // Its possible for a thread to be interrupted before the - // last thread arrives. If the interrupted thread hasn't + // Its possible for a thread to be interrupted before the + // last thread arrives. If the interrupted thread hasn't // resumed, then just propagate the interruption if(myGeneration != _generation) @@ -277,13 +277,13 @@ namespace ZThread { throw; } - + // If the thread woke because it was notified by the thread // that broke the barrier, throw. - if(_broken) + if(_broken) throw BrokenBarrier_Exception(); - - } + + } return true; @@ -293,12 +293,12 @@ namespace ZThread { * Break the Barrier ending the wait for any threads that were waiting on * the barrier. * - * @post the Barrier is broken, all waiting threads will throw the + * @post the Barrier is broken, all waiting threads will throw the * BrokenBarrier_Exception */ void shatter() { - - Guard<LockType> g(_lock); + + Guard<LockType> g(_lock); _broken = true; _arrived.broadcast(); @@ -306,23 +306,23 @@ namespace ZThread { } /** - * Reset the Barrier. + * Reset the Barrier. * * @post the Barrier is no longer Broken and can be used again. */ void reset() { - - Guard<LockType> g(_lock); + + Guard<LockType> g(_lock); _broken = false; _generation++; _count = Count; - + } }; - + } // namespace ZThread #endif // __ZTBARRIER_H__ |