aboutsummaryrefslogtreecommitdiff
path: root/dep/include/zthread
diff options
context:
space:
mode:
Diffstat (limited to 'dep/include/zthread')
-rw-r--r--dep/include/zthread/AtomicCount.h20
-rw-r--r--dep/include/zthread/Barrier.h102
-rw-r--r--dep/include/zthread/BiasedReadWriteLock.h110
-rw-r--r--dep/include/zthread/BlockingQueue.h34
-rw-r--r--dep/include/zthread/BoundedQueue.h124
-rw-r--r--dep/include/zthread/Cancelable.h22
-rw-r--r--dep/include/zthread/ClassLockable.h20
-rw-r--r--dep/include/zthread/ConcurrentExecutor.h46
-rw-r--r--dep/include/zthread/Condition.h60
-rw-r--r--dep/include/zthread/Config.h36
-rw-r--r--dep/include/zthread/CountedPtr.h40
-rw-r--r--dep/include/zthread/CountingSemaphore.h56
-rw-r--r--dep/include/zthread/Exceptions.h58
-rw-r--r--dep/include/zthread/Executor.h26
-rw-r--r--dep/include/zthread/FairReadWriteLock.h24
-rw-r--r--dep/include/zthread/FastMutex.h42
-rw-r--r--dep/include/zthread/FastRecursiveMutex.h28
-rw-r--r--dep/include/zthread/Guard.h96
-rw-r--r--dep/include/zthread/GuardedClass.h18
-rw-r--r--dep/include/zthread/Lockable.h44
-rw-r--r--dep/include/zthread/LockedQueue.h32
-rw-r--r--dep/include/zthread/MonitoredQueue.h86
-rw-r--r--dep/include/zthread/Mutex.h28
-rw-r--r--dep/include/zthread/PoolExecutor.h52
-rw-r--r--dep/include/zthread/PriorityCondition.h12
-rw-r--r--dep/include/zthread/PriorityInheritanceMutex.h34
-rw-r--r--dep/include/zthread/PriorityMutex.h26
-rw-r--r--dep/include/zthread/PrioritySemaphore.h24
-rw-r--r--dep/include/zthread/Queue.h30
-rw-r--r--dep/include/zthread/ReadWriteLock.h16
-rw-r--r--dep/include/zthread/RecursiveMutex.h40
-rw-r--r--dep/include/zthread/Runnable.h4
-rw-r--r--dep/include/zthread/Semaphore.h64
-rw-r--r--dep/include/zthread/Singleton.h68
-rw-r--r--dep/include/zthread/SynchronousExecutor.h20
-rw-r--r--dep/include/zthread/Task.h36
-rw-r--r--dep/include/zthread/Thread.h60
-rw-r--r--dep/include/zthread/ThreadLocal.h114
-rw-r--r--dep/include/zthread/ThreadLocalImpl.h16
-rw-r--r--dep/include/zthread/ThreadedExecutor.h32
-rw-r--r--dep/include/zthread/Waitable.h26
41 files changed, 913 insertions, 913 deletions
diff --git a/dep/include/zthread/AtomicCount.h b/dep/include/zthread/AtomicCount.h
index ea042a7feb2..38e67dc0d0b 100644
--- a/dep/include/zthread/AtomicCount.h
+++ b/dep/include/zthread/AtomicCount.h
@@ -33,7 +33,7 @@ namespace ZThread {
/**
* @class AtomicCount
* @author Eric Crahen <http://www.code-foo.com>
- * @date <2003-07-16T09:41:55-0400>
+ * @date <2003-07-16T09:41:55-0400>
* @version 2.3.0
*
* This class provides an interface to a small integer whose value can be
@@ -42,33 +42,33 @@ namespace ZThread {
* counts.
*/
class ZTHREAD_API AtomicCount : public NonCopyable {
-
+
void* _value;
-
+
public:
-
+
//! Create a new AtomicCount, initialized to a value of 1
AtomicCount();
//! Destroy a new AtomicCount
~AtomicCount();
-
+
//! Postfix decrement and return the current value
size_t operator--(int);
-
+
//! Postfix increment and return the current value
- size_t operator++(int);
+ size_t operator++(int);
//! Prefix decrement and return the current value
size_t operator--();
-
+
//! Prefix increment and return the current value
- size_t operator++();
+ size_t operator++();
}; /* AtomicCount */
-
+
} // namespace ZThread
#endif // __ZTATOMICCOUNT_H__
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__
diff --git a/dep/include/zthread/BiasedReadWriteLock.h b/dep/include/zthread/BiasedReadWriteLock.h
index b1de74292cf..1fcff74e032 100644
--- a/dep/include/zthread/BiasedReadWriteLock.h
+++ b/dep/include/zthread/BiasedReadWriteLock.h
@@ -36,21 +36,21 @@ namespace ZThread {
* @author Eric Crahen <http://www.code-foo.com>
* @date <2003-07-16T10:22:34-0400>
* @version 2.2.7
- *
- * A BiasedReadWriteLock has a bias toward writers. It will prefer read-write access over
+ *
+ * A BiasedReadWriteLock has a bias toward writers. It will prefer read-write access over
* read-only access when many threads are contending for access to either Lockable this
* ReadWriteLock provides.
*
- * @see ReadWriteLock
+ * @see ReadWriteLock
*/
class BiasedReadWriteLock : public ReadWriteLock {
FastMutex _lock;
Condition _condRead;
Condition _condWrite;
-
+
volatile int _activeWriters;
- volatile int _activeReaders;
+ volatile int _activeReaders;
volatile int _waitingReaders;
volatile int _waitingWriters;
@@ -70,7 +70,7 @@ namespace ZThread {
_rwlock.beforeRead();
}
- virtual bool tryAcquire(unsigned long timeout) {
+ virtual bool tryAcquire(unsigned long timeout) {
return _rwlock.beforeReadAttempt(timeout);
}
@@ -96,7 +96,7 @@ namespace ZThread {
_rwlock.beforeWrite();
}
- virtual bool tryAcquire(unsigned long timeout) {
+ virtual bool tryAcquire(unsigned long timeout) {
return _rwlock.beforeWriteAttempt(timeout);
}
@@ -113,18 +113,18 @@ namespace ZThread {
WriteLock _wlock;
public:
-
+
/**
* Create a BiasedReadWriteLock
*
- * @exception Initialization_Exception thrown if resources could not be
+ * @exception Initialization_Exception thrown if resources could not be
* allocated for this object.
*/
BiasedReadWriteLock() : _condRead(_lock), _condWrite(_lock), _rlock(*this), _wlock(*this) {
_activeWriters = 0;
_activeReaders = 0;
-
+
_waitingReaders = 0;
_waitingWriters = 0;
@@ -143,64 +143,64 @@ namespace ZThread {
*/
virtual Lockable& getWriteLock() { return _wlock; }
-
+
protected:
void beforeRead() {
-
- Guard<FastMutex> guard(_lock);
-
- ++_waitingReaders;
-
+
+ Guard<FastMutex> guard(_lock);
+
+ ++_waitingReaders;
+
while(!allowReader()) {
-
+
try {
-
+
// wait
_condRead.wait();
-
+
} catch(...) {
-
- --_waitingReaders;
+
+ --_waitingReaders;
throw;
}
-
+
}
-
+
--_waitingReaders;
++_activeReaders;
-
+
}
bool beforeReadAttempt(unsigned long timeout) {
-
- Guard<FastMutex> guard(_lock);
+
+ Guard<FastMutex> guard(_lock);
bool result = false;
- ++_waitingReaders;
+ ++_waitingReaders;
while(!allowReader()) {
-
+
try {
-
+
result = _condRead.wait(timeout);
-
+
} catch(...) {
-
- --_waitingReaders;
+
+ --_waitingReaders;
throw;
}
}
-
+
--_waitingReaders;
++_activeReaders;
return result;
- }
-
+ }
+
void afterRead() {
@@ -210,7 +210,7 @@ namespace ZThread {
{
Guard<FastMutex> guard(_lock);
-
+
--_activeReaders;
wakeReader = (_waitingReaders > 0);
@@ -220,62 +220,62 @@ namespace ZThread {
if(wakeWriter)
_condWrite.signal();
-
+
else if(wakeReader)
_condRead.signal();
}
void beforeWrite() {
-
+
Guard<FastMutex> guard(_lock);
-
+
++_waitingWriters;
while(!allowWriter()) {
-
+
try {
_condWrite.wait();
-
+
} catch(...) {
--_waitingWriters;
throw;
}
-
+
}
-
+
--_waitingWriters;
- ++_activeWriters;
+ ++_activeWriters;
}
bool beforeWriteAttempt(unsigned long timeout) {
-
+
Guard<FastMutex> guard(_lock);
bool result = false;
++_waitingWriters;
while(!allowWriter()) {
-
+
try {
result = _condWrite.wait(timeout);
-
+
} catch(...) {
--_waitingWriters;
throw;
}
-
+
}
-
+
--_waitingWriters;
++_activeWriters;
-
+
return result;
}
@@ -288,9 +288,9 @@ namespace ZThread {
{
Guard<FastMutex> guard(_lock);
-
+
--_activeWriters;
-
+
wakeReader = (_waitingReaders > 0);
wakeWriter = (_waitingWriters > 0);
@@ -298,14 +298,14 @@ namespace ZThread {
if(wakeWriter)
_condWrite.signal();
-
+
else if(wakeReader)
_condRead.signal();
-
+
}
bool allowReader() {
- return (_activeWriters == 0);
+ return (_activeWriters == 0);
}
bool allowWriter() {
diff --git a/dep/include/zthread/BlockingQueue.h b/dep/include/zthread/BlockingQueue.h
index ac17347d1cc..da0b701a825 100644
--- a/dep/include/zthread/BlockingQueue.h
+++ b/dep/include/zthread/BlockingQueue.h
@@ -30,14 +30,14 @@
#include <deque>
namespace ZThread {
-
+
/**
* @class BlockingQueue
* @author Eric Crahen <http://www.code-foo.com>
* @date <2003-07-16T12:01:43-0400>
* @version 2.3.0
*
- * Like a LockedQueue, a BlockingQueue is a Queue implementation that provides
+ * Like a LockedQueue, a BlockingQueue is a Queue implementation that provides
* serialized access to the items added to it. It differs by causing threads
* accessing the next() methods to block until a value becomes available.
*/
@@ -70,12 +70,12 @@ namespace ZThread {
virtual void add(const T& item) {
Guard<LockType> g(_lock);
-
+
if(_canceled)
throw Cancellation_Exception();
-
+
_queue.push_back(item);
-
+
_notEmpty.signal();
}
@@ -88,17 +88,17 @@ namespace ZThread {
try {
Guard<LockType> g(_lock, timeout);
-
+
if(_canceled)
throw Cancellation_Exception();
-
+
_queue.push_back(item);
_notEmpty.signal();
} catch(Timeout_Exception&) { return false; }
-
- return true;
+
+ return true;
}
@@ -106,7 +106,7 @@ namespace ZThread {
* Get a value from this Queue. The calling thread may block indefinitely.
*
* @return <em>T</em> next available value
- *
+ *
* @exception Cancellation_Exception thrown if this Queue has been canceled.
*
* @exception Interrupted_Exception thrown if the calling thread is interrupted
@@ -126,10 +126,10 @@ namespace ZThread {
if( _queue.empty() )
throw Cancellation_Exception();
-
+
T item = _queue.front();
_queue.pop_front();
-
+
return item;
}
@@ -142,7 +142,7 @@ namespace ZThread {
* the calling thread.
*
* @return <em>T</em> next available value
- *
+ *
* @exception Cancellation_Exception thrown if this Queue has been canceled.
* @exception Timeout_Exception thrown if the timeout expires before a value
* can be retrieved.
@@ -165,10 +165,10 @@ namespace ZThread {
if(_queue.empty() )
throw Cancellation_Exception();
-
+
T item = _queue.front();
_queue.pop_front();
-
+
return item;
}
@@ -177,7 +177,7 @@ namespace ZThread {
/**
* @see Queue::cancel()
*
- * @post If threads are blocked on one of the next() functions then
+ * @post If threads are blocked on one of the next() functions then
* they will be awakened with a Cancellation_Exception.
*/
virtual void cancel() {
@@ -197,7 +197,7 @@ namespace ZThread {
// Faster check since the queue will not become un-canceled
if(_canceled)
return true;
-
+
Guard<LockType> g(_lock);
return _canceled;
diff --git a/dep/include/zthread/BoundedQueue.h b/dep/include/zthread/BoundedQueue.h
index 2b3a616f1fb..528e6d869d0 100644
--- a/dep/include/zthread/BoundedQueue.h
+++ b/dep/include/zthread/BoundedQueue.h
@@ -41,10 +41,10 @@ namespace ZThread {
* A BoundedQueue provides serialized access to a set of values. It differs from other
* Queues by adding a maximum capacity, giving it the following properties:
*
- * - Threads calling the empty() methods will be blocked until the BoundedQueue becomes empty.
+ * - Threads calling the empty() methods will be blocked until the BoundedQueue becomes empty.
* - Threads calling the next() methods will be blocked until the BoundedQueue has a value to
- * return.
- * - Threads calling the add() methods will be blocked until the number of values in the
+ * return.
+ * - Threads calling the add() methods will be blocked until the number of values in the
* Queue drops below the maximum capacity.
*
* @see Queue
@@ -76,36 +76,36 @@ namespace ZThread {
public:
/**
- * Create a BoundedQueue with the given capacity.
- *
+ * Create a BoundedQueue with the given capacity.
+ *
* @param capacity maximum number of values to allow in the Queue at
* at any time
*/
BoundedQueue(size_t capacity)
- : _notFull(_lock), _notEmpty(_lock), _isEmpty(_lock),
+ : _notFull(_lock), _notEmpty(_lock), _isEmpty(_lock),
_capacity(capacity), _canceled(false) {}
-
+
//! Destroy this Queue
virtual ~BoundedQueue() { }
-
+
/**
- * Get the maximum capacity of this Queue.
+ * Get the maximum capacity of this Queue.
*
* @return <i>size_t</i> maximum capacity
*/
- size_t capacity() {
- return _capacity;
+ size_t capacity() {
+ return _capacity;
}
/**
- * Add a value to this Queue.
+ * Add a value to this Queue.
*
- * If the number of values in the queue matches the value returned by <i>capacity</i>()
- * then the calling thread will be blocked until at least one value is removed from
+ * If the number of values in the queue matches the value returned by <i>capacity</i>()
+ * then the calling thread will be blocked until at least one value is removed from
* the Queue.
*
* @param item value to be added to the Queue
- *
+ *
* @exception Cancellation_Exception thrown if this Queue has been canceled.
* @exception Interrupted_Exception thrown if the thread was interrupted while waiting
* to add a value
@@ -116,35 +116,35 @@ namespace ZThread {
* @see Queue::add(const T& item)
*/
virtual void add(const T& item) {
-
+
Guard<LockType> g(_lock);
-
- // Wait for the capacity of the Queue to drop
+
+ // Wait for the capacity of the Queue to drop
while ((_queue.size() == _capacity) && !_canceled)
_notFull.wait();
-
+
if(_canceled)
throw Cancellation_Exception();
_queue.push_back(item);
_notEmpty.signal(); // Wake any waiters
-
-
+
+
}
-
+
/**
- * Add a value to this Queue.
+ * Add a value to this Queue.
*
- * If the number of values in the queue matches the value returned by <i>capacity</i>()
- * then the calling thread will be blocked until at least one value is removed from
+ * If the number of values in the queue matches the value returned by <i>capacity</i>()
+ * then the calling thread will be blocked until at least one value is removed from
* the Queue.
*
* @param item value to be added to the Queue
* @param timeout maximum amount of time (milliseconds) this method may block
* the calling thread.
*
- * @return
- * - <em>true</em> if a copy of <i>item</i> can be added before <i>timeout</i>
+ * @return
+ * - <em>true</em> if a copy of <i>item</i> can be added before <i>timeout</i>
* milliseconds elapse.
* - <em>false</em> otherwise.
*
@@ -158,24 +158,24 @@ namespace ZThread {
* @see Queue::add(const T& item, unsigned long timeout)
*/
virtual bool add(const T& item, unsigned long timeout) {
-
+
try {
Guard<LockType> g(_lock, timeout);
-
- // Wait for the capacity of the Queue to drop
+
+ // Wait for the capacity of the Queue to drop
while ((_queue.size() == _capacity) && !_canceled)
if(!_notFull.wait(timeout))
return false;
-
+
if(_canceled)
throw Cancellation_Exception();
-
+
_queue.push_back(item);
_notEmpty.signal(); // Wake any waiters
-
+
} catch(Timeout_Exception&) { return false; }
-
+
return true;
}
@@ -183,11 +183,11 @@ namespace ZThread {
/**
* Retrieve and remove a value from this Queue.
*
- * If invoked when there are no values present to return then the calling thread
+ * If invoked when there are no values present to return then the calling thread
* will be blocked until a value arrives in the Queue.
*
* @return <em>T</em> next available value
- *
+ *
* @exception Cancellation_Exception thrown if this Queue has been canceled.
* @exception Interrupted_Exception thrown if the thread was interrupted while waiting
* to retrieve a value
@@ -196,18 +196,18 @@ namespace ZThread {
* @post The value returned will have been removed from the Queue.
*/
virtual T next() {
-
+
Guard<LockType> g(_lock);
-
+
while ( _queue.empty() && !_canceled)
_notEmpty.wait();
-
+
if( _queue.empty()) // Queue canceled
- throw Cancellation_Exception();
+ throw Cancellation_Exception();
T item = _queue.front();
_queue.pop_front();
-
+
_notFull.signal(); // Wake any thread trying to add
if(_queue.empty()) // Wake empty waiters
@@ -220,14 +220,14 @@ namespace ZThread {
/**
* Retrieve and remove a value from this Queue.
*
- * If invoked when there are no values present to return then the calling thread
+ * If invoked when there are no values present to return then the calling thread
* will be blocked until a value arrives in the Queue.
*
* @param timeout maximum amount of time (milliseconds) this method may block
* the calling thread.
*
* @return <em>T</em> next available value
- *
+ *
* @exception Cancellation_Exception thrown if this Queue has been canceled.
* @exception Timeout_Exception thrown if the timeout expires before a value
* can be retrieved.
@@ -236,9 +236,9 @@ namespace ZThread {
* @post The value returned will have been removed from the Queue.
*/
virtual T next(unsigned long timeout) {
-
+
Guard<LockType> g(_lock, timeout);
-
+
// Wait for items to be added
while (_queue.empty() && !_canceled) {
if(!_notEmpty.wait(timeout))
@@ -246,7 +246,7 @@ namespace ZThread {
}
if(_queue.empty()) // Queue canceled
- throw Cancellation_Exception();
+ throw Cancellation_Exception();
T item = _queue.front();
_queue.pop_front();
@@ -255,21 +255,21 @@ namespace ZThread {
if(_queue.empty()) // Wake empty() waiters
_isEmpty.broadcast();
-
+
return item;
-
+
}
/**
- * Cancel this queue.
- *
+ * Cancel this queue.
+ *
* @post Any threads blocked by an add() function will throw a Cancellation_Exception.
* @post Any threads blocked by a next() function will throw a Cancellation_Exception.
- *
+ *
* @see Queue::cancel()
*/
virtual void cancel() {
-
+
Guard<LockType> g(_lock);
_canceled = true;
@@ -285,7 +285,7 @@ namespace ZThread {
// Faster check since the Queue will not become un-canceled
if(_canceled)
return true;
-
+
Guard<LockType> g(_lock);
return _canceled;
@@ -296,7 +296,7 @@ namespace ZThread {
* @see Queue::size()
*/
virtual size_t size() {
-
+
Guard<LockType> g(_lock);
return _queue.size();
@@ -315,10 +315,10 @@ namespace ZThread {
/**
* Test whether any values are available in this Queue.
*
- * The calling thread is blocked until there are no values present
+ * The calling thread is blocked until there are no values present
* in the Queue.
- *
- * @return
+ *
+ * @return
* - <em>true</em> if there are no values available.
* - <em>false</em> if there <i>are</i> values available.
*
@@ -330,7 +330,7 @@ namespace ZThread {
while(!_queue.empty()) // Wait for an empty signal
_isEmpty.wait();
-
+
return true;
@@ -340,13 +340,13 @@ namespace ZThread {
/**
* Test whether any values are available in this Queue.
*
- * The calling thread is blocked until there are no values present
+ * The calling thread is blocked until there are no values present
* in the Queue.
- *
+ *
* @param timeout maximum amount of time (milliseconds) this method may block
* the calling thread.
*
- * @return
+ * @return
* - <em>true</em> if there are no values available.
* - <em>false</em> if there <i>are</i> values available.
*
@@ -361,7 +361,7 @@ namespace ZThread {
while(!_queue.empty()) // Wait for an empty signal
_isEmpty.wait(timeout);
-
+
return true;
}
diff --git a/dep/include/zthread/Cancelable.h b/dep/include/zthread/Cancelable.h
index 9151ec8dd03..8d1cae526c3 100644
--- a/dep/include/zthread/Cancelable.h
+++ b/dep/include/zthread/Cancelable.h
@@ -36,20 +36,20 @@ namespace ZThread {
*
* The Cancelable interface defines a common method of adding general <i>disable-and-exit</i>
* semantics to some object. By cancel()ing a Cancelable object, a request is
- * made to disable that object.
+ * made to disable that object.
*
* <b>Disabling</b>
*
* A cancel()ed object may not necessarily abort it work immediately. Often, it much more
- * elegant for a cancel()ed object to complete handling whatever responsibilities have
- * been assigned to it, but it will <i>not</i> take on any new responsibility.
+ * elegant for a cancel()ed object to complete handling whatever responsibilities have
+ * been assigned to it, but it will <i>not</i> take on any new responsibility.
*
* <b>Exiting</b>
*
* A cancel()ed should complete its responsibilities as soon as possible.
* Canceling is not only a request to stop taking on new responsibility, and to
- * complete its current responsibility. Its also a request to complete dealing with its
- * current responsibilities, quickly when possible.
+ * complete its current responsibility. Its also a request to complete dealing with its
+ * current responsibilities, quickly when possible.
*/
class Cancelable {
public:
@@ -58,21 +58,21 @@ namespace ZThread {
virtual ~Cancelable() {}
/**
- * Canceling a Cancelable object makes a request to disable that object.
- * This entails refusing to take on any new responsibility, and completing
+ * Canceling a Cancelable object makes a request to disable that object.
+ * This entails refusing to take on any new responsibility, and completing
* its current responsibilities quickly.
*
* Canceling an object more than once has no effect.
- *
- * @post The Cancelable object will have permanently transitioned to a
- * disabled state; it will now refuse to accept new responsibility.
+ *
+ * @post The Cancelable object will have permanently transitioned to a
+ * disabled state; it will now refuse to accept new responsibility.
*/
virtual void cancel() = 0;
/**
* Determine if a Cancelable object has been canceled.
*
- * @return
+ * @return
* - <em>true</em> if cancel() was called prior to this function.
* - <em>false</em> otherwise.
*/
diff --git a/dep/include/zthread/ClassLockable.h b/dep/include/zthread/ClassLockable.h
index a10fb4932a2..7c1eb0b5059 100644
--- a/dep/include/zthread/ClassLockable.h
+++ b/dep/include/zthread/ClassLockable.h
@@ -26,7 +26,7 @@
#include "zthread/CountedPtr.h"
#include "zthread/Mutex.h"
-namespace ZThread {
+namespace ZThread {
/**
* @class ClassLockable
@@ -43,25 +43,25 @@ namespace ZThread {
static CountedPtr<LockType> _instance;
CountedPtr<LockType> _lock;
- public:
-
+ public:
+
//! Create a ClassLockable
- ClassLockable()
- : _lock(_instance) {}
-
+ ClassLockable()
+ : _lock(_instance) {}
+
//! acquire() the ClassLockable
- virtual void acquire() {
- _lock->acquire();
+ virtual void acquire() {
+ _lock->acquire();
}
//! tryAcquire() the ClassLockable
virtual bool tryAcquire(unsigned long timeout) {
- return _lock->tryAcquire(timeout);
+ return _lock->tryAcquire(timeout);
}
//! release() the ClassLockable
virtual void release() {
- _lock->release();
+ _lock->release();
}
};
diff --git a/dep/include/zthread/ConcurrentExecutor.h b/dep/include/zthread/ConcurrentExecutor.h
index 199fe306e08..ccfd4a7ab67 100644
--- a/dep/include/zthread/ConcurrentExecutor.h
+++ b/dep/include/zthread/ConcurrentExecutor.h
@@ -35,7 +35,7 @@ namespace ZThread {
* @version 2.3.0
*
* A ConcurrentExecutor spawns a single thread to service a series of Tasks.
- *
+ *
* @see PoolExecutor.
*/
class ConcurrentExecutor : public Executor {
@@ -43,20 +43,20 @@ namespace ZThread {
PoolExecutor _executor;
public:
-
+
//! Create a ConcurrentExecutor
- ConcurrentExecutor();
+ ConcurrentExecutor();
/**
* Interrupting a ConcurrentExecutor will cause the thread running the tasks to be
- * be interrupted once during the execution of each task that has been submitted
+ * be interrupted once during the execution of each task that has been submitted
* at the time this function is called.
- *
- * Tasks that are submitted after this function is called will
+ *
+ * Tasks that are submitted after this function is called will
* not be interrupt()ed; unless this function is invoked again().
*
* @code
- *
+ *
* void aFunction() {
*
* ConcurrentExecutor executor;
@@ -65,60 +65,60 @@ namespace ZThread {
* for(size_t n = 0; n < p; n++)
* executor.execute(new aRunnable);
*
- * // Tasks [m, p) may be interrupted, where m is the first task that has
- * // not completed at the time the interrupt() is invoked.
+ * // Tasks [m, p) may be interrupted, where m is the first task that has
+ * // not completed at the time the interrupt() is invoked.
* executor.interrupt();
*
* // Submit (q - p) Tasks
* for(size_t n = p; n < q; n++)
* executor.execute(new Chore);
- *
- * // Tasks [p, q) are not interrupted
+ *
+ * // Tasks [p, q) are not interrupted
*
* }
*
* @endcode
*/
virtual void interrupt();
-
+
/**
- * Submit a Task to this Executor. This will not block the current thread
- * for very long. The task will be enqueued internally and eventually run
- * in the context of the single thread driving all the Tasks submitted to this
+ * Submit a Task to this Executor. This will not block the current thread
+ * for very long. The task will be enqueued internally and eventually run
+ * in the context of the single thread driving all the Tasks submitted to this
* Executor.
- *
+ *
* @exception Cancellation_Exception thrown if this Executor has been canceled.
* The Task being submitted will not be executed by this Executor.
*
- * @exception Synchronization_Exception thrown only in the event of an error
+ * @exception Synchronization_Exception thrown only in the event of an error
* in the implementation of the library.
*
* @see Executor::execute(const Task&)
*/
virtual void execute(const Task&);
-
+
/**
* @see Cancelable::cancel()
*/
virtual void cancel();
-
+
/**
* @see Cancelable::isCanceled()
*/
virtual bool isCanceled();
-
+
/**
* @see PoolExecutor::wait()
*/
virtual void wait();
-
+
/**
* @see PoolExecutor::wait(unsigned long timeout)
*/
virtual bool wait(unsigned long timeout);
-
+
}; /* ConcurrentExecutor */
-
+
} // namespace ZThread
#endif // __ZTCONCURRENTEXECUTOR_H__
diff --git a/dep/include/zthread/Condition.h b/dep/include/zthread/Condition.h
index eba93619bfe..60f4b544ea9 100644
--- a/dep/include/zthread/Condition.h
+++ b/dep/include/zthread/Condition.h
@@ -28,7 +28,7 @@
#include "zthread/Waitable.h"
namespace ZThread {
-
+
class FifoConditionImpl;
/**
@@ -37,13 +37,13 @@ namespace ZThread {
* @date <2003-07-16T14:38:59-0400>
* @version 2.2.1
*
- * A Condition is a Waitable object used to block a thread until a particular
- * condition is met. A Condition object is always used in conjunction with Lockable
+ * A Condition is a Waitable object used to block a thread until a particular
+ * condition is met. A Condition object is always used in conjunction with Lockable
* object. This object should be a FastMutex, Mutex, PriorityMutex or PriorityInheritanceMutex.
*
- * Condition objects are reminiscent of POSIX condition variables in several ways but
- * are slightly different.
- *
+ * Condition objects are reminiscent of POSIX condition variables in several ways but
+ * are slightly different.
+ *
* A Condition is <i>not</i> subject to spurious wakeup.
*
* Like all Waitable objects, Conditions are sensitive to Thread::interupt() which can
@@ -52,10 +52,10 @@ namespace ZThread {
* @see Thread::interupt()
*
* Before a wait() is performed on a Condition, the associated Lockable object should
- * have been acquire()ed. When the wait() begins, that Lockable object is release()d
- * (wait() will atomically begin the wait and unlock the Lockable).
+ * have been acquire()ed. When the wait() begins, that Lockable object is release()d
+ * (wait() will atomically begin the wait and unlock the Lockable).
*
- * A thread blocked by wait() will remain so until an exception occurs, or until
+ * A thread blocked by wait() will remain so until an exception occurs, or until
* the thread awakened by a signal() or broadcast(). When the thread resumes execution,
* the associated Lockable is acquire()d before wait() returns.
*
@@ -66,33 +66,33 @@ namespace ZThread {
class ZTHREAD_API Condition : public Waitable, private NonCopyable {
FifoConditionImpl* _impl;
-
+
public:
-
+
/**
* Create a Condition associated with the given Lockable object.
*
* @param l Lockable object to associate with this Condition object.
*/
- Condition(Lockable& l);
+ Condition(Lockable& l);
//! Destroy Condition object
virtual ~Condition();
-
+
/**
* Wake <em>one</em> thread waiting on this Condition.
*
- * The associated Lockable need not have been acquire when this function is
+ * The associated Lockable need not have been acquire when this function is
* invoked.
*
* @post a waiting thread, if any exists, will be awakened.
*/
- void signal();
+ void signal();
/**
* Wake <em>all</em> threads wait()ing on this Condition.
*
- * The associated Lockable need not have been acquire when this function is
+ * The associated Lockable need not have been acquire when this function is
* invoked.
*
* @post all wait()ing threads, if any exist, will be awakened.
@@ -108,16 +108,16 @@ namespace ZThread {
* @exception Interrupted_Exception thrown when the calling thread is interrupted.
* A thread may be interrupted at any time, prematurely ending any wait.
*
- * @pre The thread calling this method must have first acquired the associated
- * Lockable object.
+ * @pre The thread calling this method must have first acquired the associated
+ * Lockable object.
*
- * @post A thread that has resumed execution without exception (because of a signal(),
- * broadcast() or exception) will have acquire()d the associated Lockable object
+ * @post A thread that has resumed execution without exception (because of a signal(),
+ * broadcast() or exception) will have acquire()d the associated Lockable object
* before returning from a wait().
*
* @see Waitable::wait()
*/
- virtual void wait();
+ virtual void wait();
/**
* Wait for this Condition, blocking the calling thread until a signal or broadcast
@@ -127,28 +127,28 @@ namespace ZThread {
*
* @param timeout maximum amount of time (milliseconds) this method could block
*
- * @return
- * - <em>true</em> if the Condition receives a signal or broadcast before
+ * @return
+ * - <em>true</em> if the Condition receives a signal or broadcast before
* <i>timeout</i> milliseconds elapse.
* - <em>false</em> otherwise.
- *
+ *
* @exception Interrupted_Exception thrown when the calling thread is interrupted.
* A thread may be interrupted at any time, prematurely ending any wait.
*
- * @pre The thread calling this method must have first acquired the associated
- * Lockable object.
+ * @pre The thread calling this method must have first acquired the associated
+ * Lockable object.
*
- * @post A thread that has resumed execution without exception (because of a signal(),
- * broadcast() or exception) will have acquire()d the associated Lockable object
+ * @post A thread that has resumed execution without exception (because of a signal(),
+ * broadcast() or exception) will have acquire()d the associated Lockable object
* before returning from a wait().
*
* @see Waitable::wait(unsigned long timeout)
*/
virtual bool wait(unsigned long timeout);
-
+
};
-
+
} // namespace ZThread
#endif // __ZTCONDITION_H__
diff --git a/dep/include/zthread/Config.h b/dep/include/zthread/Config.h
index 21e08bf8461..ee03c831dc4 100644
--- a/dep/include/zthread/Config.h
+++ b/dep/include/zthread/Config.h
@@ -25,7 +25,7 @@
// =====================================================================================
// The following section describes the symbols the configure program will define.
-// If you are not using configure (autoconf), then you make want to set these by
+// If you are not using configure (autoconf), then you make want to set these by
// uncommenting them here, or whatever other means you'd like.
// =====================================================================================
@@ -75,7 +75,7 @@
// Uncomment to select the vannila dual mutex implementation of FastRecursiveLock
// #define ZTHREAD_DUAL_LOCKS 1
-// Uncomment to select a POSIX implementation of FastRecursiveLock that does not
+// Uncomment to select a POSIX implementation of FastRecursiveLock that does not
// spin, but instead sleeps on a condition variable.
// #define ZTHREAD_CONDITION_LOCKS 1
@@ -92,7 +92,7 @@
// The following section will attempt to guess the best configuration for your system
// ===================================================================================
-// Select an implementation by checking out the environment, first looking for
+// Select an implementation by checking out the environment, first looking for
// compilers, then by looking for other definitions that could be present
#if !defined(ZT_POSIX) && !defined(ZT_WIN9X) && !defined(ZT_WIN32) && !defined(ZT_MACOS)
@@ -116,7 +116,7 @@
# define ZT_POSIX
// Check for definitions from well known headers
-#elif defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE)
+#elif defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE)
# define ZT_POSIX
@@ -148,8 +148,8 @@
#endif
-// Windows users will get a static build by default, unless they
-// define either ZTHREAD_IMPORTS or ZTHREAD_EXPORTS. Client code
+// Windows users will get a static build by default, unless they
+// define either ZTHREAD_IMPORTS or ZTHREAD_EXPORTS. Client code
// of a dll version of this library should define the first flag;
// To build the dll version of this library, define the second.
@@ -157,29 +157,29 @@
# error "Import and export declarations are not valid"
#else
-# if defined(ZTHREAD_IMPORTS)
+# if defined(ZTHREAD_IMPORTS)
# define ZTHREAD_API __declspec(dllimport)
-# elif defined(ZTHREAD_EXPORTS)
+# elif defined(ZTHREAD_EXPORTS)
# define ZTHREAD_API __declspec(dllexport)
# else
-# define ZTHREAD_API
+# define ZTHREAD_API
# endif
#endif
-// Once the API decorator is configured, create a macro for
-// explicit template instantiation (whose need can hopefully
+// Once the API decorator is configured, create a macro for
+// explicit template instantiation (whose need can hopefully
// be removed from the library)
#if defined(ZTHREAD_EXPORTS)
-# define EXPLICIT_TEMPLATE(X) template class __declspec( dllexport ) X;
+# define EXPLICIT_TEMPLATE(X) template class __declspec( dllexport ) X;
#elif defined(ZTHREAD_IMPORTS)
-# define EXPLICIT_TEMPLATE(X) template class __declspec( dllimport ) X;
+# define EXPLICIT_TEMPLATE(X) template class __declspec( dllimport ) X;
#else
# define EXPLICIT_TEMPLATE(X)
#endif
-// Give libc a hint, should be defined by the user - but people tend
+// Give libc a hint, should be defined by the user - but people tend
// to forget.
#if !defined(REENTRANT)
@@ -192,7 +192,7 @@
#if defined(_MSC_VER)
# pragma warning(disable:4275)
-# pragma warning(disable:4290)
+# pragma warning(disable:4290)
# pragma warning(disable:4786)
# pragma warning(disable:4251)
# pragma warning(disable:4355)
@@ -202,16 +202,16 @@
#if \
(defined(ZT_POSIX) && defined(ZT_WIN32)) \
|| (defined(ZT_POSIX) && defined(ZT_WIN9X)) \
- || (defined(ZT_WIN32) && defined(ZT_WIN9X))
+ || (defined(ZT_WIN32) && defined(ZT_WIN9X))
# error "Only one implementation should be selected!"
#endif
#if defined(ZTHREAD_NOINLINE)
-# define ZTHREAD_INLINE
+# define ZTHREAD_INLINE
#else
-# define ZTHREAD_INLINE inline
+# define ZTHREAD_INLINE inline
#endif
#endif // __ZTCONFIG_H__
diff --git a/dep/include/zthread/CountedPtr.h b/dep/include/zthread/CountedPtr.h
index a4dcc6ef248..095b61c7ab5 100644
--- a/dep/include/zthread/CountedPtr.h
+++ b/dep/include/zthread/CountedPtr.h
@@ -36,7 +36,7 @@
#endif
namespace ZThread {
-
+
/**
* @class CountedPtr
*
@@ -100,41 +100,41 @@ namespace ZThread {
~CountedPtr() {
if(_count && --(*_count) == 0) {
-
- if(_instance)
+
+ if(_instance)
delete _instance;
delete _count;
-
+
}
}
-
+
#if !defined(__MWERKS__)
#if !defined(_MSC_VER) || (_MSC_VER > 1200)
const CountedPtr& operator=(const CountedPtr& ptr) {
-
+
typedef CountedPtr<T, CountT> ThisT;
ThisT(ptr).swap(*this);
return *this;
- }
+ }
#endif
#endif
template <typename U, typename V>
const CountedPtr& operator=(const CountedPtr<U, V>& ptr) {
-
+
typedef CountedPtr<T, CountT> ThisT;
ThisT(ptr).swap(*this);
return *this;
- }
+ }
void reset() {
@@ -155,7 +155,7 @@ namespace ZThread {
#endif
#endif
-
+
template <typename U, typename V>
void swap(CountedPtr<U, V>& ptr) {
@@ -221,7 +221,7 @@ namespace ZThread {
assert(_instance != 0);
return _instance;
}
-
+
bool operator!() const {
return _instance == 0;
}
@@ -229,25 +229,25 @@ namespace ZThread {
operator bool() const {
return _instance != 0;
}
-
+
}; /* CountedPtr */
- template<typename U, typename V, typename X, typename Y>
+ template<typename U, typename V, typename X, typename Y>
inline bool operator<(CountedPtr<U, V> const &lhs, CountedPtr<X, Y> const &rhs) {
return lhs.less(rhs);
}
- template<typename U, typename V, typename X, typename Y>
+ template<typename U, typename V, typename X, typename Y>
inline bool operator==(CountedPtr<U, V> const &lhs, CountedPtr<X, Y> const &rhs) {
return lhs.equal(rhs.get);
}
- template<typename U, typename V, typename X, typename Y>
+ template<typename U, typename V, typename X, typename Y>
inline bool operator!=(CountedPtr<U, V> const &lhs, CountedPtr<X, Y> const &rhs) {
return !(lhs.equal(rhs.get));
}
- template<typename U, typename V, typename X, typename Y>
+ template<typename U, typename V, typename X, typename Y>
inline void swap(CountedPtr<U, V> const &lhs, CountedPtr<X, Y> const &rhs) {
lhs.swap(rhs);
}
@@ -260,17 +260,17 @@ namespace ZThread {
return lhs.less(rhs);
}
- template<typename U, typename V>
+ template<typename U, typename V>
inline bool operator==(CountedPtr<U, V> const &lhs, CountedPtr<U, V> const &rhs) {
return lhs.equal(rhs.get);
}
- template<typename U, typename V>
+ template<typename U, typename V>
inline bool operator!=(CountedPtr<U, V> const &lhs, CountedPtr<U, V> const &rhs) {
return !(lhs.equal(rhs.get));
}
- template<typename U, typename V>
+ template<typename U, typename V>
inline void swap(CountedPtr<U, V> const &lhs, CountedPtr<U, V> const &rhs) {
lhs.swap(rhs);
}
@@ -283,7 +283,7 @@ namespace ZThread {
#ifdef _MSC_VER
# pragma warning(pop)
# pragma warning(pop)
-#endif
+#endif
#endif // __ZTCOUNTEDPTR_H__
diff --git a/dep/include/zthread/CountingSemaphore.h b/dep/include/zthread/CountingSemaphore.h
index f580a65f726..ea23300c2a7 100644
--- a/dep/include/zthread/CountingSemaphore.h
+++ b/dep/include/zthread/CountingSemaphore.h
@@ -27,17 +27,17 @@
#include "zthread/NonCopyable.h"
namespace ZThread {
-
+
class FifoSemaphoreImpl;
-
+
/**
* @class CountingSemaphore
* @author Eric Crahen <http://www.code-foo.com>
* @date <2003-07-16T15:26:18-0400>
* @version 2.2.1
*
- * A CountingSemaphore is an owner-less Lockable object.
- *
+ * A CountingSemaphore is an owner-less Lockable object.
+ *
* It differs from a normal Semaphore in that there is no upper bound on the count
* and it will not throw an exception because a maximum value has been exceeded.
*
@@ -46,17 +46,17 @@ namespace ZThread {
* Threads blocked on a CountingSemaphore are resumed in FIFO order.
*/
class ZTHREAD_API CountingSemaphore : public Lockable, private NonCopyable {
-
- FifoSemaphoreImpl* _impl;
+
+ FifoSemaphoreImpl* _impl;
public:
/**
- * Create a new CountingSemaphore.
+ * Create a new CountingSemaphore.
*
* @param count - initial count
*/
- CountingSemaphore(int initialCount = 0);
+ CountingSemaphore(int initialCount = 0);
//! Destroy the CountingSemaphore
virtual ~CountingSemaphore();
@@ -65,8 +65,8 @@ namespace ZThread {
* <i>Provided to reflect the traditional Semaphore semantics</i>
*
* @see acquire()
- */
- void wait();
+ */
+ void wait();
/**
@@ -74,51 +74,51 @@ namespace ZThread {
*
* @see tryAcquire(unsigned long timeout)
*/
- bool tryWait(unsigned long timeout);
+ bool tryWait(unsigned long timeout);
/**
* <i>Provided to reflect the traditional Semaphore semantics</i>
*
* @see release()
*/
- void post();
+ void post();
+
-
/**
- * Get the current count of the semaphore.
+ * Get the current count of the semaphore.
*
* This value may change immediately after this function returns to the calling thread.
*
* @return <em>int</em> count
*/
- virtual int count();
-
+ virtual int count();
+
/**
- * Decrement the count, blocking that calling thread if the count becomes 0 or
- * less than 0. The calling thread will remain blocked until the count is
+ * Decrement the count, blocking that calling thread if the count becomes 0 or
+ * less than 0. The calling thread will remain blocked until the count is
* raised above 0, an exception is thrown or the given amount of time expires.
- *
+ *
* @param timeout maximum amount of time (milliseconds) this method could block
- *
- * @return
+ *
+ * @return
* - <em>true</em> if the Semaphore was acquired before <i>timeout</i> milliseconds elapse.
* - <em>false</em> otherwise.
*
* @exception Interrupted_Exception thrown when the calling thread is interrupted.
* A thread may be interrupted at any time, prematurely ending any wait.
- *
+ *
* @see Lockable::tryAcquire(unsigned long timeout)
*/
virtual bool tryAcquire(unsigned long timeout);
/**
- * Decrement the count, blocking that calling thread if the count becomes 0 or
- * less than 0. The calling thread will remain blocked until the count is
+ * Decrement the count, blocking that calling thread if the count becomes 0 or
+ * less than 0. The calling thread will remain blocked until the count is
* raised above 0 or if an exception is thrown.
- *
+ *
* @exception Interrupted_Exception thrown when the calling thread is interrupted.
* A thread may be interrupted at any time, prematurely ending any wait.
- *
+ *
* @see Lockable::acquire()
*/
virtual void acquire();
@@ -129,8 +129,8 @@ namespace ZThread {
* @see Lockable::release()
*/
virtual void release();
-
- };
+
+ };
} // namespace ZThread
diff --git a/dep/include/zthread/Exceptions.h b/dep/include/zthread/Exceptions.h
index b7207932af4..7a387feb5a4 100644
--- a/dep/include/zthread/Exceptions.h
+++ b/dep/include/zthread/Exceptions.h
@@ -27,8 +27,8 @@
#include "zthread/Config.h"
#include <string>
-namespace ZThread {
-
+namespace ZThread {
+
/**
* @class Synchronization_Exception
*
@@ -43,11 +43,11 @@ class Synchronization_Exception {
static void * operator new[](size_t size);
std::string _msg;
-
+
public:
-
+
/**
- * Create a new exception with a default error message 'Synchronization
+ * Create a new exception with a default error message 'Synchronization
* Exception'
*/
Synchronization_Exception() : _msg("Synchronization exception") { }
@@ -67,9 +67,9 @@ public:
const char* what() const {
return _msg.c_str();
}
-
+
};
-
+
/**
* @class Interrupted_Exception
@@ -88,9 +88,9 @@ class Interrupted_Exception : public Synchronization_Exception {
Interrupted_Exception(const char* msg) : Synchronization_Exception(msg) { }
};
-
-
-
+
+
+
/**
* @class Deadlock_Exception
*
@@ -106,8 +106,8 @@ class Deadlock_Exception : public Synchronization_Exception {
Deadlock_Exception(const char* msg) : Synchronization_Exception(msg) { }
};
-
-
+
+
/**
* @class InvalidOp_Exception
*
@@ -123,16 +123,16 @@ class InvalidOp_Exception : public Synchronization_Exception {
};
-
-
+
+
/**
* @class Initialization_Exception
*
- * Thrown when the system has no more resources to create new
+ * Thrown when the system has no more resources to create new
* synchronization controls
*/
class Initialization_Exception : public Synchronization_Exception {
-
+
public:
//! Create a new exception
@@ -141,24 +141,24 @@ class Initialization_Exception : public Synchronization_Exception {
Initialization_Exception(const char*msg) : Synchronization_Exception(msg) { }
};
-
+
/**
* @class Cancellation_Exception
*
- * Cancellation_Exceptions are thrown by 'Canceled' objects.
+ * Cancellation_Exceptions are thrown by 'Canceled' objects.
* @see Cancelable
*/
class Cancellation_Exception : public Synchronization_Exception {
public:
-
+
//! Create a new Cancelltion_Exception
Cancellation_Exception() : Synchronization_Exception("Canceled") { }
//! Create a new Cancelltion_Exception
Cancellation_Exception(const char*msg) : Synchronization_Exception(msg) { }
-
+
};
-
+
/**
* @class Timeout_Exception
@@ -171,20 +171,20 @@ class Timeout_Exception : public Synchronization_Exception {
//! Create a new Timeout_Exception
Timeout_Exception() : Synchronization_Exception("Timeout") { }
- //! Create a new
+ //! Create a new
Timeout_Exception(const char*msg) : Synchronization_Exception(msg) { }
-
+
};
/**
* @class NoSuchElement_Exception
- *
- * The last operation that was attempted on a Queue could not find
+ *
+ * The last operation that was attempted on a Queue could not find
* the item that was indicated (during that last Queue method invocation)
*/
class NoSuchElement_Exception {
public:
-
+
//! Create a new exception
NoSuchElement_Exception() {}
@@ -193,7 +193,7 @@ class NoSuchElement_Exception {
/**
* @class InvalidTask_Exception
*
- * Thrown when a task is not valid (e.g. null or start()ing a thread with
+ * Thrown when a task is not valid (e.g. null or start()ing a thread with
* no overriden run() method)
*/
class InvalidTask_Exception : public InvalidOp_Exception {
@@ -201,7 +201,7 @@ class InvalidTask_Exception : public InvalidOp_Exception {
//! Create a new exception
InvalidTask_Exception() : InvalidOp_Exception("Invalid task") {}
-
+
};
/**
@@ -221,7 +221,7 @@ class BrokenBarrier_Exception : public Synchronization_Exception {
BrokenBarrier_Exception(const char* msg) : Synchronization_Exception(msg) { }
};
-
+
/**
* @class Future_Exception
*
diff --git a/dep/include/zthread/Executor.h b/dep/include/zthread/Executor.h
index 833d0d4c3d1..1c6a81a72eb 100644
--- a/dep/include/zthread/Executor.h
+++ b/dep/include/zthread/Executor.h
@@ -28,7 +28,7 @@
namespace ZThread {
-
+
/**
* @class Executor
*
@@ -41,27 +41,27 @@ namespace ZThread {
* be found in the proceedings of the 2002 VikingPLOP conference.
*
* <b>Executing</b>
- *
+ *
* - <em>execute</em>()ing task with an Executor will submit the task, scheduling
* it for execution at some future time depending on the Executor being used.
*
* <b>Disabling</b>
*
- * - <em>cancel</em>()ing an Executor will cause it to stop accepting
- * new tasks.
+ * - <em>cancel</em>()ing an Executor will cause it to stop accepting
+ * new tasks.
*
* <b>Interrupting</b>
*
- * - <em>interrupt</em>()ing an Executor will cause the any thread running
- * a task which was submitted prior to the invocation of this function to
+ * - <em>interrupt</em>()ing an Executor will cause the any thread running
+ * a task which was submitted prior to the invocation of this function to
* be interrupted during the execution of that task.
*
* <b>Waiting</b>
*
- * - <em>wait</em>()ing on a PoolExecutor will block the calling thread
+ * - <em>wait</em>()ing on a PoolExecutor will block the calling thread
* until all tasks that were submitted prior to the invocation of this function
* have completed.
- *
+ *
* @see Cancelable
* @see Waitable
*/
@@ -69,15 +69,15 @@ namespace ZThread {
public:
/**
- * If supported by the Executor, interrupt all tasks submitted prior to
+ * If supported by the Executor, interrupt all tasks submitted prior to
* the invocation of this function.
- */
+ */
virtual void interrupt() = 0;
/**
- * Submit a task to this Executor.
+ * Submit a task to this Executor.
*
- * @param task Task to be run by a thread managed by this executor
+ * @param task Task to be run by a thread managed by this executor
*
* @pre The Executor should have been canceled prior to this invocation.
* @post The submitted task will be run at some point in the future by this Executor.
@@ -86,7 +86,7 @@ namespace ZThread {
* the invocation of this function.
*/
virtual void execute(const Task& task) = 0;
-
+
};
} // namespace ZThread
diff --git a/dep/include/zthread/FairReadWriteLock.h b/dep/include/zthread/FairReadWriteLock.h
index 8f183b62839..908f663a508 100644
--- a/dep/include/zthread/FairReadWriteLock.h
+++ b/dep/include/zthread/FairReadWriteLock.h
@@ -36,18 +36,18 @@ namespace ZThread {
* @author Eric Crahen <http://www.code-foo.com>
* @date <2003-07-16T10:26:25-0400>
* @version 2.2.7
- *
- * A FairReadWriteLock maintains a balance between the order read-only access
+ *
+ * A FairReadWriteLock maintains a balance between the order read-only access
* and read-write access is allowed. Threads contending for the pair of Lockable
* objects this ReadWriteLock provides will gain access to the locks in FIFO order.
*
- * @see ReadWriteLock
+ * @see ReadWriteLock
*/
class FairReadWriteLock : public ReadWriteLock {
Mutex _lock;
Condition _cond;
-
+
volatile int _readers;
//! @class ReadLock
@@ -64,16 +64,16 @@ namespace ZThread {
virtual void acquire() {
Guard<Mutex> g(_rwlock._lock);
- ++_rwlock._readers;
+ ++_rwlock._readers;
}
virtual bool tryAcquire(unsigned long timeout) {
-
+
if(!_rwlock._lock.tryAcquire(timeout))
return false;
- ++_rwlock._readers;
+ ++_rwlock._readers;
_rwlock._lock.release();
return true;
@@ -82,7 +82,7 @@ namespace ZThread {
virtual void release() {
Guard<Mutex> g(_rwlock._lock);
- --_rwlock._readers;
+ --_rwlock._readers;
if(_rwlock._readers == 0)
_rwlock._cond.signal();
@@ -121,7 +121,7 @@ namespace ZThread {
}
virtual bool tryAcquire(unsigned long timeout) {
-
+
if(!_rwlock._lock.tryAcquire(timeout))
return false;
@@ -154,11 +154,11 @@ namespace ZThread {
WriteLock _wlock;
public:
-
+
/**
* Create a BiasedReadWriteLock
*
- * @exception Initialization_Exception thrown if resources could not be
+ * @exception Initialization_Exception thrown if resources could not be
* allocated for this object.
*/
FairReadWriteLock() : _cond(_lock), _readers(0), _rlock(*this), _wlock(*this) {}
@@ -175,7 +175,7 @@ namespace ZThread {
* @see ReadWriteLock::getWriteLock()
*/
virtual Lockable& getWriteLock() { return _wlock; }
-
+
};
}; // __ZTFAIRREADWRITELOCK_H__
diff --git a/dep/include/zthread/FastMutex.h b/dep/include/zthread/FastMutex.h
index 1812c3e55a5..819108b377a 100644
--- a/dep/include/zthread/FastMutex.h
+++ b/dep/include/zthread/FastMutex.h
@@ -38,10 +38,10 @@ namespace ZThread {
*
* A FastMutex is a small fast implementation of a non-recursive, mutually exclusive
* Lockable object. This implementation is a bit faster than the other Mutex classes
- * as it involved the least overhead. However, this slight increase in speed is
- * gained by sacrificing the robustness provided by the other classes.
+ * as it involved the least overhead. However, this slight increase in speed is
+ * gained by sacrificing the robustness provided by the other classes.
*
- * A FastMutex has the useful property of not being interruptable; that is to say
+ * A FastMutex has the useful property of not being interruptable; that is to say
* that acquire() and tryAcquire() will not throw Interrupted_Exceptions.
*
* @see Mutex
@@ -53,49 +53,49 @@ namespace ZThread {
* <b>Error Checking</b>
*
* No error checking is performed, this means there is the potential for deadlock.
- */
+ */
class ZTHREAD_API FastMutex : public Lockable, private NonCopyable {
-
+
FastLock* _lock;
public:
-
+
//! Create a FastMutex
FastMutex();
-
+
//! Destroy a FastMutex
virtual ~FastMutex();
-
+
/**
- * Acquire exclusive access to the mutex. The calling thread will block until the
+ * Acquire exclusive access to the mutex. The calling thread will block until the
* lock can be acquired. No safety or state checks are performed.
- *
+ *
* @pre The calling thread should <i>not</i> have previously acquired this lock.
- * Deadlock will result if the same thread attempts to acquire the mutex more
- * than once.
+ * Deadlock will result if the same thread attempts to acquire the mutex more
+ * than once.
*
* @post The calling thread obtains the lock successfully if no exception is thrown.
* @exception Interrupted_Exception never thrown
*/
virtual void acquire();
-
+
/**
* Release exclusive access. No safety or state checks are performed.
- *
+ *
* @pre the caller should have previously acquired this lock
*/
virtual void release();
-
+
/**
- * Try to acquire exclusive access to the mutex. The calling thread will block until the
+ * Try to acquire exclusive access to the mutex. The calling thread will block until the
* lock can be acquired. No safety or state checks are performed.
- *
+ *
* @pre The calling thread should <i>not</i> have previously acquired this lock.
- * Deadlock will result if the same thread attempts to acquire the mutex more
- * than once.
+ * Deadlock will result if the same thread attempts to acquire the mutex more
+ * than once.
*
* @param timeout unused
- * @return
+ * @return
* - <em>true</em> if the lock was acquired
* - <em>false</em> if the lock was acquired
*
@@ -103,7 +103,7 @@ namespace ZThread {
* @exception Interrupted_Exception never thrown
*/
virtual bool tryAcquire(unsigned long timeout);
-
+
}; /* FastMutex */
};
diff --git a/dep/include/zthread/FastRecursiveMutex.h b/dep/include/zthread/FastRecursiveMutex.h
index a30f4b53aa7..5a3322e3c65 100644
--- a/dep/include/zthread/FastRecursiveMutex.h
+++ b/dep/include/zthread/FastRecursiveMutex.h
@@ -39,10 +39,10 @@ namespace ZThread {
*
* A FastRecursiveMutex is a small fast implementation of a recursive, mutally exclusive
* Lockable object. This implementation is a bit faster than the other Mutex classes
- * as it involved the least overhead. However, this slight increase in speed is
- * gained by sacrificing the robustness provided by the other classes.
+ * as it involved the least overhead. However, this slight increase in speed is
+ * gained by sacrificing the robustness provided by the other classes.
*
- * A FastRecursiveMutex has the useful property of not being interruptable; that is to say
+ * A FastRecursiveMutex has the useful property of not being interruptable; that is to say
* that acquire() and tryAcquire() will not throw Interrupted_Exceptions.
*
* @see RecursiveMutex
@@ -54,13 +54,13 @@ namespace ZThread {
* <b>Error Checking</b>
*
* No error checking is performed, this means there is the potential for deadlock.
- */
+ */
class ZTHREAD_API FastRecursiveMutex : public Lockable, private NonCopyable {
-
+
FastRecursiveLock* _lock;
public:
-
+
//! Create a new FastRecursiveMutex
FastRecursiveMutex();
@@ -68,7 +68,7 @@ namespace ZThread {
virtual ~FastRecursiveMutex();
/**
- * Acquire exclusive access to the mutex. The calling thread will block until the
+ * Acquire exclusive access to the mutex. The calling thread will block until the
* lock can be acquired. No safety or state checks are performed. The calling thread
* may acquire the mutex nore than once.
*
@@ -76,21 +76,21 @@ namespace ZThread {
* @exception Interrupted_Exception never thrown
*/
virtual void acquire();
-
+
/**
* Release access. No safety or state checks are performed.
- *
+ *
* @pre the caller should have previously acquired this lock at least once.
*/
virtual void release();
-
+
/**
- * Try to acquire exclusive access to the mutex. The calling thread will block until the
+ * Try to acquire exclusive access to the mutex. The calling thread will block until the
* lock can be acquired. No safety or state checks are performed. The calling thread
* may acquire the mutex more than once.
*
* @param timeout unused
- * @return
+ * @return
* - <em>true</em> if the lock was acquired
* - <em>false</em> if the lock was acquired
*
@@ -98,8 +98,8 @@ namespace ZThread {
* @exception Interrupted_Exception never thrown
*/
virtual bool tryAcquire(unsigned long timeout);
-
- };
+
+ };
} // namespace ZThread
diff --git a/dep/include/zthread/Guard.h b/dep/include/zthread/Guard.h
index 988c3cfa3c2..d1befccd85a 100644
--- a/dep/include/zthread/Guard.h
+++ b/dep/include/zthread/Guard.h
@@ -26,15 +26,15 @@
#include "zthread/NonCopyable.h"
#include "zthread/Exceptions.h"
-namespace ZThread {
+namespace ZThread {
-//
-// GuardLockingPolicyContract {
//
-// createScope(lock_type&)
-// bool createScope(lock_type&, unsigned long)
-// destroyScope(lock_type&)
-//
+// GuardLockingPolicyContract {
+//
+// createScope(lock_type&)
+// bool createScope(lock_type&, unsigned long)
+// destroyScope(lock_type&)
+//
// }
//
@@ -59,12 +59,12 @@ class LockHolder {
template <class T>
LockHolder(T& t) : _lock(extract(t)._lock), _enabled(true) { }
-
+
LockHolder(LockHolder& holder) : _lock(holder._lock), _enabled(true) { }
LockHolder(LockType& lock) : _lock(lock), _enabled(true) { }
- void disable() {
+ void disable() {
_enabled = false;
}
@@ -78,7 +78,7 @@ class LockHolder {
protected:
- template <class T>
+ template <class T>
static LockHolder& extract(T& t) {
// Design and Evolution of C++, page 328
return (LockHolder&)(t);
@@ -117,7 +117,7 @@ class CompoundScope {
return false;
}
-
+
return true;
}
@@ -154,7 +154,7 @@ class LockedScope {
* @param lock2 LockType1& is the LockHolder that wants to share
template <class LockType1, class LockType2>
static void shareScope(LockHolder<LockType1>& l1, LockHolder<LockType2>& l2) {
-
+
l2.getLock().acquire();
}
@@ -207,7 +207,7 @@ class LockedScope {
*
* Locking policy for Lockable objects. This policy release()s a Lockable
* when the protection scope is created, and it acquire()s a Lockable
- * when the scope is destroyed.
+ * when the scope is destroyed.
*/
class UnlockedScope {
public:
@@ -251,7 +251,7 @@ class UnlockedScope {
}
};
-
+
/**
@@ -277,7 +277,7 @@ class TimedLockedScope {
if(!l2.getLock().tryAcquire(TimeOut))
throw Timeout_Exception();
-
+
}
template <class LockType>
@@ -338,29 +338,29 @@ class OverlappedScope {
* @version 2.2.0
*
* Scoped locking utility. This template class can be given a Lockable
- * synchronization object and can 'Guard' or serialize access to
+ * synchronization object and can 'Guard' or serialize access to
* that method.
- *
- * For instance, consider a case in which a class or program have a
- * Mutex object associated with it. Access can be serialized with a
+ *
+ * For instance, consider a case in which a class or program have a
+ * Mutex object associated with it. Access can be serialized with a
* Guard as shown below.
*
* @code
*
* Mutex _mtx;
* void guarded() {
- *
+ *
* Guard<Mutex> g(_mtx);
*
* }
*
* @endcode
*
- * The Guard will lock the synchronization object when it is created and
- * automatically unlock it when it goes out of scope. This eliminates
+ * The Guard will lock the synchronization object when it is created and
+ * automatically unlock it when it goes out of scope. This eliminates
* common mistakes like forgetting to unlock your mutex.
*
- * An alternative to the above example would be
+ * An alternative to the above example would be
*
* @code
*
@@ -385,15 +385,15 @@ class Guard : private LockHolder<LockType>, private NonCopyable {
friend class LockHolder<LockType>;
public:
-
+
/**
* Create a Guard that enforces a the effective protection scope
- * throughout the lifetime of the Guard object or until the protection
+ * throughout the lifetime of the Guard object or until the protection
* scope is modified by another Guard.
*
- * @param lock LockType the lock this Guard will use to enforce its
+ * @param lock LockType the lock this Guard will use to enforce its
* protection scope.
- * @post the protection scope may be ended prematurely
+ * @post the protection scope may be ended prematurely
*/
Guard(LockType& lock) : LockHolder<LockType>(lock) {
@@ -403,12 +403,12 @@ public:
/**
* Create a Guard that enforces a the effective protection scope
- * throughout the lifetime of the Guard object or until the protection
+ * throughout the lifetime of the Guard object or until the protection
* scope is modified by another Guard.
*
- * @param lock LockType the lock this Guard will use to enforce its
+ * @param lock LockType the lock this Guard will use to enforce its
* protection scope.
- * @post the protection scope may be ended prematurely
+ * @post the protection scope may be ended prematurely
*/
Guard(LockType& lock, unsigned long timeout) : LockHolder<LockType>(lock) {
@@ -419,31 +419,31 @@ public:
/**
* Create a Guard that shares the effective protection scope
- * from the given Guard to this Guard.
+ * from the given Guard to this Guard.
*
- * @param g Guard<U, V> guard that is currently enabled
- * @param lock LockType the lock this Guard will use to enforce its
+ * @param g Guard<U, V> guard that is currently enabled
+ * @param lock LockType the lock this Guard will use to enforce its
* protection scope.
*/
template <class U, class V>
Guard(Guard<U, V>& g) : LockHolder<LockType>(g) {
LockingPolicy::shareScope(*this, extract(g));
-
+
}
/**
* Create a Guard that shares the effective protection scope
- * from the given Guard to this Guard.
+ * from the given Guard to this Guard.
*
- * @param g Guard guard that is currently enabled
- * @param lock LockType the lock this Guard will use to enforce its
+ * @param g Guard guard that is currently enabled
+ * @param lock LockType the lock this Guard will use to enforce its
* protection scope.
*/
Guard(Guard& g) : LockHolder<LockType>(g) {
LockingPolicy::shareScope(*this, g);
-
+
}
@@ -451,8 +451,8 @@ public:
* Create a Guard that transfers the effective protection scope
* from the given Guard to this Guard.
*
- * @param g Guard<U, V> guard that is currently enabled
- * @param lock LockType the lock this Guard will use to enforce its
+ * @param g Guard<U, V> guard that is currently enabled
+ * @param lock LockType the lock this Guard will use to enforce its
* protection scope.
*/
template <class U, class V>
@@ -467,8 +467,8 @@ public:
* Create a Guard that transfers the effective protection scope
* from the given Guard to this Guard.
*
- * @param g Guard guard that is currently enabled
- * @param lock LockType the lock this Guard will use to enforce its
+ * @param g Guard guard that is currently enabled
+ * @param lock LockType the lock this Guard will use to enforce its
* protection scope.
*/
Guard(Guard& g, LockType& lock) : LockHolder<LockType>(lock) {
@@ -476,7 +476,7 @@ public:
LockingPolicy::transferScope(*this, g);
}
-
+
/**
* Unlock a given Lockable object with the destruction of this Guard
@@ -488,14 +488,14 @@ public:
template <class LockType, class LockingPolicy>
Guard<LockType, LockingPolicy>::~Guard() throw() {
-
+
try {
-
+
if(!this->isDisabled())
LockingPolicy::destroyScope(*this);
-
- } catch (...) { /* ignore */ }
-
+
+ } catch (...) { /* ignore */ }
+
}
diff --git a/dep/include/zthread/GuardedClass.h b/dep/include/zthread/GuardedClass.h
index 4ef3879cb08..1a8ac1904df 100644
--- a/dep/include/zthread/GuardedClass.h
+++ b/dep/include/zthread/GuardedClass.h
@@ -34,25 +34,25 @@ namespace ZThread {
* @date <2003-07-20T20:17:34-0400>
* @version 2.3.0
*
- * A simple wrapper template that uses Guard's to provide
+ * A simple wrapper template that uses Guard's to provide
* serialized access to an objects member functions.
*/
template <class T, class LockType = Mutex>
class GuardedClass {
-
+
LockType _lock;
T* _ptr;
-
+
class TransferedScope {
public:
-
+
template <class LockType1, class LockType2>
static void shareScope(LockHolder<LockType1>& l1,
LockHolder<LockType2>& l2) {
l1.disable();
l2.getLock().acquire();
}
-
+
template <class LockType1>
static void createScope(LockHolder<LockType1>& l) {
// Don't acquire the lock when scope the Guard is created
@@ -82,9 +82,9 @@ namespace ZThread {
GuardedClass();
GuardedClass& operator=(const GuardedClass&);
-
+
public:
-
+
GuardedClass(T* ptr) : _ptr(ptr) {}
~GuardedClass() {
if(_ptr)
@@ -95,9 +95,9 @@ namespace ZThread {
Proxy p(_lock, _ptr);
return p;
}
-
+
};
-
+
} // namespace ZThread
#endif // __ZTGUARDEDCLASS_H__
diff --git a/dep/include/zthread/Lockable.h b/dep/include/zthread/Lockable.h
index 32f7eeda97b..a663498bc2c 100644
--- a/dep/include/zthread/Lockable.h
+++ b/dep/include/zthread/Lockable.h
@@ -25,7 +25,7 @@
#include "zthread/Exceptions.h"
-namespace ZThread {
+namespace ZThread {
/**
* @class Lockable
@@ -33,18 +33,18 @@ namespace ZThread {
* @date <2003-07-16T10:33:32-0400>
* @version 2.3.0
*
- * The Lockable interface defines a common method of adding general <i>acquire-release</i>
- * semantics to an object. An <i>acquire-release</i> protocol does not necessarily imply
- * exclusive access.
+ * The Lockable interface defines a common method of adding general <i>acquire-release</i>
+ * semantics to an object. An <i>acquire-release</i> protocol does not necessarily imply
+ * exclusive access.
*/
class Lockable {
- public:
-
+ public:
+
//! Destroy a Lockable object.
virtual ~Lockable() {}
- /**
- * Acquire the Lockable object.
+ /**
+ * Acquire the Lockable object.
*
* This method may or may not block the caller for an indefinite amount
* of time. Those details are defined by specializations of this class.
@@ -52,40 +52,40 @@ namespace ZThread {
* @exception Interrupted_Exception thrown if the calling thread is interrupted before
* the operation completes.
*
- * @post The Lockable is acquired only if no exception was thrown.
+ * @post The Lockable is acquired only if no exception was thrown.
*/
virtual void acquire() = 0;
- /**
- * Attempt to acquire the Lockable object.
+ /**
+ * Attempt to acquire the Lockable object.
*
* This method may or may not block the caller for a definite amount
* of time. Those details are defined by specializations of this class;
- * however, this method includes a timeout value that can be used to
- * limit the maximum amount of time that a specialization <i>could</i> block.
+ * however, this method includes a timeout value that can be used to
+ * limit the maximum amount of time that a specialization <i>could</i> block.
*
* @param timeout - maximum amount of time (milliseconds) this method could block
*
- * @return
- * - <em>true</em> if the operation completes and the Lockable is acquired before
- * the timeout expires.
+ * @return
+ * - <em>true</em> if the operation completes and the Lockable is acquired before
+ * the timeout expires.
* - <em>false</em> if the operation times out before the Lockable can be acquired.
- *
+ *
* @exception Interrupted_Exception thrown if the calling thread is interrupted before
* the operation completes.
*
- * @post The Lockable is acquired only if no exception was thrown.
+ * @post The Lockable is acquired only if no exception was thrown.
*/
virtual bool tryAcquire(unsigned long timeout) = 0;
-
- /**
+
+ /**
* Release the Lockable object.
*
* This method may or may not block the caller for an indefinite amount
* of time. Those details are defined by specializations of this class.
*
- * @post The Lockable is released only if no exception was thrown.
- */
+ * @post The Lockable is released only if no exception was thrown.
+ */
virtual void release() = 0;
};
diff --git a/dep/include/zthread/LockedQueue.h b/dep/include/zthread/LockedQueue.h
index a1f0df26431..5aae3278406 100644
--- a/dep/include/zthread/LockedQueue.h
+++ b/dep/include/zthread/LockedQueue.h
@@ -36,7 +36,7 @@ namespace ZThread {
* @date <2003-07-16T11:42:33-0400>
* @version 2.3.0
*
- * A LockedQueue is the simple Queue implementation that provides
+ * A LockedQueue is the simple Queue implementation that provides
* serialized access to the values added to it.
*/
template <class T, class LockType, typename StorageType=std::deque<T> >
@@ -65,7 +65,7 @@ namespace ZThread {
virtual void add(const T& item) {
Guard<LockType> g(_lock);
-
+
if(_canceled)
throw Cancellation_Exception();
@@ -77,18 +77,18 @@ namespace ZThread {
* @see Queue::add(const T& item, unsigned long timeout)
*/
virtual bool add(const T& item, unsigned long timeout) {
-
+
try {
Guard<LockType> g(_lock, timeout);
-
+
if(_canceled)
throw Cancellation_Exception();
-
+
_queue.push_back(item);
} catch(Timeout_Exception&) { return false; }
-
+
return true;
}
@@ -97,23 +97,23 @@ namespace ZThread {
* @see Queue::next()
*/
virtual T next() {
-
+
Guard<LockType> g(_lock);
if(_queue.empty() && _canceled)
throw Cancellation_Exception();
-
+
if(_queue.empty())
throw NoSuchElement_Exception();
T item = _queue.front();
_queue.pop_front();
-
+
return item;
}
-
+
/**
* @see Queue::next(unsigned long timeout)
*/
@@ -123,15 +123,15 @@ namespace ZThread {
if(_queue.empty() && _canceled)
throw Cancellation_Exception();
-
+
if(_queue.empty())
throw NoSuchElement_Exception();
T item = _queue.front();
_queue.pop_front();
-
+
return item;
-
+
}
virtual T front()
@@ -148,7 +148,7 @@ namespace ZThread {
* @see Queue::cancel()
*/
virtual void cancel() {
-
+
Guard<LockType> g(_lock);
_canceled = true;
@@ -159,11 +159,11 @@ namespace ZThread {
* @see Queue::isCanceled()
*/
virtual bool isCanceled() {
-
+
// Faster check since the queue will not become un-canceled
if(_canceled)
return true;
-
+
Guard<LockType> g(_lock);
return _canceled;
diff --git a/dep/include/zthread/MonitoredQueue.h b/dep/include/zthread/MonitoredQueue.h
index 8578fe62b96..2122b7f7a28 100644
--- a/dep/include/zthread/MonitoredQueue.h
+++ b/dep/include/zthread/MonitoredQueue.h
@@ -37,12 +37,12 @@ namespace ZThread {
* @date <2003-07-16T20:23:28-0400>
* @version 2.3.0
*
- * A MonitoredQueue is a Queue implementation that provides serialized access to the
- * items added to it.
+ * A MonitoredQueue is a Queue implementation that provides serialized access to the
+ * items added to it.
*
- * - Threads calling the empty() methods will be blocked until the BoundedQueue becomes empty.
+ * - Threads calling the empty() methods will be blocked until the BoundedQueue becomes empty.
* - Threads calling the next() methods will be blocked until the BoundedQueue has a value to
- * return.
+ * return.
*
* @see Queue
*/
@@ -67,17 +67,17 @@ namespace ZThread {
public:
//! Create a new MonitoredQueue
- MonitoredQueue()
+ MonitoredQueue()
: _notEmpty(_lock), _isEmpty(_lock), _canceled(false) {}
//! Destroy a MonitoredQueue, delete remaining items
virtual ~MonitoredQueue() { }
/**
- * Add a value to this Queue.
+ * Add a value to this Queue.
*
* @param item value to be added to the Queue
- *
+ *
* @exception Cancellation_Exception thrown if this Queue has been canceled.
* @exception Interrupted_Exception thrown if the thread was interrupted while waiting
* to add a value
@@ -90,7 +90,7 @@ namespace ZThread {
virtual void add(const T& item) {
Guard<LockType> g(_lock);
-
+
// Allow no further additions in the canceled state
if(_canceled)
throw Cancellation_Exception();
@@ -102,14 +102,14 @@ namespace ZThread {
}
/**
- * Add a value to this Queue.
+ * Add a value to this Queue.
*
* @param item value to be added to the Queue
* @param timeout maximum amount of time (milliseconds) this method may block
* the calling thread.
*
- * @return
- * - <em>true</em> if a copy of <i>item</i> can be added before <i>timeout</i>
+ * @return
+ * - <em>true</em> if a copy of <i>item</i> can be added before <i>timeout</i>
* milliseconds elapse.
* - <em>false</em> otherwise.
*
@@ -123,32 +123,32 @@ namespace ZThread {
* @see Queue::add(const T& item, unsigned long timeout)
*/
virtual bool add(const T& item, unsigned long timeout) {
-
+
try {
Guard<LockType> g(_lock, timeout);
-
+
if(_canceled)
throw Cancellation_Exception();
-
+
_queue.push_back(item);
_notEmpty.signal();
} catch(Timeout_Exception&) { return false; }
-
- return true;
+
+ return true;
}
/**
* Retrieve and remove a value from this Queue.
*
- * If invoked when there are no values present to return then the calling thread
+ * If invoked when there are no values present to return then the calling thread
* will be blocked until a value arrives in the Queue.
*
* @return <em>T</em> next available value
- *
+ *
* @exception Cancellation_Exception thrown if this Queue has been canceled.
* @exception Interrupted_Exception thrown if the thread was interrupted while waiting
* to retrieve a value
@@ -157,15 +157,15 @@ namespace ZThread {
* @post The value returned will have been removed from the Queue.
*/
virtual T next() {
-
+
Guard<LockType> g(_lock);
-
- while (_queue.empty() && !_canceled)
+
+ while (_queue.empty() && !_canceled)
_notEmpty.wait();
-
+
if(_queue.empty()) // Queue canceled
- throw Cancellation_Exception();
-
+ throw Cancellation_Exception();
+
T item = _queue.front();
_queue.pop_front();
@@ -179,14 +179,14 @@ namespace ZThread {
/**
* Retrieve and remove a value from this Queue.
*
- * If invoked when there are no values present to return then the calling thread
+ * If invoked when there are no values present to return then the calling thread
* will be blocked until a value arrives in the Queue.
*
* @param timeout maximum amount of time (milliseconds) this method may block
* the calling thread.
*
* @return <em>T</em> next available value
- *
+ *
* @exception Cancellation_Exception thrown if this Queue has been canceled.
* @exception Timeout_Exception thrown if the timeout expires before a value
* can be retrieved.
@@ -195,16 +195,16 @@ namespace ZThread {
* @post The value returned will have been removed from the Queue.
*/
virtual T next(unsigned long timeout) {
-
+
Guard<LockType> g(_lock, timeout);
-
+
while(_queue.empty() && !_canceled) {
if(!_notEmpty.wait(timeout))
throw Timeout_Exception();
}
if( _queue.empty()) // Queue canceled
- throw Cancellation_Exception();
+ throw Cancellation_Exception();
T item = _queue.front();
_queue.pop_front();
@@ -218,10 +218,10 @@ namespace ZThread {
/**
- * Cancel this queue.
- *
+ * Cancel this queue.
+ *
* @post Any threads blocked by a next() function will throw a Cancellation_Exception.
- *
+ *
* @see Queue::cancel()
*/
virtual void cancel() {
@@ -237,11 +237,11 @@ namespace ZThread {
* @see Queue::isCanceled()
*/
virtual bool isCanceled() {
-
+
// Faster check since the queue will not become un-canceled
if(_canceled)
return true;
-
+
Guard<LockType> g(_lock);
return _canceled;
@@ -272,10 +272,10 @@ namespace ZThread {
/**
* Test whether any values are available in this Queue.
*
- * The calling thread is blocked until there are no values present
+ * The calling thread is blocked until there are no values present
* in the Queue.
- *
- * @return
+ *
+ * @return
* - <em>true</em> if there are no values available.
* - <em>false</em> if there <i>are</i> values available.
*
@@ -287,7 +287,7 @@ namespace ZThread {
while(!_queue.empty()) // Wait for an empty signal
_isEmpty.wait();
-
+
return true;
}
@@ -295,13 +295,13 @@ namespace ZThread {
/**
* Test whether any values are available in this Queue.
*
- * The calling thread is blocked until there are no values present
+ * The calling thread is blocked until there are no values present
* in the Queue.
- *
+ *
* @param timeout maximum amount of time (milliseconds) this method may block
* the calling thread.
*
- * @return
+ * @return
* - <em>true</em> if there are no values available.
* - <em>false</em> if there <i>are</i> values available.
*
@@ -311,12 +311,12 @@ namespace ZThread {
* @see Queue::empty()
*/
virtual bool empty(unsigned long timeout) {
-
+
Guard<LockType> g(_lock, timeout);
while(!_queue.empty()) // Wait for an empty signal
_isEmpty.wait(timeout);
-
+
return true;
}
diff --git a/dep/include/zthread/Mutex.h b/dep/include/zthread/Mutex.h
index 1b521b1598d..6c2c6bd2d3e 100644
--- a/dep/include/zthread/Mutex.h
+++ b/dep/include/zthread/Mutex.h
@@ -26,8 +26,8 @@
#include "zthread/Lockable.h"
#include "zthread/NonCopyable.h"
-namespace ZThread {
-
+namespace ZThread {
+
class FifoMutexImpl;
/**
@@ -39,7 +39,7 @@ namespace ZThread {
* A Mutex is used to provide serialized (one thread at a time) access to some portion
* of code. This is accomplished by attempting to acquire the Mutex before entering that
* piece of code, and by releasing the Mutex when leaving that region. It is a non-reentrant,
- * MUTual EXclusion Lockable object.
+ * MUTual EXclusion Lockable object.
*
* @see Guard
*
@@ -49,26 +49,26 @@ namespace ZThread {
*
* <b>Error Checking</b>
*
- * A Mutex will throw a Deadlock_Exception if an attempt to acquire a Mutex more
+ * A Mutex will throw a Deadlock_Exception if an attempt to acquire a Mutex more
* than once is made from the context of the same thread.
*
- * A Mutex will throw an InvalidOp_Exception if an attempt to release a Mutex is
+ * A Mutex will throw an InvalidOp_Exception if an attempt to release a Mutex is
* made from the context of a thread that does not currently own that Mutex.
*/
class ZTHREAD_API Mutex : public Lockable, private NonCopyable {
-
+
FifoMutexImpl* _impl;
-
+
public:
//! Create a new Mutex.
- Mutex();
+ Mutex();
//! Destroy this Mutex.
virtual ~Mutex();
-
+
/**
- * Acquire a Mutex, possibly blocking until either the current owner of the
+ * Acquire a Mutex, possibly blocking until either the current owner of the
* Mutex releases it or until an exception is thrown.
*
* Only one thread may acquire() the Mutex at any given time.
@@ -88,14 +88,14 @@ namespace ZThread {
virtual void acquire();
/**
- * Acquire a Mutex, possibly blocking until the current owner of the
+ * Acquire a Mutex, possibly blocking until the current owner of the
* Mutex releases it, until an exception is thrown or until the given amount
* of time expires.
*
* Only one thread may acquire the Mutex at any given time.
*
* @param timeout maximum amount of time (milliseconds) this method could block
- * @return
+ * @return
* - <em>true</em> if the lock was acquired
* - <em>false</em> if the lock was acquired
*
@@ -112,7 +112,7 @@ namespace ZThread {
* @see Lockable::tryAcquire(unsigned long timeout)
*/
virtual bool tryAcquire(unsigned long timeout);
-
+
/**
* Release a Mutex allowing another thread to acquire it.
*
@@ -126,7 +126,7 @@ namespace ZThread {
* @see Lockable::release()
*/
virtual void release();
-
+
};
diff --git a/dep/include/zthread/PoolExecutor.h b/dep/include/zthread/PoolExecutor.h
index 82f5c4f05ba..03df37d9f77 100644
--- a/dep/include/zthread/PoolExecutor.h
+++ b/dep/include/zthread/PoolExecutor.h
@@ -28,7 +28,7 @@
#include "zthread/Thread.h"
namespace ZThread {
-
+
namespace { class ExecutorImpl; }
/**
@@ -38,33 +38,33 @@ namespace ZThread {
* @date <2003-07-16T22:41:07-0400>
* @version 2.3.0
*
- * A PoolExecutor spawns a set of threads that are used to run tasks
+ * A PoolExecutor spawns a set of threads that are used to run tasks
* that are submitted in parallel. A PoolExecutor supports the following
* optional operations,
*
- * - <em>cancel</em>()ing a PoolExecutor will cause it to stop accepting
- * new tasks.
+ * - <em>cancel</em>()ing a PoolExecutor will cause it to stop accepting
+ * new tasks.
*
- * - <em>interrupt</em>()ing a PoolExecutor will cause the any thread running
- * a task which was submitted prior to the invocation of this function to
+ * - <em>interrupt</em>()ing a PoolExecutor will cause the any thread running
+ * a task which was submitted prior to the invocation of this function to
* be interrupted during the execution of that task.
*
- * - <em>wait</em>()ing on a PoolExecutor will block the calling thread
+ * - <em>wait</em>()ing on a PoolExecutor will block the calling thread
* until all tasks that were submitted prior to the invocation of this function
* have completed.
- *
+ *
* @see Executor.
*/
class PoolExecutor : public Executor {
- //! Reference to the internal implementation
+ //! Reference to the internal implementation
CountedPtr< ExecutorImpl > _impl;
-
+
//! Cancellation task
Task _shutdown;
public:
-
+
/**
* Create a PoolExecutor
*
@@ -77,19 +77,19 @@ namespace ZThread {
/**
* Invoking this function causes each task that had been submitted prior to
- * this function to be interrupted. Tasks submitted after the invocation of
+ * this function to be interrupted. Tasks submitted after the invocation of
* this function are unaffected.
*
* @post Any task submitted prior to the invocation of this function will be
- * run in the context of an interrupted thread.
- * @post Any thread already executing a task which was submitted prior to the
- * invocation of this function will be interrupted.
+ * run in the context of an interrupted thread.
+ * @post Any thread already executing a task which was submitted prior to the
+ * invocation of this function will be interrupted.
*/
virtual void interrupt();
/**
* Alter the number of threads being used to execute submitted tasks.
- *
+ *
* @param n number of worker threads.
*
* @pre <i>n</i> must be greater than 0.
@@ -99,21 +99,21 @@ namespace ZThread {
* <i>n</i> is less than 1.
*/
void size(size_t n);
-
+
/**
* Get the current number of threads being used to execute submitted tasks.
*
* @return n number of worker threads.
*/
size_t size();
-
+
/**
- * Submit a task to this Executor.
+ * Submit a task to this Executor.
*
* This will not block the calling thread very long. The submitted task will
* be executed at some later point by another thread.
- *
- * @param task Task to be run by a thread managed by this executor
+ *
+ * @param task Task to be run by a thread managed by this executor
*
* @pre The Executor should have been canceled prior to this invocation.
* @post The submitted task will be run at some point in the future by this Executor.
@@ -135,7 +135,7 @@ namespace ZThread {
* @see Cancelable::isCanceled()
*/
virtual bool isCanceled();
-
+
/**
* Block the calling thread until all tasks submitted prior to this invocation
* complete.
@@ -151,21 +151,21 @@ namespace ZThread {
* Block the calling thread until all tasks submitted prior to this invocation
* complete or until the calling thread is interrupted.
*
- * @param timeout maximum amount of time, in milliseconds, to wait for the
+ * @param timeout maximum amount of time, in milliseconds, to wait for the
* currently submitted set of Tasks to complete.
*
* @exception Interrupted_Exception thrown if the calling thread is interrupted
* before the set of tasks being wait for can complete.
*
- * @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.
*
* @see Waitable::wait(unsigned long timeout)
*/
virtual bool wait(unsigned long timeout);
-
+
}; /* PoolExecutor */
diff --git a/dep/include/zthread/PriorityCondition.h b/dep/include/zthread/PriorityCondition.h
index 1fd86c41c11..a85a000e941 100644
--- a/dep/include/zthread/PriorityCondition.h
+++ b/dep/include/zthread/PriorityCondition.h
@@ -28,7 +28,7 @@
#include "zthread/Waitable.h"
namespace ZThread {
-
+
class PriorityConditionImpl;
/**
@@ -49,9 +49,9 @@ namespace ZThread {
class ZTHREAD_API PriorityCondition : public Waitable, private NonCopyable {
PriorityConditionImpl* _impl;
-
+
public:
-
+
/**
* @see Condition::Condition(Lockable& l)
*/
@@ -61,7 +61,7 @@ namespace ZThread {
* @see Condition::~Condition()
*/
~PriorityCondition();
-
+
/**
* @see Condition::signal()
*/
@@ -81,9 +81,9 @@ namespace ZThread {
* @see Condition::wait(unsigned long timeout)
*/
virtual bool wait(unsigned long timeout);
-
+
};
-
+
} // namespace ZThread
#endif // __ZTPRIORITYCONDITION_H__
diff --git a/dep/include/zthread/PriorityInheritanceMutex.h b/dep/include/zthread/PriorityInheritanceMutex.h
index 1a5f5bfd300..81c6109b318 100644
--- a/dep/include/zthread/PriorityInheritanceMutex.h
+++ b/dep/include/zthread/PriorityInheritanceMutex.h
@@ -26,8 +26,8 @@
#include "zthread/Lockable.h"
#include "zthread/NonCopyable.h"
-namespace ZThread {
-
+namespace ZThread {
+
class PriorityInheritanceMutexImpl;
/**
@@ -37,27 +37,27 @@ namespace ZThread {
* @date <2003-07-16T19:37:36-0400>
* @version 2.2.1
*
- * A PriorityInheritanceMutex is similar to a PriorityMutex, it is a non-reentrant,
- * priority sensitive MUTual EXclusion Lockable object. It differs only in its
+ * A PriorityInheritanceMutex is similar to a PriorityMutex, it is a non-reentrant,
+ * priority sensitive MUTual EXclusion Lockable object. It differs only in its
* scheduling policy.
*
* @see PriorityMutex
*
* <b>Scheduling</b>
*
- * Threads competing to acquire() a PriorityInheritanceMutex are granted access in
+ * Threads competing to acquire() a PriorityInheritanceMutex are granted access in
* order of priority. Threads with a higher priority will be given access first.
*
- * When a higher priority thread tries to acquire() a PriorityInheritanceMutex and is
+ * When a higher priority thread tries to acquire() a PriorityInheritanceMutex and is
* about to be blocked by a lower priority thread that has already acquire()d it, the
- * lower priority thread will temporarily have its effective priority raised to that
- * of the higher priority thread until it release()s the mutex; at which point its
- * previous priority will be restored.
+ * lower priority thread will temporarily have its effective priority raised to that
+ * of the higher priority thread until it release()s the mutex; at which point its
+ * previous priority will be restored.
*/
class ZTHREAD_API PriorityInheritanceMutex : public Lockable, private NonCopyable {
-
+
PriorityInheritanceMutexImpl* _impl;
-
+
public:
/**
@@ -69,23 +69,23 @@ namespace ZThread {
* @see Mutex::~Mutex()
*/
virtual ~PriorityInheritanceMutex();
-
+
/**
* @see Mutex::acquire()
*/
- virtual void acquire();
+ virtual void acquire();
/**
* @see Mutex::tryAcquire(unsigned long timeout)
*/
- virtual bool tryAcquire(unsigned long timeout);
-
+ virtual bool tryAcquire(unsigned long timeout);
+
/**
* @see Mutex::release()
*/
virtual void release();
-
- };
+
+ };
} // namespace ZThread
diff --git a/dep/include/zthread/PriorityMutex.h b/dep/include/zthread/PriorityMutex.h
index 477c8d9fd4d..b1279764eea 100644
--- a/dep/include/zthread/PriorityMutex.h
+++ b/dep/include/zthread/PriorityMutex.h
@@ -26,8 +26,8 @@
#include "zthread/Lockable.h"
#include "zthread/NonCopyable.h"
-namespace ZThread {
-
+namespace ZThread {
+
class PriorityMutexImpl;
/**
@@ -36,9 +36,9 @@ namespace ZThread {
* @date <2003-07-16T17:35:46-0400>
* @version 2.2.1
*
- * A PriorityMutex is similar to a Mutex, with exception that a PriorityMutex
- * has a difference scheduling policy. It is a non-reentrant, priority sensitive
- * MUTual EXclusion Lockable object.
+ * A PriorityMutex is similar to a Mutex, with exception that a PriorityMutex
+ * has a difference scheduling policy. It is a non-reentrant, priority sensitive
+ * MUTual EXclusion Lockable object.
*
* @see Mutex
*
@@ -48,9 +48,9 @@ namespace ZThread {
* with a higher priority will be given access first.
*/
class ZTHREAD_API PriorityMutex : public Lockable, private NonCopyable {
-
+
PriorityMutexImpl* _impl;
-
+
public:
/**
@@ -62,23 +62,23 @@ namespace ZThread {
* @see Mutex::~Mutex()
*/
virtual ~PriorityMutex();
-
+
/**
* @see Mutex::acquire()
*/
- virtual void acquire();
+ virtual void acquire();
/**
* @see Mutex::tryAcquire(unsigned long timeout)
*/
- virtual bool tryAcquire(unsigned long timeout);
-
+ virtual bool tryAcquire(unsigned long timeout);
+
/**
* @see Mutex::release()
*/
virtual void release();
-
- };
+
+ };
} // namespace ZThread
diff --git a/dep/include/zthread/PrioritySemaphore.h b/dep/include/zthread/PrioritySemaphore.h
index 54ef2c48c52..887691f72df 100644
--- a/dep/include/zthread/PrioritySemaphore.h
+++ b/dep/include/zthread/PrioritySemaphore.h
@@ -28,16 +28,16 @@
#include "zthread/NonCopyable.h"
namespace ZThread {
-
+
class PrioritySemaphoreImpl;
-
+
/**
* @class PrioritySemaphore
* @author Eric Crahen <http://www.code-foo.com>
* @date <2003-07-16T15:36:07-0400>
* @version 2.2.1
*
- * A PrioritySemaphore operates in the same way as a Semaphore. Its an owner-less
+ * A PrioritySemaphore operates in the same way as a Semaphore. Its an owner-less
* Lockable object that is sensitive to priority.
*
* <b>Scheduling</b>
@@ -47,17 +47,17 @@ namespace ZThread {
*
* <b>Error Checking</b>
*
- * An attempt to increase a PrioritySemaphore beyond its maximum value will result in
+ * An attempt to increase a PrioritySemaphore beyond its maximum value will result in
* an InvalidOp_Exception.
*
* @see Semaphore
*/
class ZTHREAD_API PrioritySemaphore : public Lockable, private NonCopyable {
-
+
PrioritySemaphoreImpl* _impl;
-
+
public:
-
+
/**
* @see Semaphore::Semaphore(int count, unsigned int maxCount)
*/
@@ -70,19 +70,19 @@ namespace ZThread {
/**
* @see Semaphore::wait()
- */
+ */
void wait();
/**
* @see Semaphore::tryWait(unsigned long)
- */
+ */
bool tryWait(unsigned long);
/**
* @see Semaphore::post()
*/
void post();
-
+
/**
* @see Semaphore::count()
*/
@@ -102,8 +102,8 @@ namespace ZThread {
* @see Semaphore::release()
*/
virtual void release();
-
- };
+
+ };
} // namespace ZThread
diff --git a/dep/include/zthread/Queue.h b/dep/include/zthread/Queue.h
index 98b83a10c63..11a84330b23 100644
--- a/dep/include/zthread/Queue.h
+++ b/dep/include/zthread/Queue.h
@@ -35,7 +35,7 @@ namespace ZThread {
* @version 2.3.0
*
* A Queue defines an interface for a value-oriented collection objects (similar to
- * STL collections).
+ * STL collections).
*/
template <typename T>
class Queue : public Cancelable, private NonCopyable {
@@ -48,7 +48,7 @@ namespace ZThread {
* Add an object to this Queue.
*
* @param item value to be added to the Queue
- *
+ *
* @exception Cancellation_Exception thrown if this Queue has been canceled.
*
* @pre The Queue should not have been canceled prior to the invocation of this function.
@@ -63,8 +63,8 @@ namespace ZThread {
* @param timeout maximum amount of time (milliseconds) this method may block
* the calling thread.
*
- * @return
- * - <em>true</em> if a copy of <i>item</i> can be added before <i>timeout</i>
+ * @return
+ * - <em>true</em> if a copy of <i>item</i> can be added before <i>timeout</i>
* milliseconds elapse.
* - <em>false</em> otherwise.
*
@@ -79,7 +79,7 @@ namespace ZThread {
* Retrieve and remove a value from this Queue.
*
* @return <em>T</em> next available value
- *
+ *
* @exception Cancellation_Exception thrown if this Queue has been canceled.
*
* @pre The Queue should not have been canceled prior to the invocation of this function.
@@ -94,7 +94,7 @@ namespace ZThread {
* the calling thread.
*
* @return <em>T</em> next available value
- *
+ *
* @exception Cancellation_Exception thrown if this Queue has been canceled.
* @exception Timeout_Exception thrown if the timeout expires before a value
* can be retrieved.
@@ -110,28 +110,28 @@ namespace ZThread {
* the next() methods.
*
* Canceling a Queue more than once has no effect.
- *
- * @post The next() methods will continue to return objects until
- * the Queue has been emptied.
+ *
+ * @post The next() methods will continue to return objects until
+ * the Queue has been emptied.
* @post Once emptied, the next() methods will throw a Cancellation_Exception.
* @post The add() methods will throw a Cancellation_Exceptions from this point on.
*/
virtual void cancel() = 0;
/**
- * Count the values present in this Queue.
+ * Count the values present in this Queue.
*
- * @return <em>size_t</em> number of elements available in the Queue.
+ * @return <em>size_t</em> number of elements available in the Queue.
*/
virtual size_t size() = 0;
/**
- * Count the values present in this Queue.
+ * Count the values present in this Queue.
*
* @param timeout maximum amount of time (milliseconds) this method may block
* the calling thread.
*
- * @return <em>size_t</em> number of elements available in the Queue.
+ * @return <em>size_t</em> number of elements available in the Queue.
*
* @exception Timeout_Exception thrown if <i>timeout</i> milliseconds
* expire before a value becomes available
@@ -141,7 +141,7 @@ namespace ZThread {
/**
* Test whether any values are available in this Queue.
*
- * @return
+ * @return
* - <em>true</em> if there are no values available.
* - <em>false</em> if there <i>are</i> values available.
*/
@@ -163,7 +163,7 @@ namespace ZThread {
* @param timeout maximum amount of time (milliseconds) this method may block
* the calling thread.
*
- * @return
+ * @return
* - <em>true</em> if there are no values available.
* - <em>false</em> if there <i>are</i> values available.
*
diff --git a/dep/include/zthread/ReadWriteLock.h b/dep/include/zthread/ReadWriteLock.h
index e01643f1993..38b429b699b 100644
--- a/dep/include/zthread/ReadWriteLock.h
+++ b/dep/include/zthread/ReadWriteLock.h
@@ -27,10 +27,10 @@
#include "zthread/NonCopyable.h"
namespace ZThread {
-
+
/**
* @class ReadWriteLock
- *
+ *
* @author Eric Crahen <http://www.code-foo.com>
* @date <2003-07-16T10:17:31-0400>
* @version 2.2.7
@@ -40,21 +40,21 @@ namespace ZThread {
*
* @see BiasedReadWriteLock
* @see FairReadWriteLock
- */
+ */
class ReadWriteLock : public NonCopyable {
public:
/**
* Create a ReadWriteLock
*
- * @exception Initialization_Exception thrown if resources could not be
+ * @exception Initialization_Exception thrown if resources could not be
* allocated for this object.
*/
ReadWriteLock() {}
-
+
//! Destroy this ReadWriteLock
- virtual ~ReadWriteLock() {}
-
+ virtual ~ReadWriteLock() {}
+
/**
* Get a reference to the read-only Lockable.
*
@@ -71,7 +71,7 @@ namespace ZThread {
*/
virtual Lockable& getWriteLock() = 0;
-
+
}; /* ReadWriteLock */
diff --git a/dep/include/zthread/RecursiveMutex.h b/dep/include/zthread/RecursiveMutex.h
index 7dda9c5119b..25df4484b6b 100644
--- a/dep/include/zthread/RecursiveMutex.h
+++ b/dep/include/zthread/RecursiveMutex.h
@@ -26,8 +26,8 @@
#include "zthread/Lockable.h"
#include "zthread/NonCopyable.h"
-namespace ZThread {
-
+namespace ZThread {
+
class RecursiveMutexImpl;
/**
@@ -37,9 +37,9 @@ namespace ZThread {
* @date <2003-07-16T17:51:33-0400>
* @version 2.2.1
*
- * A RecursiveMutex is a recursive, MUTual EXclusion Lockable object. It is
- * recursive because it can be acquire()d and release()d more than once
- * by the same thread, instead of causing a Deadlock_Exception.
+ * A RecursiveMutex is a recursive, MUTual EXclusion Lockable object. It is
+ * recursive because it can be acquire()d and release()d more than once
+ * by the same thread, instead of causing a Deadlock_Exception.
*
* @see Mutex
* @see Guard
@@ -50,15 +50,15 @@ namespace ZThread {
*
* <b>Error Checking</b>
*
- * A Mutex will throw an InvalidOp_Exception if an attempt to release() a Mutex is
+ * A Mutex will throw an InvalidOp_Exception if an attempt to release() a Mutex is
* made from the context of a thread that does not currently own that Mutex.
*/
class ZTHREAD_API RecursiveMutex : public Lockable, private NonCopyable {
-
+
RecursiveMutexImpl* _impl;
-
+
public:
-
+
//! Create a new RecursiveMutex.
RecursiveMutex();
@@ -66,10 +66,10 @@ namespace ZThread {
virtual ~RecursiveMutex();
/**
- * Acquire a RecursiveMutex, possibly blocking until the the current owner of the
+ * Acquire a RecursiveMutex, possibly blocking until the the current owner of the
* releases it or until an exception is thrown.
*
- * Only one thread may acquire the RecursiveMutex at any given time.
+ * Only one thread may acquire the RecursiveMutex at any given time.
* The same thread may acquire a RecursiveMutex multiple times.
*
* @exception Interrupted_Exception thrown when the calling thread is interrupted.
@@ -80,18 +80,18 @@ namespace ZThread {
*
* @see Lockable::acquire()
*/
- virtual void acquire();
+ virtual void acquire();
/**
- * Acquire a RecursiveMutex, possibly blocking until the the current owner
+ * Acquire a RecursiveMutex, possibly blocking until the the current owner
* releases it, until an exception is thrown or until the given amount
* of time expires.
*
- * Only one thread may acquire the RecursiveMutex at any given time.
+ * Only one thread may acquire the RecursiveMutex at any given time.
* The same thread may acquire a RecursiveMutex multiple times.
*
* @param timeout maximum amount of time (milliseconds) this method could block
- * @return
+ * @return
* - <em>true</em> if the lock was acquired
* - <em>false</em> if the lock was acquired
*
@@ -108,16 +108,16 @@ namespace ZThread {
/**
* Release exclusive access. No safety or state checks are performed.
- *
- * @pre This should not be called more times than the acquire() method was
+ *
+ * @pre This should not be called more times than the acquire() method was
* called.
*
* @see Lockable::release()
*/
virtual void release();
-
- };
-
+
+ };
+
} // namespace ZThread
#endif // __ZTRECURSIVEMUTEX_H__
diff --git a/dep/include/zthread/Runnable.h b/dep/include/zthread/Runnable.h
index 98628530a14..bfe8d03a58f 100644
--- a/dep/include/zthread/Runnable.h
+++ b/dep/include/zthread/Runnable.h
@@ -30,7 +30,7 @@ namespace ZThread {
/**
* @class Runnable
- *
+ *
* @author Eric Crahen <http://www.code-foo.com>
* @date <2003-07-16T17:45:35-0400>
* @version 2.2.11
@@ -51,7 +51,7 @@ namespace ZThread {
virtual void run() = 0;
};
-
+
}
diff --git a/dep/include/zthread/Semaphore.h b/dep/include/zthread/Semaphore.h
index 2a9e4d02d03..b01c77804ba 100644
--- a/dep/include/zthread/Semaphore.h
+++ b/dep/include/zthread/Semaphore.h
@@ -27,16 +27,16 @@
#include "zthread/NonCopyable.h"
namespace ZThread {
-
+
class FifoSemaphoreImpl;
-
+
/**
* @class Semaphore
* @author Eric Crahen <http://www.code-foo.com>
* @date <2003-07-16T15:28:01-0400>
* @version 2.2.1
*
- * A Semaphore is an owner-less Lockable object. Its probably best described as
+ * A Semaphore is an owner-less Lockable object. Its probably best described as
* a set of 'permits'. A Semaphore is initialized with an initial count and
* a maximum count, these would correspond to the number of 'permits' currently
* available and the number of' permits' in total.
@@ -44,28 +44,28 @@ namespace ZThread {
* - Acquiring the Semaphore means taking a permit, but if there are none
* (the count is 0) the Semaphore will block the calling thread.
*
- * - Releasing the Semaphore means returning a permit, unblocking a thread
+ * - Releasing the Semaphore means returning a permit, unblocking a thread
* waiting for one.
*
- * A Semaphore with an initial value of 1 and maximum value of 1 will act as
+ * A Semaphore with an initial value of 1 and maximum value of 1 will act as
* a Mutex.
*
* Threads blocked on a Semaphore are resumed in FIFO order.
*
*/
class ZTHREAD_API Semaphore : public Lockable, private NonCopyable {
-
+
FifoSemaphoreImpl* _impl;
-
+
public:
-
+
/**
- * Create a new Semaphore.
+ * Create a new Semaphore.
*
* @param count initial count
* @param maxCount maximum count
*/
- Semaphore(int count = 1, unsigned int maxCount = 1);
+ Semaphore(int count = 1, unsigned int maxCount = 1);
//! Destroy the Semaphore
virtual ~Semaphore();
@@ -74,8 +74,8 @@ namespace ZThread {
* <i>Provided to reflect the traditional Semaphore semantics</i>
*
* @see acquire()
- */
- void wait();
+ */
+ void wait();
/**
@@ -83,52 +83,52 @@ namespace ZThread {
*
* @see tryAcquire(unsigned long timeout)
*/
- bool tryWait(unsigned long timeout);
+ bool tryWait(unsigned long timeout);
/**
* <i>Provided to reflect the traditional Semaphore semantics</i>
*
* @see release()
*/
- void post();
+ void post();
+
-
/**
- * Get the current count of the semaphore.
+ * Get the current count of the semaphore.
*
* This value may change immediately after this function returns to the calling thread.
*
* @return <em>int</em> count
*/
- virtual int count();
+ virtual int count();
/**
- * Decrement the count, blocking that calling thread if the count becomes 0 or
- * less than 0. The calling thread will remain blocked until the count is
+ * Decrement the count, blocking that calling thread if the count becomes 0 or
+ * less than 0. The calling thread will remain blocked until the count is
* raised above 0, an exception is thrown or the given amount of time expires.
- *
+ *
* @param timeout maximum amount of time (milliseconds) this method could block
- *
- * @return
+ *
+ * @return
* - <em>true</em> if the Semaphore was acquired before <i>timeout</i> milliseconds elapse.
* - <em>false</em> otherwise.
*
* @exception Interrupted_Exception thrown when the calling thread is interrupted.
* A thread may be interrupted at any time, prematurely ending any wait.
- *
+ *
* @see Lockable::tryAcquire(unsigned long timeout)
*/
- virtual bool tryAcquire(unsigned long timeout);
-
+ virtual bool tryAcquire(unsigned long timeout);
+
/**
- * Decrement the count, blocking that calling thread if the count becomes 0 or
- * less than 0. The calling thread will remain blocked until the count is
+ * Decrement the count, blocking that calling thread if the count becomes 0 or
+ * less than 0. The calling thread will remain blocked until the count is
* raised above 0 or if an exception is thrown.
- *
+ *
* @exception Interrupted_Exception thrown when the calling thread is interrupted.
* A thread may be interrupted at any time, prematurely ending any wait.
- *
+ *
* @see Lockable::acquire()
*/
virtual void acquire();
@@ -137,12 +137,12 @@ namespace ZThread {
* Increment the count, unblocking one thread if count is positive.
*
* @exception InvalidOp_Exception thrown if the maximum count would be exceeded.
- *
+ *
* @see Lockable::release()
*/
virtual void release();
-
- };
+
+ };
} // namespace ZThread
diff --git a/dep/include/zthread/Singleton.h b/dep/include/zthread/Singleton.h
index b66c9d0898a..b8f0d1ea842 100644
--- a/dep/include/zthread/Singleton.h
+++ b/dep/include/zthread/Singleton.h
@@ -32,7 +32,7 @@ namespace ZThread {
//
// This policy controls how an object is instantiated
// as well as how and when its destroyed. Phoenix-style
-// singletons are not supported easily with type of policy,
+// singletons are not supported easily with type of policy,
// this is intentional since I do not believe that is in
// the true spirit of a singleton.
//
@@ -46,9 +46,9 @@ namespace ZThread {
* @class LocalStaticInstantiation
* @author Eric Crahen <http://www.code-foo.com>
* @date <2003-07-16T17:57:45-0400>
- * @version 2.2.0
+ * @version 2.2.0
*
- * The LocalStaticInstantiation policy allows the creation
+ * The LocalStaticInstantiation policy allows the creation
* and lifetime of an instance of a particular type
* to be managed using static local values. This will
* abide by the standard C++ rules for static objects
@@ -61,12 +61,12 @@ protected:
* Create an instance of an object, using a local static. The
* object will be destroyed by the system.
*
- * @param ptr reference to location to receive the address
+ * @param ptr reference to location to receive the address
* of the allocated object
*/
template <class T>
static void create(T*& ptr) {
-
+
static T instance;
ptr = &instance;
@@ -91,9 +91,9 @@ class StaticInstantiationHelper {
* @class StaticInstantiation
* @author Eric Crahen <http://www.code-foo.com>
* @date <2003-07-16T17:57:45-0400>
- * @version 2.2.0
+ * @version 2.2.0
*
- * The StaticInstantiation policy allows the creation
+ * The StaticInstantiation policy allows the creation
* and lifetime of an instance of a particular type
* to be managed using static instantiation. This will
* abide by the standard C++ rules for static objects
@@ -105,7 +105,7 @@ protected:
/**
* Create an instance of an object using by simply allocating it statically.
*
- * @param ptr reference to location to receive the address
+ * @param ptr reference to location to receive the address
* of the allocated object
*/
template <class T>
@@ -118,32 +118,32 @@ protected:
//! SingletonDestroyer
template <class T>
class Destroyer {
-
+
T* doomed;
-
+
public:
-
+
Destroyer(T* q) : doomed(q) {
assert(doomed);
}
-
+
~Destroyer();
};
template <class T>
Destroyer<T>::~Destroyer() {
-
+
try {
-
+
if(doomed)
delete doomed;
-
+
} catch(...) { }
-
+
doomed = 0;
-
-}
+
+}
/**
@@ -152,10 +152,10 @@ Destroyer<T>::~Destroyer() {
* @date <2003-07-16T17:57:45-0400>
* @version 2.2.0
*
- * The LazyInstantiation policy allows the creation
+ * The LazyInstantiation policy allows the creation
* and lifetime of an instance of a particular type
* to be managed using dynamic allocation and a singleton
- * destroyer. This will abide by the standard C++ rules
+ * destroyer. This will abide by the standard C++ rules
* for static objects lifetimes.
*/
class LazyInstantiation {
@@ -166,33 +166,33 @@ protected:
* destroyed when an associated Destroyer object (allocated
* statically) goes out of scope.
*
- * @param ptr reference to location to receive the address
+ * @param ptr reference to location to receive the address
* of the allocated object
*/
template <class T>
static void create(T*& ptr) {
-
+
ptr = new T;
static Destroyer<T> destroyer(ptr);
-
+
}
};
-
+
/**
* @class Singleton
* @author Eric Crahen <http://www.code-foo.com>
* @date <2003-07-16T17:57:45-0400>
- * @version 2.2.0
+ * @version 2.2.0
*
* Based on the work of John Vlissidles in his book 'Pattern Hatching'
* an article by Douglas Schmidtt on double-checked locking and policy
* templates described by Andrei Alexandrescu.
*
- * This is a thread safe wrapper for creating Singleton classes. The
+ * This is a thread safe wrapper for creating Singleton classes. The
* synchronization method and instantiation methods can be changed
- * easily by specifying different policy implementations as the
+ * easily by specifying different policy implementations as the
* templates parameters.
*
* @code
@@ -200,7 +200,7 @@ protected:
* // Most common Singleton
* Singletion<LonesomeType>
*
- * // Singleton that uses static storage
+ * // Singleton that uses static storage
* Singletion<LonesomeType, StaticInstantiation>
*
* // Single-threaded singleton that uses static storage (Meyers-like)
@@ -213,9 +213,9 @@ class Singleton : private InstantiationPolicy, private NonCopyable {
public:
/**
- * Provide access to the single instance through double-checked locking
+ * Provide access to the single instance through double-checked locking
*
- * @return T* single instance
+ * @return T* single instance
*/
static T* instance();
@@ -226,19 +226,19 @@ T* Singleton<T, InstantiationPolicy, LockType>::instance() {
// Uses local static storage to avoid static construction
// sequence issues. (regaring when the lock is created)
- static T* ptr = 0;
+ static T* ptr = 0;
static LockType lock;
if(!ptr) {
Guard<LockType, LockedScope> g(lock);
- if(!ptr)
+ if(!ptr)
InstantiationPolicy::create(ptr);
}
-
+
return const_cast<T*>(ptr);
-
+
}
diff --git a/dep/include/zthread/SynchronousExecutor.h b/dep/include/zthread/SynchronousExecutor.h
index b6dbbef6af6..bc9de273c4c 100644
--- a/dep/include/zthread/SynchronousExecutor.h
+++ b/dep/include/zthread/SynchronousExecutor.h
@@ -37,14 +37,14 @@ namespace ZThread {
* @date <2003-07-16T22:33:51-0400>
* @version 2.3.0
*
- * A SynchronousExecutor is an Executor which runs tasks using the thread that
+ * A SynchronousExecutor is an Executor which runs tasks using the thread that
* submits the task. It runs tasks serially, one at a time, in the order they
* were submitted to the executor.
*
* @see Executor.
*/
class SynchronousExecutor : public Executor {
-
+
//! Serialize access
Mutex _lock;
@@ -65,10 +65,10 @@ namespace ZThread {
virtual void interrupt();
/**
- * Submit a task to this Executor, blocking the calling thread until the
- * task is executed.
+ * Submit a task to this Executor, blocking the calling thread until the
+ * task is executed.
*
- * @param task Task to be run by a thread managed by this executor
+ * @param task Task to be run by a thread managed by this executor
*
* @pre The Executor should have been canceled prior to this invocation.
* @post The submitted task will be run at some point in the future by this Executor.
@@ -84,12 +84,12 @@ namespace ZThread {
* @see Cancelable::cancel()
*/
virtual void cancel();
-
+
/**
* @see Cancelable::cancel()
*/
virtual bool isCanceled();
-
+
/**
* Block the calling thread until all tasks submitted prior to this invocation
* complete.
@@ -105,14 +105,14 @@ namespace ZThread {
* Block the calling thread until all tasks submitted prior to this invocation
* complete or until the calling thread is interrupted.
*
- * @param timeout - maximum amount of time, in milliseconds, to wait for the
+ * @param timeout - maximum amount of time, in milliseconds, to wait for the
* currently submitted set of Tasks to complete.
*
* @exception Interrupted_Exception thrown if the calling thread is interrupted
* before the set of tasks being wait for can complete.
*
- * @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> othewise.
*/
diff --git a/dep/include/zthread/Task.h b/dep/include/zthread/Task.h
index 6503be66f33..850ab98c043 100644
--- a/dep/include/zthread/Task.h
+++ b/dep/include/zthread/Task.h
@@ -27,9 +27,9 @@
#include "zthread/Runnable.h"
namespace ZThread {
-
+
class ThreadImpl;
-
+
/**
* @class Task
*
@@ -37,9 +37,9 @@ namespace ZThread {
* @date <2003-07-20T05:22:38-0400>
* @version 2.3.0
*
- * A Task provides a CountedPtr wrapper for Runnable objects.
- * This wrapper enables an implicit conversion from a
- * <i>Runnable*</i> to a <i>Task</i> adding some syntactic sugar
+ * A Task provides a CountedPtr wrapper for Runnable objects.
+ * This wrapper enables an implicit conversion from a
+ * <i>Runnable*</i> to a <i>Task</i> adding some syntactic sugar
* to the interface.
*/
class ZTHREAD_API Task : public CountedPtr<Runnable, AtomicCount> {
@@ -47,29 +47,29 @@ namespace ZThread {
#if !defined(_MSC_VER) || (_MSC_VER > 1200)
-
+
Task(Runnable* raw)
- : CountedPtr<Runnable, AtomicCount>(raw) { }
+ : CountedPtr<Runnable, AtomicCount>(raw) { }
#endif
-
+
template <typename U>
Task(U* raw)
- : CountedPtr<Runnable, AtomicCount>(raw) { }
-
- Task(const CountedPtr<Runnable, AtomicCount>& ptr)
- : CountedPtr<Runnable, AtomicCount>(ptr) { }
-
+ : CountedPtr<Runnable, AtomicCount>(raw) { }
+
+ Task(const CountedPtr<Runnable, AtomicCount>& ptr)
+ : CountedPtr<Runnable, AtomicCount>(ptr) { }
+
template <typename U, typename V>
- Task(const CountedPtr<U, V>& ptr)
- : CountedPtr<Runnable, AtomicCount>(ptr) { }
-
+ Task(const CountedPtr<U, V>& ptr)
+ : CountedPtr<Runnable, AtomicCount>(ptr) { }
+
void operator()() {
(*this)->run();
}
-
+
}; /* Task */
-
+
} // namespace ZThread
#endif // __ZTTASK_H__
diff --git a/dep/include/zthread/Thread.h b/dep/include/zthread/Thread.h
index e1700c737fa..23ecd1af4bf 100644
--- a/dep/include/zthread/Thread.h
+++ b/dep/include/zthread/Thread.h
@@ -30,9 +30,9 @@
#include "zthread/Waitable.h"
namespace ZThread {
-
+
class ThreadImpl;
-
+
/**
* @class Thread
* @author Eric Crahen <http://www.code-foo.com>
@@ -50,8 +50,8 @@ namespace ZThread {
*
* <h2><a name="ex1">Launching a task</a></h2>
*
- * A thread is started simply by constructing a thread object and giving
- * it a task to perform. The thread will continue to run its task, even
+ * A thread is started simply by constructing a thread object and giving
+ * it a task to perform. The thread will continue to run its task, even
* after the Thread object used to launch the thread has gone out of scope.
*
* @code
@@ -74,12 +74,12 @@ namespace ZThread {
* int main() {
*
* try {
- *
+ *
* // Implictly constructs a Task
* Thread t(new aRunnable);
*
- * } catch(Synchronization_Exception& e) {
- * std::cerr << e.what() << std::endl;
+ * } catch(Synchronization_Exception& e) {
+ * std::cerr << e.what() << std::endl;
* }
*
* std::cout << "Hello from the main thread" << std::endl;
@@ -121,13 +121,13 @@ namespace ZThread {
* int main() {
*
* try {
- *
+ *
* // Implictly constructs a Task
* Thread t(new aRunnable);
* t.wait();
*
- * } catch(Synchronization_Exception& e) {
- * std::cerr << e.what() << std::endl;
+ * } catch(Synchronization_Exception& e) {
+ * std::cerr << e.what() << std::endl;
* }
*
* std::cout << "Hello from the main thread" << std::endl;
@@ -169,7 +169,7 @@ namespace ZThread {
* int main() {
*
* try {
- *
+ *
* // Explictly constructs a Task
* Task task(new aRunnable);
*
@@ -177,8 +177,8 @@ namespace ZThread {
* Thread t1(task);
* Thread t2(task);
*
- * } catch(Synchronization_Exception& e) {
- * std::cerr << e.what() << std::endl;
+ * } catch(Synchronization_Exception& e) {
+ * std::cerr << e.what() << std::endl;
* }
*
* std::cout << "Hello from the main thread" << std::endl;
@@ -195,7 +195,7 @@ namespace ZThread {
*
* @endcode
*/
- class ZTHREAD_API Thread
+ class ZTHREAD_API Thread
: public Cancelable, public Waitable, public NonCopyable {
//! Delegate
@@ -212,7 +212,7 @@ namespace ZThread {
/**
* Create a Thread that spawns a new thread to run the given task.
*
- * @param task Task to be run by a thread managed by this executor
+ * @param task Task to be run by a thread managed by this executor
* @param autoCancel flag to requestion automatic cancellation
*
* @post if the <i>autoCancel</i> flag was true, this thread will
@@ -241,17 +241,17 @@ namespace ZThread {
* @exception Interrupted_Exception thrown if the joining thread has been interrupt()ed
*/
void wait();
-
+
/**
* Wait for the thread represented by this object to complete its task.
* The calling thread is blocked until the thread represented by this
* object exits, or until the timeout expires.
*
- * @param timeout maximum amount of time (milliseconds) this method
+ * @param timeout maximum amount of time (milliseconds) this method
* could block the calling thread.
*
- * @return
- * - <em>true</em> if the thread task complete before <i>timeout</i>
+ * @return
+ * - <em>true</em> if the thread task complete before <i>timeout</i>
* milliseconds elapse.
* - <em>false</em> othewise.
*
@@ -260,10 +260,10 @@ namespace ZThread {
* @exception Interrupted_Exception thrown if the joining thread has been interrupt()ed
*/
bool wait(unsigned long timeout);
-
+
/**
* Change the priority of this Thread. This will change the actual
- * priority of the thread when the OS supports it.
+ * priority of the thread when the OS supports it.
*
* If there is no real priority support, it's simulated.
*
@@ -280,18 +280,18 @@ namespace ZThread {
/**
* Interrupts this thread, setting the <i>interrupted</i> status of the thread.
- * This status is cleared by one of three methods.
+ * This status is cleared by one of three methods.
*
* If this thread is blocked when this method is called, the thread will
* abort that blocking operation with an Interrupted_Exception.
*
* - The first is by attempting an operation on a synchronization object that
- * would normally block the calling thread; Instead of blocking the calling
+ * would normally block the calling thread; Instead of blocking the calling
* the calling thread, the function that would normally block will thrown an
* Interrupted_Exception and clear the <i>interrupted</i> status of the thread.
*
* - The second is by calling Thread::interrupted().
- *
+ *
* - The third is by calling Thread::canceled().
*
* Threads already blocked by an operation on a synchronization object will abort
@@ -300,7 +300,7 @@ namespace ZThread {
*
* Interrupting a thread that is no longer running will have no effect.
*
- * @return
+ * @return
* - <em>true</em> if the thread was interrupted while not blocked by a wait
* on a synchronization object.
* - <em>false</em> othewise.
@@ -311,11 +311,11 @@ namespace ZThread {
* Tests whether the current Thread has been interrupt()ed, clearing
* its interruption status.
*
- * @return
+ * @return
* - <em>true</em> if the Thread was interrupted.
* - <em>false</em> otherwise.
*
- * @post The <i>interrupted</i> status of the current thread will be cleared,
+ * @post The <i>interrupted</i> status of the current thread will be cleared,
* allowing it to perform a blocking operation on a synchronization
* object without throwing an exception.
*/
@@ -333,16 +333,16 @@ namespace ZThread {
* Tests whether this thread has been canceled. If called from the context
* of this thread, the interrupted status is cleared.
*
- * @return
+ * @return
* - <em>true</em> if the Thread was canceled.
* - <em>false</em> otherwise.
- *
+ *
* @see Cancelable::isCanceled()
*/
virtual bool isCanceled();
/**
- * Interrupt and cancel this thread in a single operation. The thread will
+ * Interrupt and cancel this thread in a single operation. The thread will
* return <em>true</em> whenever its cancelation status is tested in the future.
*
* @exception InvalidOp_Exception thrown if a thread attempts to cancel itself
diff --git a/dep/include/zthread/ThreadLocal.h b/dep/include/zthread/ThreadLocal.h
index bb83a0fe3ef..7cccab4ca69 100644
--- a/dep/include/zthread/ThreadLocal.h
+++ b/dep/include/zthread/ThreadLocal.h
@@ -34,30 +34,30 @@ namespace ZThread {
* @date <2003-07-27T11:18:21-0400>
* @version 2.3.0
*
- * Provides access to store and retrieve value types to and from a thread local
+ * Provides access to store and retrieve value types to and from a thread local
* storage context. A thread local storage context consists of the calling thread
* a specific ThreadLocal object. Since this context is specific to each thread
- * whenever a value is stored in a ThreadLocal that is accessible from multiple
- * threads, it can only be retrieved by the thread that stored it.
+ * whenever a value is stored in a ThreadLocal that is accessible from multiple
+ * threads, it can only be retrieved by the thread that stored it.
*
* The first time a thread accesses the value associated with a thread local storage
- * context, a value is created. That value is either an initial value (determined by
+ * context, a value is created. That value is either an initial value (determined by
* InitialValueT) or an inherited value (determined by ChildValueT).
*
* - If a threads parent had no value associated with a ThreadLocal when the thread was created,
* then the InitialValueT functor is used to create an initial value.
*
- * - If a threads parent did have a value associated with a ThreadLocal when the thread was
+ * - If a threads parent did have a value associated with a ThreadLocal when the thread was
* created, then the childValueT functor is used to create an initial value.
*
* Not all ThreadLocal's support the inheritance of values from parent threads. The default
* behavoir is to create values through the InitialValueT functor for all thread when
- * they first access a thread local storage context.
- *
+ * they first access a thread local storage context.
+ *
* - Inheritance is enabled automatically when a user supplies a ChildValueT functor other
* than the default one supplied.
*
- * - Inheritance can be controlled explicitly by the user through a third functor,
+ * - Inheritance can be controlled explicitly by the user through a third functor,
* InheritableValueT.
*
* <h2>Examples</h2>
@@ -68,9 +68,9 @@ namespace ZThread {
*
* <h2><a name="ex1">Default initial value</a></h2>
* A ThreadLocal that does not inherit, and uses the default value
- * for an int as its initial value.
+ * for an int as its initial value.
*
- * @code
+ * @code
*
* #include "zthread/ThreadLocal.h"
* #include "zthread/Thread.h"
@@ -82,7 +82,7 @@ namespace ZThread {
* ThreadLocal<int> localValue;
* public:
* void run() {
- * std::cout << localValue.get() << std::endl;
+ * std::cout << localValue.get() << std::endl;
* }
* };
*
@@ -110,7 +110,7 @@ namespace ZThread {
* <h2><a name="ex2">User-specified initial value</a></h2>
* A ThreadLocal that does not inherit, and uses a custom initial value.
*
- * @code
+ * @code
*
* #include "zthread/ThreadLocal.h"
* #include "zthread/Thread.h"
@@ -119,10 +119,10 @@ namespace ZThread {
* using namespace ZThread;
*
* struct anInitialValueFn {
- * int operator()() {
+ * int operator()() {
* static int next = 100;
* int val = next; next += 100;
- * return val;
+ * return val;
* }
* };
*
@@ -130,7 +130,7 @@ namespace ZThread {
* ThreadLocal<int, anInitialValueFn> localValue;
* public:
* void run() {
- * std::cout << localValue.get() << std::endl;
+ * std::cout << localValue.get() << std::endl;
* }
* };
*
@@ -156,10 +156,10 @@ namespace ZThread {
* @endcode
*
* <h2><a name="ex3">User-specified inherited value</a></h2>
- * A ThreadLocal that does inherit and modify child values.
+ * A ThreadLocal that does inherit and modify child values.
* (The default initial value functor is used)
*
- * @code
+ * @code
*
* #include "zthread/ThreadLocal.h"
* #include "zthread/Thread.h"
@@ -168,18 +168,18 @@ namespace ZThread {
* using namespace ZThread;
*
* struct anInheritedValueFn {
- * int operator()(int val) {
- * return val + 100;
+ * int operator()(int val) {
+ * return val + 100;
* }
* };
*
- * // This Runnable associates no ThreadLocal value in the main thread; so
+ * // This Runnable associates no ThreadLocal value in the main thread; so
* // none of the child threads have anything to inherit.
* class aRunnable : public Runnable {
* ThreadLocal<int, ThreadLocalImpl::InitialValueFn<int>, anInheritedValueFn> localValue;
* public:
* void run() {
- * std::cout << localValue.get() << std::endl;
+ * std::cout << localValue.get() << std::endl;
* }
* };
*
@@ -188,11 +188,11 @@ namespace ZThread {
* class anotherRunnable : public Runnable {
* ThreadLocal<int, ThreadLocalImpl::InitialValueFn<int>, anInheritedValueFn> localValue;
* public:
- * anotherRunnable() {
+ * anotherRunnable() {
* localValue.set(100);
* }
* void run() {
- * std::cout << localValue.get() << std::endl;
+ * std::cout << localValue.get() << std::endl;
* }
* };
*
@@ -238,7 +238,7 @@ namespace ZThread {
*
* <code>
* // required operator
- * T operator()
+ * T operator()
*
* // supported expression
* InitialValueT()()
@@ -249,12 +249,12 @@ namespace ZThread {
*
* This template parameter should indicate the functor used to set
* the value that will be inherited by thread whose parent have associated
- * a value with the ThreadLocal's context at the time they are created.
+ * a value with the ThreadLocal's context at the time they are created.
* It should support the following operator:
*
* <code>
* // required operator
- * T operator(const T& parentValue)
+ * T operator(const T& parentValue)
*
* // supported expression
* ChildValueT()(parentValue)
@@ -270,7 +270,7 @@ namespace ZThread {
*
* <code>
* // required operator
- * bool operator(const T& childValueFunctor)
+ * bool operator(const T& childValueFunctor)
*
* // supported expression
* InheritableValueT()( ChildValueT() )
@@ -278,9 +278,9 @@ namespace ZThread {
*
*/
template <
- typename T,
+ typename T,
typename InitialValueT = ThreadLocalImpl::InitialValueFn<T>,
- typename ChildValueT = ThreadLocalImpl::UniqueChildValueFn,
+ typename ChildValueT = ThreadLocalImpl::UniqueChildValueFn,
typename InheritableValueT = ThreadLocalImpl::InheritableValueFn
>
class ThreadLocal : private ThreadLocalImpl {
@@ -288,39 +288,39 @@ namespace ZThread {
typedef ThreadLocalImpl::ValuePtr ValuePtr;
class Value : public ThreadLocalImpl::Value {
-
+
T value;
-
+
public:
-
+
Value() : value( InitialValueT()() ) { }
-
+
Value(const Value& v) : value( ChildValueT()(v.value) ) { }
-
- virtual ~Value() { }
-
+
+ virtual ~Value() { }
+
operator T() { return value; }
-
+
const Value& operator=(const T& v) { value = v; }
-
+
virtual bool isInheritable() const {
return InheritableValueT()( ChildValueT() );
}
-
+
virtual ValuePtr clone() const {
return ValuePtr( new Value(*this) );
}
-
+
};
-
+
static ValuePtr createValue() {
return ValuePtr( new Value );
}
-
+
public:
/**
- * Get the value associated with the context (this ThreadLocal and
+ * Get the value associated with the context (this ThreadLocal and
* the calling thread) of the invoker. If no value is currently
* associated, then an intial value is created and associated; that value
* is returned.
@@ -329,14 +329,14 @@ namespace ZThread {
*
* @post If no value has been associated with the invoking context
* then an inital value will be associated. That value is
- * created by the <em>InitialValueT</em> functor.
+ * created by the <em>InitialValueT</em> functor.
*/
- T get() const {
+ T get() const {
return (T)reinterpret_cast<Value&>( *value(&createValue) );
}
-
+
/**
- * Replace the value associated with the context (this ThreadLocal and
+ * Replace the value associated with the context (this ThreadLocal and
* the calling thread) of the invoker. If no value is currently
* associated, then an intial value is first created and subsequently
* replaced by the new value.
@@ -345,18 +345,18 @@ namespace ZThread {
*
* @post If no value has been associated with the invoking context
* then an inital value will first be associated. That value is
- * created by the <em>InitialValueT</em> functor and then
- * replaced with the new value.
+ * created by the <em>InitialValueT</em> functor and then
+ * replaced with the new value.
*/
void set(T v) const {
reinterpret_cast<Value&>( *value(&createValue) ) = v;
}
/**
- * Remove any value current associated with this ThreadLocal.
- *
- * @post Upon thier next invocation the get() and set() functions will behave as
- * if no value has been associated with this ThreadLocal and an
+ * Remove any value current associated with this ThreadLocal.
+ *
+ * @post Upon thier next invocation the get() and set() functions will behave as
+ * if no value has been associated with this ThreadLocal and an
* initial value will be generated.
*/
void clear() const {
@@ -364,10 +364,10 @@ namespace ZThread {
}
/**
- * Remove any value current associated with <em>any</em> ThreadLocal.
- *
- * @post Upon thier next invocation the get() and set() functions will behave as
- * if no value has been associated with <em>any</em> ThreadLocal and new
+ * Remove any value current associated with <em>any</em> ThreadLocal.
+ *
+ * @post Upon thier next invocation the get() and set() functions will behave as
+ * if no value has been associated with <em>any</em> ThreadLocal and new
* initial values will be generated.
*/
static void clearAll() {
diff --git a/dep/include/zthread/ThreadLocalImpl.h b/dep/include/zthread/ThreadLocalImpl.h
index 3b4046f8f58..be000dfa695 100644
--- a/dep/include/zthread/ThreadLocalImpl.h
+++ b/dep/include/zthread/ThreadLocalImpl.h
@@ -35,7 +35,7 @@ namespace ZThread {
*
* @see ThreadLocal
*/
- class ZTHREAD_API ThreadLocalImpl : private NonCopyable {
+ class ZTHREAD_API ThreadLocalImpl : private NonCopyable {
public:
class Value;
@@ -52,17 +52,17 @@ namespace ZThread {
//! Create a ThreadLocalImpl
ThreadLocalImpl();
-
+
//! Destroy a ThreadLocalImpl
~ThreadLocalImpl();
-
+
/**
* @class InitialValueFn
*/
template <typename T>
- struct InitialValueFn {
+ struct InitialValueFn {
T operator()() { return T(); }
- };
+ };
/**
* @class ChildValueFn
@@ -71,18 +71,18 @@ namespace ZThread {
template <typename T>
T operator()(const T& value) { return T(value); }
};
-
+
/**
* @class UniqueChildValueFn
*/
struct UniqueChildValueFn : public ChildValueFn { };
-
+
/**
* @class InheritableValueFn
*/
struct InheritableValueFn {
- template <typename T>
+ template <typename T>
bool operator()(const T&) { return true; }
bool operator()(const UniqueChildValueFn&) { return false; }
diff --git a/dep/include/zthread/ThreadedExecutor.h b/dep/include/zthread/ThreadedExecutor.h
index 9bc29b3c497..469a112f6bc 100644
--- a/dep/include/zthread/ThreadedExecutor.h
+++ b/dep/include/zthread/ThreadedExecutor.h
@@ -40,21 +40,21 @@ namespace ZThread {
* A ThreadedExecutor spawns a new thread to execute each task submitted.
* A ThreadedExecutor supports the following optional operations,
*
- * - <em>cancel</em>()ing a ThreadedExecutor will cause it to stop accepting
- * new tasks.
+ * - <em>cancel</em>()ing a ThreadedExecutor will cause it to stop accepting
+ * new tasks.
*
- * - <em>interrupt</em>()ing a ThreadedExecutor will cause the any thread running
- * a task which was submitted prior to the invocation of this function to
+ * - <em>interrupt</em>()ing a ThreadedExecutor will cause the any thread running
+ * a task which was submitted prior to the invocation of this function to
* be interrupted during the execution of that task.
*
- * - <em>wait</em>()ing on a ThreadedExecutor will block the calling thread
+ * - <em>wait</em>()ing on a ThreadedExecutor will block the calling thread
* until all tasks that were submitted prior to the invocation of this function
* have completed.
- *
+ *
* @see Executor.
*/
class ThreadedExecutor : public Executor {
-
+
CountedPtr< ExecutorImpl > _impl;
public:
@@ -68,16 +68,16 @@ namespace ZThread {
/**
* Interrupting a ThreadedExecutor will cause an interrupt() to be sent
* to every Task that has been submitted at the time this function is
- * called. Tasks that are submitted after this function is called will
+ * called. Tasks that are submitted after this function is called will
* not be interrupt()ed; unless this function is invoked again().
*/
virtual void interrupt();
-
+
/**
- * Submit a task to this Executor. This will not block the current thread
+ * Submit a task to this Executor. This will not block the current thread
* for very long. A new thread will be created and the task will be run()
* within the context of that new thread.
- *
+ *
* @exception Cancellation_Exception thrown if this Executor has been canceled.
* The Task being submitted will not be executed by this Executor.
*
@@ -89,12 +89,12 @@ namespace ZThread {
* @see Cancelable::cancel()
*/
virtual void cancel();
-
+
/**
* @see Cancelable::isCanceled()
*/
virtual bool isCanceled();
-
+
/**
* Waiting on a ThreadedExecutor will block the current thread until all
* tasks submitted to the Executor up until the time this function was called
@@ -112,15 +112,15 @@ namespace ZThread {
virtual void wait();
/**
- * Operates the same as ThreadedExecutor::wait() but with a timeout.
+ * Operates the same as ThreadedExecutor::wait() but with a timeout.
*
- * @param timeout maximum amount of time, in milliseconds, to wait for the
+ * @param timeout maximum amount of time, in milliseconds, to wait for the
* currently submitted set of Tasks to complete.
*
* @exception Interrupted_Exception thrown if the calling thread is interrupt()ed
* while waiting for the current set of Tasks to complete.
*
- * @return
+ * @return
* - <em>true</em> if the set of tasks running at the time this function is invoked complete
* before <i>timeout</i> milliseconds elapse.
* - <em>false</em> othewise.
diff --git a/dep/include/zthread/Waitable.h b/dep/include/zthread/Waitable.h
index 3d925f2a691..17260370316 100644
--- a/dep/include/zthread/Waitable.h
+++ b/dep/include/zthread/Waitable.h
@@ -25,7 +25,7 @@
#include "zthread/Exceptions.h"
-namespace ZThread {
+namespace ZThread {
/**
* @class Waitable
@@ -35,21 +35,21 @@ namespace ZThread {
* @version 2.3.0
*
* The Waitable interface defines a common method of adding generic <i>wait</i> semantics
- * to a class.
+ * to a class.
*
* <b>Waiting</b>
*
* An object implementing the Waitable interface externalizes a mechanism for testing
- * some internal condition. Another object may <i>wait()</i>s for a Waitable object;
- * in doing so, it wait()s for that condition to become true by blocking the caller
+ * some internal condition. Another object may <i>wait()</i>s for a Waitable object;
+ * in doing so, it wait()s for that condition to become true by blocking the caller
* while the condition is false.
*
* For example, a Condition is Waitable object that extends <i>wait</i> semantics
- * so that wait()ing means a thread is blocked until some external stimulus
- * specifically performs an operation on the Condition to make its internal condition true.
+ * so that wait()ing means a thread is blocked until some external stimulus
+ * specifically performs an operation on the Condition to make its internal condition true.
* (serialization aside)
*
- * A Barrier extends <i>wait</i> semantics so that wait()ing mean waiting for other
+ * A Barrier extends <i>wait</i> semantics so that wait()ing mean waiting for other
* waiters, and may include automatically resetting the condition once a wait is complete.
*
* @see Condition
@@ -57,9 +57,9 @@ namespace ZThread {
* @see Executor
*/
class Waitable {
- public:
-
- //! Destroy a Waitable object.
+ public:
+
+ //! Destroy a Waitable object.
virtual ~Waitable() {}
/**
@@ -78,14 +78,14 @@ namespace ZThread {
*
* @param timeout maximum amount of time, in milliseconds, to spend waiting.
*
- * @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> othewise.
*/
virtual bool wait(unsigned long timeout) = 0;
-
+
}; /* Waitable */