activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r796317 [1/3] - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/ main/activemq/core/ main/decaf/internal/io/ main/decaf/internal/util/ main/decaf/internal/util/concurrent/ main/decaf/io/ main/decaf/net/ main/decaf/util/ main/decaf/ut...
Date Tue, 21 Jul 2009 14:28:12 GMT
Author: tabish
Date: Tue Jul 21 14:28:11 2009
New Revision: 796317

URL: http://svn.apache.org/viewvc?rev=796317&view=rev
Log:
Refactored the Synchronizbale interface a bit to make the param a long long and to add a new wait method that takes a long long and an int value for nanoseconds.  Added a start on a PriorityQueue implementation.  Added a new Timer class that mimics the Java Timer class and added the TimerTask interface that goes along with it.  Performed some other API documentation cleanup.

Added:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/TimerTaskHeap.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/TimerTaskHeap.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/SynchronizableImpl.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/SynchronizableImpl.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/PriorityQueue.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Timer.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Timer.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/TimerTask.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/TimerTask.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/comparators/
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/comparators/Less.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/ExecutorService.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/util/TimerTaskHeapTest.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/util/TimerTaskHeapTest.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/PriorityQueueTest.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/PriorityQueueTest.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/TimerTest.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/TimerTest.h   (with props)
Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/MessageDispatchChannel.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/io/StandardErrorOutputStream.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/io/StandardInputStream.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/io/StandardOutputStream.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/BlockingByteArrayInputStream.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterInputStream.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterOutputStream.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/AbstractCollection.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Map.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Queue.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StlMap.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StlQueue.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Callable.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Concurrent.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Lock.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/RejectedExecutionException.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Synchronizable.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/BufferedInputStreamTest.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/BufferedOutputStreamTest.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/FilterInputStreamTest.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/StlMapTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/MutexTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/testRegistry.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?rev=796317&r1=796316&r2=796317&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Tue Jul 21 14:28:11 2009
@@ -120,6 +120,7 @@
     activemq/transport/failover/FailoverTransportFactory.cpp \
     activemq/transport/failover/FailoverTransportListener.cpp \
     activemq/transport/failover/URIPool.cpp \
+    activemq/transport/inactivity/InactivityMonitor.cpp \
     activemq/transport/logging/LoggingTransport.cpp \
     activemq/transport/mock/InternalCommandListener.cpp \
     activemq/transport/mock/MockTransport.cpp \
@@ -365,6 +366,8 @@
     decaf/internal/nio/ShortArrayBuffer.cpp \
     decaf/internal/util/ByteArrayAdapter.cpp \
     decaf/internal/util/HexStringParser.cpp \
+    decaf/internal/util/TimerTaskHeap.cpp \
+    decaf/internal/util/concurrent/SynchronizableImpl.cpp \
     decaf/io/BlockingByteArrayInputStream.cpp \
     decaf/io/BufferedInputStream.cpp \
     decaf/io/BufferedOutputStream.cpp \
@@ -407,6 +410,8 @@
     decaf/util/Properties.cpp \
     decaf/util/Random.cpp \
     decaf/util/StringTokenizer.cpp \
+    decaf/util/Timer.cpp \
+    decaf/util/TimerTask.cpp \
     decaf/util/UUID.cpp \
     decaf/util/concurrent/CountDownLatch.cpp \
     decaf/util/concurrent/Mutex.cpp \
@@ -556,6 +561,7 @@
     activemq/transport/failover/FailoverTransportFactory.h \
     activemq/transport/failover/FailoverTransportListener.h \
     activemq/transport/failover/URIPool.h \
+    activemq/transport/inactivity/InactivityMonitor.h \
     activemq/transport/logging/LoggingTransport.h \
     activemq/transport/mock/InternalCommandListener.h \
     activemq/transport/mock/MockTransport.h \
@@ -836,6 +842,8 @@
     decaf/internal/nio/ShortArrayBuffer.h \
     decaf/internal/util/ByteArrayAdapter.h \
     decaf/internal/util/HexStringParser.h \
+    decaf/internal/util/TimerTaskHeap.h \
+    decaf/internal/util/concurrent/SynchronizableImpl.h \
     decaf/io/BlockingByteArrayInputStream.h \
     decaf/io/BufferedInputStream.h \
     decaf/io/BufferedOutputStream.h \
@@ -938,6 +946,7 @@
     decaf/util/List.h \
     decaf/util/ListIterator.h \
     decaf/util/Map.h \
+    decaf/util/PriorityQueue.h \
     decaf/util/Properties.h \
     decaf/util/Queue.h \
     decaf/util/Random.h \
@@ -947,7 +956,10 @@
     decaf/util/StlQueue.h \
     decaf/util/StlSet.h \
     decaf/util/StringTokenizer.h \
+    decaf/util/Timer.h \
+    decaf/util/TimerTask.h \
     decaf/util/UUID.h \
+    decaf/util/comparators/Less.h \
     decaf/util/concurrent/BrokenBarrierException.h \
     decaf/util/concurrent/Callable.h \
     decaf/util/concurrent/CancellationException.h \
@@ -958,6 +970,7 @@
     decaf/util/concurrent/Delayed.h \
     decaf/util/concurrent/ExecutionException.h \
     decaf/util/concurrent/Executor.h \
+    decaf/util/concurrent/ExecutorService.h \
     decaf/util/concurrent/Future.h \
     decaf/util/concurrent/Lock.h \
     decaf/util/concurrent/Mutex.h \

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/MessageDispatchChannel.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/MessageDispatchChannel.h?rev=796317&r1=796316&r2=796317&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/MessageDispatchChannel.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/MessageDispatchChannel.h Tue Jul 21 14:28:11 2009
@@ -155,10 +155,14 @@
             channel.wait();
         }
 
-        virtual void wait( unsigned long millisecs ) throw( decaf::lang::Exception ) {
+        virtual void wait( long long millisecs ) throw( decaf::lang::Exception ) {
             channel.wait( millisecs );
         }
 
+        virtual void wait( long long millisecs, int nanos ) throw( decaf::lang::Exception ) {
+            channel.wait( millisecs, nanos );
+        }
+
         virtual void notify() throw( decaf::lang::Exception ){
             channel.notify();
         }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/io/StandardErrorOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/io/StandardErrorOutputStream.h?rev=796317&r1=796316&r2=796317&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/io/StandardErrorOutputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/io/StandardErrorOutputStream.h Tue Jul 21 14:28:11 2009
@@ -105,7 +105,7 @@
             mutex.wait();
         }
 
-        virtual void wait( unsigned long millisecs ) throw( decaf::lang::Exception ){
+        virtual void wait( long long millisecs ) throw( decaf::lang::Exception ){
             mutex.wait( millisecs );
         }
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/io/StandardInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/io/StandardInputStream.h?rev=796317&r1=796316&r2=796317&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/io/StandardInputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/io/StandardInputStream.h Tue Jul 21 14:28:11 2009
@@ -157,7 +157,7 @@
             mutex.wait();
         }
 
-        virtual void wait( unsigned long millisecs ) throw( lang::Exception ){
+        virtual void wait( long long millisecs ) throw( lang::Exception ){
             mutex.wait( millisecs );
         }
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/io/StandardOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/io/StandardOutputStream.h?rev=796317&r1=796316&r2=796317&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/io/StandardOutputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/io/StandardOutputStream.h Tue Jul 21 14:28:11 2009
@@ -96,7 +96,7 @@
             mutex.wait();
         }
 
-        virtual void wait( unsigned long millisecs ) throw( decaf::lang::Exception ){
+        virtual void wait( long long millisecs ) throw( decaf::lang::Exception ){
             mutex.wait( millisecs );
         }
 

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/TimerTaskHeap.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/TimerTaskHeap.cpp?rev=796317&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/TimerTaskHeap.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/TimerTaskHeap.cpp Tue Jul 21 14:28:11 2009
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "TimerTaskHeap.h"
+
+using namespace decaf;
+using namespace decaf::internal;
+using namespace decaf::internal::util;
+
+////////////////////////////////////////////////////////////////////////////////
+TimerTaskHeap::TimerTaskHeap() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+TimerTaskHeap::~TimerTaskHeap() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Pointer<TimerTask> TimerTaskHeap::peek() {
+
+    if( heap.empty() ) {
+        return Pointer<TimerTask>();
+    }
+
+    return heap[0];
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool TimerTaskHeap::isEmpty() const {
+    return heap.empty();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t TimerTaskHeap::size() const {
+    return this->heap.size();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TimerTaskHeap::insert( const Pointer<TimerTask>& task ) {
+
+    heap.push_back( task );
+    upHeap();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TimerTaskHeap::remove( std::size_t pos ) {
+
+    // possible to delete any position of the heap
+    if( pos < heap.size() ) {
+        heap[pos] = heap.back();
+        heap.pop_back();
+        downHeap( pos );
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TimerTaskHeap::upHeap() {
+
+    int current = heap.size() - 1;
+    int parent = ( current - 1 ) / 2;
+
+    while( heap[current]->when < heap[parent]->when) {
+
+        // swap the two
+        Pointer<TimerTask> tmp = heap[current];
+        heap[current] = heap[parent];
+        heap[parent] = tmp;
+
+        // update parent and current positions.
+        current = parent;
+        parent = ( current - 1 ) / 2;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TimerTaskHeap::downHeap( std::size_t pos ) {
+
+    std::size_t current = pos;
+    std::size_t child = 2 * current + 1;
+
+    while( child < heap.size() && !heap.empty() ) {
+
+        // compare the children if they exist
+        if( child + 1 < heap.size() && heap[child + 1]->when < heap[child]->when) {
+            child++;
+        }
+
+        // compare selected child with parent
+        if( heap[current]->when < heap[child]->when ) {
+            break;
+        }
+
+        // swap the two
+        Pointer<TimerTask> tmp = heap[current];
+        heap[current] = heap[child];
+        heap[child] = tmp;
+
+        // update child and current positions
+        current = child;
+        child = 2 * current + 1;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TimerTaskHeap::reset() {
+    heap.clear();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TimerTaskHeap::adjustMinimum() {
+    downHeap( 0 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t TimerTaskHeap::deleteIfCancelled() {
+
+    std::size_t result = 0;
+
+    for( std::size_t i = 0; i < heap.size(); ++i ) {
+        if( heap[i]->cancelled ) {
+            result++;
+            remove( i );
+            // re-try this point
+            i--;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t TimerTaskHeap::find( const Pointer<TimerTask>& task ) const {
+
+    for( std::size_t i = 0; i < heap.size(); ++i ) {
+        if( heap[i] == task ) {
+            return i;
+        }
+    }
+
+    return -1;
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/TimerTaskHeap.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/TimerTaskHeap.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/TimerTaskHeap.h?rev=796317&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/TimerTaskHeap.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/TimerTaskHeap.h Tue Jul 21 14:28:11 2009
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_INTERNAL_UTIL_TIMERTASKHEAP_H_
+#define _DECAF_INTERNAL_UTIL_TIMERTASKHEAP_H_
+
+#include <decaf/util/Config.h>
+
+#include <decaf/util/TimerTask.h>
+#include <decaf/lang/Pointer.h>
+
+namespace decaf {
+namespace internal {
+namespace util {
+
+    using decaf::lang::Pointer;
+    using decaf::util::TimerTask;
+
+    /**
+     * A Binary Heap implemented specifically for the Timer class in Decaf Util.
+     *
+     * @since 1.0
+     */
+    class DECAF_API TimerTaskHeap {
+    private:
+
+        // The default size of the Heap at creation.
+        static const int DEFAULT_HEAP_SIZE = 256;
+
+        // Dynamic Array of TimerTasks used to represent the heap
+        std::vector< Pointer<TimerTask> > heap;
+
+    public:
+
+        TimerTaskHeap();
+        virtual ~TimerTaskHeap();
+
+        /**
+         * Peaks at the Head of the Heap, returns the task with the nearest scheduled run time.
+         *
+         * @return The TimerTask that is scheduled to be executed next if the Heap is empty
+         *         a Null Pointer value is returned.
+         */
+        Pointer<TimerTask> peek();
+
+        /**
+         * @returns true if the heap is empty.
+         */
+        bool isEmpty() const;
+
+        /**
+         * @returns the size of the heap.
+         */
+        std::size_t size() const;
+
+        /**
+         * Inserts the specified Task into the heap, heap is reordered to reflect the addition
+         * of a new element.
+         *
+         * @param task
+         *      The TimerTask to insert into the heap.
+         */
+        void insert( const Pointer<TimerTask>& task );
+
+        /**
+         * Removes the Task at the specified position from the heap, resorts the heap from the
+         * position down to the bottom.
+         *
+         * @param pos
+         *      The position at which to remove the TimerTask and begin a resort of the heap.
+         */
+        void remove( std::size_t pos );
+
+        /**
+         * Clear all contents from the heap.
+         */
+        void reset();
+
+        /**
+         * Resorts the heap starting at the top.
+         */
+        void adjustMinimum();
+
+        /**
+         * Runs through the heap removing all cancelled Tasks from it, this is not normally
+         * used but in case a a cancellation of a large number of tasks the user can perform
+         * this purge.
+         *
+         * @return the number of task that were removed from the heap becuase they were cancelled.
+         */
+        std::size_t deleteIfCancelled();
+
+        /**
+         * Searches the heap for the specified TimerTask element and returns its position in the
+         * heap.  Returns the unsigned equivalent of -1 if the element is not found.
+         *
+         * @returns the position in the Heap where the Task is stored, or npos.
+         */
+        std::size_t find( const Pointer<TimerTask>& task ) const;
+
+    private:
+
+        void upHeap();
+        void downHeap( std::size_t pos );
+
+    };
+
+}}}
+
+#endif /* _DECAF_INTERNAL_UTIL_TIMERTASKHEAP_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/TimerTaskHeap.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/SynchronizableImpl.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/SynchronizableImpl.cpp?rev=796317&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/SynchronizableImpl.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/SynchronizableImpl.cpp Tue Jul 21 14:28:11 2009
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SynchronizableImpl.h"
+
+using namespace decaf;
+using namespace decaf::internal;
+using namespace decaf::internal::util;
+using namespace decaf::internal::util::concurrent;
+
+////////////////////////////////////////////////////////////////////////////////
+SynchronizableImpl::SynchronizableImpl() {}
+
+////////////////////////////////////////////////////////////////////////////////
+SynchronizableImpl::~SynchronizableImpl() {}
+
+////////////////////////////////////////////////////////////////////////////////
+void SynchronizableImpl::lock() throw( lang::Exception ) {
+    mutex.lock();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SynchronizableImpl::unlock() throw( lang::Exception ) {
+    mutex.unlock();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SynchronizableImpl::wait() throw( lang::Exception ) {
+    mutex.wait();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SynchronizableImpl::wait( long long millisecs ) throw( lang::Exception ) {
+    mutex.wait( millisecs );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SynchronizableImpl::wait( long long millisecs, int nanos ) throw( lang::Exception ) {
+    mutex.wait( millisecs, nanos );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SynchronizableImpl::notify() throw( lang::Exception ) {
+    mutex.notify();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SynchronizableImpl::notifyAll() throw( lang::Exception ) {
+    mutex.notifyAll();
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/SynchronizableImpl.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/SynchronizableImpl.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/SynchronizableImpl.h?rev=796317&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/SynchronizableImpl.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/SynchronizableImpl.h Tue Jul 21 14:28:11 2009
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_INTERNAL_UTIL_CONCURRENT_SYNCHRONIZABLEIMPL_H_
+#define _DECAF_INTERNAL_UTIL_CONCURRENT_SYNCHRONIZABLEIMPL_H_
+
+#include <decaf/util/Config.h>
+#include <decaf/util/concurrent/Synchronizable.h>
+#include <decaf/util/concurrent/Mutex.h>
+
+namespace decaf {
+namespace internal {
+namespace util {
+namespace concurrent {
+
+    /**
+     * A convenience class used by some Decaf classes to implement the Synchronizable interface
+     * when there is no issues related to multiple inheritance.
+     *
+     * @since 1.0
+     */
+    class DECAF_API SynchronizableImpl : public decaf::util::concurrent::Synchronizable {
+    private:
+
+        decaf::util::concurrent::Mutex mutex;
+
+    public:
+
+        SynchronizableImpl();
+        virtual ~SynchronizableImpl();
+
+        virtual void lock() throw( lang::Exception );
+
+        virtual void unlock() throw( lang::Exception );
+
+        virtual void wait() throw( lang::Exception );
+
+        virtual void wait( long long millisecs ) throw( lang::Exception );
+
+        virtual void wait( long long millisecs, int nanos ) throw( lang::Exception );
+
+        virtual void notify() throw( lang::Exception );
+
+        virtual void notifyAll() throw( lang::Exception );
+
+    };
+
+}}}}
+
+#endif /* _DECAF_INTERNAL_UTIL_CONCURRENT_SYNCHRONIZABLEIMPL_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/SynchronizableImpl.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/BlockingByteArrayInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/BlockingByteArrayInputStream.h?rev=796317&r1=796316&r2=796317&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/BlockingByteArrayInputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/BlockingByteArrayInputStream.h Tue Jul 21 14:28:11 2009
@@ -207,8 +207,12 @@
             mutex.wait();
         }
 
-        virtual void wait( unsigned long millisecs ) throw( lang::Exception ){
-            mutex.wait(millisecs);
+        virtual void wait( long long millisecs ) throw( lang::Exception ){
+            mutex.wait( millisecs );
+        }
+
+        virtual void wait( long long millisecs, int nanos ) throw( lang::Exception ) {
+            mutex.wait( millisecs, nanos );
         }
 
         virtual void notify() throw( lang::Exception ){

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.h?rev=796317&r1=796316&r2=796317&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayInputStream.h Tue Jul 21 14:28:11 2009
@@ -209,10 +209,14 @@
             mutex.wait();
         }
 
-        virtual void wait( unsigned long millisecs ) throw( lang::Exception ){
+        virtual void wait( long long millisecs ) throw( lang::Exception ){
             mutex.wait( millisecs );
         }
 
+        virtual void wait( long long millisecs, int nanos ) throw( lang::Exception ) {
+            mutex.wait( millisecs, nanos );
+        }
+
         virtual void notify() throw( lang::Exception ){
             mutex.notify();
         }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.h?rev=796317&r1=796316&r2=796317&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/ByteArrayOutputStream.h Tue Jul 21 14:28:11 2009
@@ -162,8 +162,12 @@
             mutex.wait();
         }
 
-        virtual void wait( unsigned long millisecs ) throw( lang::Exception ){
-            mutex.wait(millisecs);
+        virtual void wait( long long millisecs ) throw( lang::Exception ){
+            mutex.wait( millisecs );
+        }
+
+        virtual void wait( long long millisecs, int nanos ) throw( lang::Exception ) {
+            mutex.wait( millisecs, nanos );
         }
 
         virtual void notify() throw( lang::Exception ){

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterInputStream.h?rev=796317&r1=796316&r2=796317&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterInputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterInputStream.h Tue Jul 21 14:28:11 2009
@@ -36,8 +36,7 @@
      * FilterInputStream  may further override some of these methods and may
      * also provide additional methods and fields.
      */
-    class DECAF_API FilterInputStream : public InputStream
-    {
+    class DECAF_API FilterInputStream : public InputStream {
     protected:
 
         // The input stream to wrap
@@ -294,8 +293,12 @@
             mutex.wait();
         }
 
-        virtual void wait( unsigned long millisecs ) throw( lang::Exception ){
-            mutex.wait(millisecs);
+        virtual void wait( long long millisecs ) throw( lang::Exception ){
+            mutex.wait( millisecs );
+        }
+
+        virtual void wait( long long millisecs, int nanos ) throw( lang::Exception ) {
+            mutex.wait( millisecs, nanos );
         }
 
         virtual void notify() throw( lang::Exception ){

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterOutputStream.h?rev=796317&r1=796316&r2=796317&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterOutputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FilterOutputStream.h Tue Jul 21 14:28:11 2009
@@ -224,10 +224,14 @@
             mutex.wait();
         }
 
-        virtual void wait( unsigned long millisecs ) throw( lang::Exception ){
+        virtual void wait( long long millisecs ) throw( lang::Exception ){
             mutex.wait( millisecs );
         }
 
+        virtual void wait( long long millisecs, int nanos ) throw( lang::Exception ) {
+            mutex.wait( millisecs, nanos );
+        }
+
         virtual void notify() throw( lang::Exception ){
             mutex.notify();
         }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.h?rev=796317&r1=796316&r2=796317&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketInputStream.h Tue Jul 21 14:28:11 2009
@@ -163,12 +163,14 @@
             mutex.wait();
         }
 
-        virtual void wait( unsigned long millisecs )
-            throw( lang::Exception ) {
-
+        virtual void wait( long long millisecs ) throw( lang::Exception ) {
             mutex.wait( millisecs );
         }
 
+        virtual void wait( long long millisecs, int nanos ) throw( lang::Exception ) {
+            mutex.wait( millisecs, nanos );
+        }
+
         virtual void notify() throw( lang::Exception ){
             mutex.notify();
         }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.h?rev=796317&r1=796316&r2=796317&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOutputStream.h Tue Jul 21 14:28:11 2009
@@ -102,12 +102,14 @@
             mutex.wait();
         }
 
-        virtual void wait( unsigned long millisecs )
-            throw( lang::Exception ) {
-
+        virtual void wait( long long millisecs ) throw( lang::Exception ) {
             mutex.wait( millisecs );
         }
 
+        virtual void wait( long long millisecs, int nanos ) throw( lang::Exception ) {
+            mutex.wait( millisecs, nanos );
+        }
+
         virtual void notify() throw( lang::Exception ){
             mutex.notify();
         }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/AbstractCollection.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/AbstractCollection.h?rev=796317&r1=796316&r2=796317&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/AbstractCollection.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/AbstractCollection.h Tue Jul 21 14:28:11 2009
@@ -431,10 +431,14 @@
             mutex.wait();
         }
 
-        virtual void wait( unsigned long millisecs ) throw( lang::Exception ) {
+        virtual void wait( long long millisecs ) throw( lang::Exception ) {
             mutex.wait( millisecs );
         }
 
+        virtual void wait( long long millisecs, int nanos ) throw( lang::Exception ) {
+            mutex.wait( millisecs, nanos );
+        }
+
         virtual void notify() throw( lang::Exception  ) {
             mutex.notify();
         }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Map.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Map.h?rev=796317&r1=796316&r2=796317&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Map.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Map.h Tue Jul 21 14:28:11 2009
@@ -47,11 +47,11 @@
             Entry() {}
             virtual ~Entry() {}
 
-            const K& getKey() const = 0;
+            virtual const K& getKey() const = 0;
 
-            const V& getValue() const = 0;
+            virtual const V& getValue() const = 0;
 
-            void setValue( const V& value ) = 0;
+            virtual void setValue( const V& value ) = 0;
 
         };
 

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/PriorityQueue.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/PriorityQueue.h?rev=796317&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/PriorityQueue.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/PriorityQueue.h Tue Jul 21 14:28:11 2009
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_UTIL_PRIORITYQUEUE_H_
+#define _DECAF_UTIL_PRIORITYQUEUE_H_
+
+#include <decaf/util/Config.h>
+#include <decaf/util/AbstractQueue.h>
+#include <decaf/util/Iterator.h>
+#include <decaf/util/Comparator.h>
+#include <decaf/util/comparators/Less.h>
+
+#include <decaf/lang/Pointer.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+#include <decaf/lang/exceptions/UnsupportedOperationException.h>
+
+namespace decaf {
+namespace util {
+
+    /**
+     * An unbounded priority queue based on a binary heap algorithm. The elements of the priority queue
+     * are ordered according to their natural ordering, or by a Comparator provided to one of the constructors
+     * that accepts Comparators.  A priority queue relying on natural ordering also does not permit insertion
+     * of non-comparable objects (doing so may result in a compiler error).
+     *
+     * The head of this queue is the least element with respect to the specified ordering. If multiple
+     * elements are tied for least value, the head is one of those elements -- ties are broken arbitrarily.
+     * The queue retrieval operations poll, remove, peek, and element access the element at the head of
+     * the queue.
+     *
+     * A priority queue is unbounded, but has an internal capacity governing the size of an array used to store
+     * the elements on the queue. It is always at least as large as the queue size. As elements are added to
+     * a priority queue, its capacity grows automatically. The details of the growth policy are not specified.
+     *
+     * This class and its iterator implement all of the optional methods of the Collection and Iterator
+     * interfaces.  The Iterator provided in method iterator() is not guaranteed to traverse the elements of
+     * the priority queue in any particular order. If you need ordered traversal, consider using
+     * <code>Arrays::sort( pq.toArray() )</code>.
+     *
+     * Note that this implementation is not synchronized. Multiple threads should not access a PriorityQueue
+     * instance concurrently if any of the threads modifies the queue. Instead, use the thread-safe
+     * PriorityBlockingQueue class.
+     *
+     * Implementation note: this implementation provides O(log(n)) time for the enqueing and dequeing methods
+     * (offer, poll, remove() and add); linear time for the remove(Object) and contains(Object) methods;
+     * and constant time for the retrieval methods (peek, element, and size).
+     *
+     * @since 1.0
+     */
+    template< typename E >
+    class PriorityQueue : public AbstractQueue<E> {
+    private:
+
+        static const int DEFAULT_CAPACITY = 256;
+
+        std::size_t _size;
+        E* elements;
+        decaf::lang::Pointer< Comparator<E> > comparator;
+
+    private:
+
+        class PriorityQueueIterator : public Iterator<E> {
+        private:
+
+            std::size_t position;
+            PriorityQueue* queue;
+
+        public:
+
+            PriorityQueueIterator( PriorityQueue* queue ) : position( 0 ), queue( queue ) {}
+
+            virtual E next() throw( lang::exceptions::NoSuchElementException ) {
+                return E();
+            }
+
+            virtual bool hasNext() const {
+                return false;
+            }
+
+            virtual void remove() throw ( lang::exceptions::IllegalStateException,
+                                          lang::exceptions::UnsupportedOperationException ) {
+
+            }
+        };
+
+        class ConstPriorityQueueIterator : public PriorityQueueIterator {
+        public:
+
+            ConstPriorityQueueIterator( const PriorityQueue* queue ) :
+                PriorityQueueIterator( const_cast<PriorityQueue*>( queue ) ) {}
+
+            virtual void remove() throw ( lang::exceptions::IllegalStateException,
+                                          lang::exceptions::UnsupportedOperationException ) {
+
+                throw lang::exceptions::UnsupportedOperationException(
+                    __FILE__, __LINE__,
+                    "PriorityQueue::Iterator::remove - Not Valid on a Const Iterator" );
+            }
+        };
+
+    public:
+
+        /**
+         * Creates a Priority Queue with the default initial capacity.
+         */
+        PriorityQueue() : _size( 0 ){
+            this->initQueue( DEFAULT_CAPACITY, NULL );
+        }
+
+        /**
+         * Creates a Priority Queue with the capacity value supplied.
+         *
+         * @param initialCapacity
+         *      The initial number of elements allocated to this PriorityQueue.
+         */
+        PriorityQueue( std::size_t initialCapacity ) : _size( 0 ) {
+            this->initQueue( initialCapacity, new comparators::Less<E>() );
+        }
+
+        /**
+         * Creates a Priority Queue with the default initial capacity.  This new PriorityQueue takes
+         * ownership of the passed Comparator instance and uses that to determine the ordering of the
+         * elements in the Queue.
+         *
+         * @param initialCapacity
+         *      The initial number of elements allocated to this PriorityQueue.
+         * @param comparator
+         *      The Comparator instance to use in sorting the elements in the Queue.
+         *
+         * @throws NullPointerException if the passed Comparator is NULL.
+         */
+        PriorityQueue( std::size_t initialCapacity, Comparator<E>* comparator ) : _size( 0 ){
+
+            if( comparator == NULL ) {
+                throw decaf::lang::exceptions::NullPointerException(
+                    __FILE__, __LINE__, "Passed Comparator Cannot be NULL." );
+            }
+
+            this->initQueue( initialCapacity, comparator );
+        }
+
+        /**
+         * Creates a PriorityQueue containing the elements in the specified Collection.
+         *
+         * @param source
+         *      the Collection whose elements are to be placed into this priority queue
+         */
+        PriorityQueue( const Collection<E>& source ) : _size( 0 ) {
+            // TODO
+        }
+
+        /**
+         * Creates a PriorityQueue containing the elements in the specified priority queue. This priority
+         * queue will be ordered according to the same ordering as the given priority queue.
+         *
+         * @param source
+         *      the priority queue whose elements are to be placed into this priority queue
+         */
+        PriorityQueue( const PriorityQueue<E>& source ) : _size( 0 ) {
+            // TODO
+        }
+
+        virtual ~PriorityQueue() {}
+
+        virtual decaf::util::Iterator<E>* iterator() {
+            return new PriorityQueueIterator( this );
+        }
+
+        virtual decaf::util::Iterator<E>* iterator() const {
+            return new ConstPriorityQueueIterator( this );
+        }
+
+        virtual std::size_t size() const {
+            return this->_size;
+        }
+
+        const E& getEmptyMarker() const {
+            static const E marker = E();
+            return marker;
+        }
+
+        bool offer( const E& value ) {
+            return false;
+        }
+
+        E poll() {
+            return this->getEmptyMarker();
+        }
+
+        const E& peek() const {
+            return this->getEmptyMarker();
+        }
+
+    private:
+
+        void initQueue( std::size_t initialSize, Comparator<E>* comparator ) {
+            this->elements = new E[initialSize];
+            this->comparator.reset( comparator );
+        }
+
+    };
+
+}}
+
+#endif /* _DECAF_UTIL_PRIORITYQUEUE_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/PriorityQueue.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Queue.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Queue.h?rev=796317&r1=796316&r2=796317&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Queue.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Queue.h Tue Jul 21 14:28:11 2009
@@ -43,6 +43,8 @@
      * Certain methods in the Queue interface return a special value instead of throwing
      * an exception if there is no element in the Queue to return, this special value
      * can be obtained by calling the Queue method <code>getEmptyMarker</code>.
+     *
+     * @since 1.0
      */
     template <typename E>
     class Queue : public decaf::util::AbstractCollection<E> {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StlMap.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StlMap.h?rev=796317&r1=796316&r2=796317&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StlMap.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StlMap.h Tue Jul 21 14:28:11 2009
@@ -288,8 +288,12 @@
             mutex.wait();
         }
 
-        virtual void wait( unsigned long millisecs ) throw( lang::Exception ) {
-            mutex.wait(millisecs);
+        virtual void wait( long long millisecs ) throw( lang::Exception ) {
+            mutex.wait( millisecs );
+        }
+
+        virtual void wait( long long millisecs, int nanos ) throw( lang::Exception ) {
+            mutex.wait( millisecs, nanos );
         }
 
         virtual void notify() throw( lang::Exception ) {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StlQueue.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StlQueue.h?rev=796317&r1=796316&r2=796317&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StlQueue.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StlQueue.h Tue Jul 21 14:28:11 2009
@@ -56,8 +56,8 @@
      * polling loop to ensure that you don't get stuck there.
      */
 
-    template <typename T> 
-	class StlQueue : public concurrent::Synchronizable {
+    template <typename T>
+    class StlQueue : public concurrent::Synchronizable {
     private:
 
         // The real queue
@@ -247,57 +247,32 @@
             target.queue.insert( target.queue.end(), queue.rbegin(), queue.rend() );
         }
 
-        /**
-         * Locks the object.
-         */
+    public:  // Synchronizable
+
         virtual void lock() throw( lang::Exception ){
             mutex.lock();
         }
 
-        /**
-         * Unlocks the object.
-         */
         virtual void unlock() throw( lang::Exception ){
             mutex.unlock();
         }
 
-        /**
-         * Waits on a signal from this object, which is generated
-         * by a call to Notify.  Must have this object locked before
-         * calling.
-         */
         virtual void wait() throw( lang::Exception ){
             mutex.wait();
         }
 
-        /**
-         * Waits on a signal from this object, which is generated
-         * by a call to Notify.  Must have this object locked before
-         * calling.  This wait will timeout after the specified time
-         * interval.
-         * @param millisecs time to wait, or WAIT_INIFINITE
-         * @throws ActiveMQException
-         */
-        virtual void wait( unsigned long millisecs )
-            throw( lang::Exception ) {
+        virtual void wait( long long millisecs ) throw( lang::Exception ) {
+            mutex.wait( millisecs );
+        }
 
-            mutex.wait(millisecs);
+        virtual void wait( long long millisecs, int nanos ) throw( lang::Exception ) {
+            mutex.wait( millisecs, nanos );
         }
 
-        /**
-         * Signals a waiter on this object that it can now wake
-         * up and continue.  Must have this object locked before
-         * calling.
-         */
         virtual void notify() throw( lang::Exception ){
             mutex.notify();
         }
 
-        /**
-         * Signals the waiters on this object that it can now wake
-         * up and continue.  Must have this object locked before
-         * calling.
-         */
         virtual void notifyAll() throw( lang::Exception ){
             mutex.notifyAll();
         }

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Timer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Timer.cpp?rev=796317&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Timer.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Timer.cpp Tue Jul 21 14:28:11 2009
@@ -0,0 +1,589 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Timer.h"
+
+#include <decaf/lang/Thread.h>
+#include <decaf/lang/Pointer.h>
+#include <decaf/lang/System.h>
+#include <decaf/util/concurrent/Mutex.h>
+#include <decaf/internal/util/TimerTaskHeap.h>
+#include <decaf/internal/util/concurrent/SynchronizableImpl.h>
+#include <decaf/lang/exceptions/InterruptedException.h>
+
+using namespace decaf;
+using namespace decaf::util;
+using namespace decaf::util::concurrent;
+using namespace decaf::internal;
+using namespace decaf::internal::util;
+using namespace decaf::internal::util::concurrent;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace decaf{
+namespace util{
+
+    class TimerImpl : public decaf::lang::Thread, public SynchronizableImpl {
+    public:
+
+        TimerTaskHeap heap;
+        bool cancelled;
+
+        TimerImpl() : cancelled( false ) {}
+
+        ~TimerImpl() {
+            try{
+                this->cancel();
+                this->join();
+            }
+            DECAF_CATCHALL_NOTHROW()
+        }
+
+        /**
+         * This method will be launched on separate thread for each Timer
+         * object.
+         */
+        virtual void run() {
+
+            while( true ) {
+
+                Pointer<TimerTask> task;
+
+                synchronized( this ) {
+
+                    if( cancelled ) {
+                        return;
+                    }
+
+                    if( heap.isEmpty()) {
+
+                        // no tasks scheduled -- sleep until any task appear
+                        try {
+                            this->wait();
+                        } catch( InterruptedException& e ) {}
+                        continue;
+                    }
+
+                    long long currentTime = System::currentTimeMillis();
+
+                    task = heap.peek();
+                    long long timeToSleep = 0LL;
+
+                    synchronized( &( task->lock ) ) {
+                        if( task->cancelled ) {
+                            heap.remove( 0 );
+                            continue;
+                        }
+
+                        // check the time to sleep for the first task scheduled
+                        timeToSleep = task->when - currentTime;
+                    }
+
+                    if( timeToSleep > 0 ) {
+
+                        task.reset( NULL );
+                        try {
+                            this->wait( timeToSleep );
+                        } catch( InterruptedException& e ) {}
+                        continue;
+                    }
+
+                    // Time to run the task, but first we need to check to see if any other
+                    // tasks where scheduled and caused this one to be moved someplace new on
+                    // the heap and find it new location.. We also need to check that the task
+                    // wasn't cancelled while we were sleeping.
+                    synchronized( &( task->lock ) ) {
+                        std::size_t pos = 0;
+
+                        if( heap.peek()->when != task->when ) {
+                            pos = heap.find( task );
+                        }
+
+                        if( task->cancelled ) {
+                            heap.remove( heap.find( task ) );
+                            continue;
+                        }
+
+                        // set time to schedule
+                        task->setScheduledTime( task->when );
+
+                        // remove task from queue
+                        heap.remove( pos );
+
+                        // set when the next task should be launched
+                        if( task->period >= 0 ) {
+
+                            // this is a repeating task,
+                            if( task->fixedRate ) {
+                                // task is scheduled at fixed rate
+                                task->when = task->when + task->period;
+                            } else {
+                                // task is scheduled at fixed delay
+                                task->when = System::currentTimeMillis() + task->period;
+                            }
+
+                            // insert this task into queue, it will be ordered by the heap for
+                            // its next run time.
+                            insertTask( task );
+
+                        } else {
+
+                            // Task was a one-shot, setting when to zero indicates it
+                            // won't run anymore.
+                            task->when = 0;
+                        }
+                    }
+                }
+
+                // run the task, suppress all exceptions, we can't deal with them.
+                if( task != NULL && !task->cancelled ) {
+                    try {
+                        task->run();
+                    } catch(...) {}
+                }
+            }
+        }
+
+        void insertTask( const Pointer<TimerTask>& task ) {
+            // callers are synchronized
+            heap.insert( task );
+            this->notify();
+        }
+
+        void cancel() {
+            synchronized( this ) {
+                cancelled = true;
+                heap.reset();
+                this->notify();
+            }
+        }
+
+        int purge() {
+
+            std::size_t result = 0;
+            synchronized( this ) {
+
+                if( heap.isEmpty() ) {
+                    return 0;
+                }
+
+                result = heap.deleteIfCancelled();
+            }
+
+            return result;
+        }
+
+    };
+}}
+
+////////////////////////////////////////////////////////////////////////////////
+Timer::Timer() {
+    this->internal.reset( new TimerImpl() );
+    this->internal->start();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Timer::~Timer() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Timer::cancel() {
+    this->internal->cancel();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t Timer::purge() {
+    return this->internal->purge();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Timer::schedule( TimerTask* task, long long delay )
+    throw( decaf::lang::exceptions::NullPointerException,
+           decaf::lang::exceptions::IllegalArgumentException,
+           decaf::lang::exceptions::IllegalStateException ) {
+
+    if( delay < 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled to start in the Future but delay was Negative" );
+    }
+
+    Pointer<TimerTask> wrapper( task );
+
+    try{
+        scheduleTask( wrapper, delay, -1, false );
+    } catch( NullPointerException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    } catch( IllegalArgumentException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    } catch( IllegalStateException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Timer::schedule( const Pointer<TimerTask>& task, long long delay )
+    throw( decaf::lang::exceptions::NullPointerException,
+           decaf::lang::exceptions::IllegalArgumentException,
+           decaf::lang::exceptions::IllegalStateException ) {
+
+    if( delay < 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled to start in the Future but delay was Negative" );
+    }
+
+    scheduleTask( task, delay, -1, false );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Timer::schedule( TimerTask* task, const Date& when )
+    throw( decaf::lang::exceptions::NullPointerException,
+           decaf::lang::exceptions::IllegalArgumentException,
+           decaf::lang::exceptions::IllegalStateException ) {
+
+    if( when.getTime() < 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled to start in the Future." );
+    }
+
+    Pointer<TimerTask> wrapper( task );
+    long long delay = when.getTime() - System::currentTimeMillis();
+
+    try{
+        scheduleTask( wrapper, delay < 0 ? 0 : delay, -1, false );
+    } catch( NullPointerException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    } catch( IllegalArgumentException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    } catch( IllegalStateException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Timer::schedule( const Pointer<TimerTask>& task, const Date& when )
+    throw( decaf::lang::exceptions::NullPointerException,
+           decaf::lang::exceptions::IllegalArgumentException,
+           decaf::lang::exceptions::IllegalStateException ) {
+
+    if( when.getTime() < 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled to start in the Future." );
+    }
+
+    long long delay = when.getTime() - System::currentTimeMillis();
+    scheduleTask( task, delay < 0 ? 0 : delay, -1, false );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Timer::schedule( TimerTask* task, long long delay, long long period )
+    throw( decaf::lang::exceptions::NullPointerException,
+           decaf::lang::exceptions::IllegalArgumentException,
+           decaf::lang::exceptions::IllegalStateException ) {
+
+    if( delay < 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled to start in the Future but delay was Negative" );
+    }
+
+    if( period <= 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled non-negative or non-zero period." );
+    }
+
+    Pointer<TimerTask> wrapper( task );
+
+    try{
+        scheduleTask( wrapper, delay, period, false );
+    } catch( NullPointerException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    } catch( IllegalArgumentException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    } catch( IllegalStateException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Timer::schedule( const Pointer<TimerTask>& task, long long delay, long long period )
+    throw( decaf::lang::exceptions::NullPointerException,
+           decaf::lang::exceptions::IllegalArgumentException,
+           decaf::lang::exceptions::IllegalStateException ) {
+
+    if( delay < 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled to start in the Future but delay was Negative" );
+    }
+
+    if( period <= 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled non-negative or non-zero period." );
+    }
+
+    scheduleTask( task, delay, period, false );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Timer::schedule( TimerTask* task, const Date& when, long long period )
+    throw( decaf::lang::exceptions::NullPointerException,
+           decaf::lang::exceptions::IllegalArgumentException,
+           decaf::lang::exceptions::IllegalStateException ) {
+
+    if( when.getTime() < 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled to start in the Future." );
+    }
+
+    if( period <= 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled non-negative or non-zero period." );
+    }
+
+    Pointer<TimerTask> wrapper( task );
+    long long delay = when.getTime() - System::currentTimeMillis();
+
+    try{
+        scheduleTask( wrapper, delay < 0 ? 0 : delay, period, false );
+    } catch( NullPointerException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    } catch( IllegalArgumentException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    } catch( IllegalStateException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Timer::schedule( const Pointer<TimerTask>& task, const Date& when, long long period )
+    throw( decaf::lang::exceptions::NullPointerException,
+           decaf::lang::exceptions::IllegalArgumentException,
+           decaf::lang::exceptions::IllegalStateException ) {
+
+    if( when.getTime() < 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled to start in the Future." );
+    }
+
+    if( period <= 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled non-negative or non-zero period." );
+    }
+
+    long long delay = when.getTime() - System::currentTimeMillis();
+    scheduleTask( task, delay < 0 ? 0 : delay, period, false );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Timer::scheduleAtFixedRate( TimerTask* task, long long delay, long long period )
+    throw( decaf::lang::exceptions::NullPointerException,
+           decaf::lang::exceptions::IllegalArgumentException,
+           decaf::lang::exceptions::IllegalStateException ) {
+
+    if( delay < 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled to start in the Future but delay was Negative" );
+    }
+
+    if( period <= 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled non-negative or non-zero period." );
+    }
+
+    Pointer<TimerTask> wrapper( task );
+
+    try{
+        scheduleTask( wrapper, delay, period, true );
+    } catch( NullPointerException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    } catch( IllegalArgumentException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    } catch( IllegalStateException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Timer::scheduleAtFixedRate( const Pointer<TimerTask>& task, long long delay, long long period )
+    throw( decaf::lang::exceptions::NullPointerException,
+           decaf::lang::exceptions::IllegalArgumentException,
+           decaf::lang::exceptions::IllegalStateException ) {
+
+    if( delay < 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled to start in the Future but delay was Negative" );
+    }
+
+    if( period <= 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled non-negative or non-zero period." );
+    }
+
+    scheduleTask( task, delay, period, true );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Timer::scheduleAtFixedRate( TimerTask* task, const Date& when, long long period )
+    throw( decaf::lang::exceptions::NullPointerException,
+           decaf::lang::exceptions::IllegalArgumentException,
+           decaf::lang::exceptions::IllegalStateException ) {
+
+    if( when.getTime() < 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled to start in the Future." );
+    }
+
+    if( period <= 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled non-negative or non-zero period." );
+    }
+
+    Pointer<TimerTask> wrapper( task );
+    long long delay = when.getTime() - System::currentTimeMillis();
+
+    try{
+        scheduleTask( wrapper, delay < 0 ? 0 : delay, period, true );
+    } catch( NullPointerException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    } catch( IllegalArgumentException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    } catch( IllegalStateException& ex ) {
+        wrapper.release();
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Timer::scheduleAtFixedRate( const Pointer<TimerTask>& task, const Date& when, long long period )
+    throw( decaf::lang::exceptions::NullPointerException,
+           decaf::lang::exceptions::IllegalArgumentException,
+           decaf::lang::exceptions::IllegalStateException ) {
+
+    if( when.getTime() < 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled to start in the Future." );
+    }
+
+    if( period <= 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Task must be scheduled non-negative or non-zero period." );
+    }
+
+    long long delay = when.getTime() - System::currentTimeMillis();
+    scheduleTask( task, delay < 0 ? 0 : delay, period, true );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Timer::scheduleTask( const Pointer<TimerTask>& task, long long delay, long long period, bool fixed ) {
+
+    if( task == NULL ) {
+        throw NullPointerException(
+            __FILE__, __LINE__, "Task pointer passed in was Null" );
+    }
+
+    synchronized( this->internal.get() ) {
+
+        if( this->internal->cancelled ) {
+            throw IllegalStateException(
+                __FILE__, __LINE__, "Timer was cancelled." );
+        }
+
+        long long when = delay + System::currentTimeMillis();
+
+        if( when < 0 ) {
+            throw IllegalArgumentException(
+                __FILE__, __LINE__,
+                "Task must be scheduled to start in the Future but delay was Negative" );
+        }
+
+        synchronized( &( task->lock ) ) {
+
+            if( task->isScheduled() ) {
+                throw IllegalStateException(
+                    __FILE__, __LINE__,
+                    "Task is already scheduled in a Timer, cannot add again." );
+            }
+
+            if( task->cancelled ) {
+                throw IllegalStateException(
+                    __FILE__, __LINE__,
+                    "Task is already has been cancelled cannot be restarted." );
+            }
+
+            task->when = when;
+            task->period = period;
+            task->fixedRate = fixed;
+        }
+
+        // insert the new Task into priority queue
+        this->internal->insertTask( task );
+    }
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Timer.cpp
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message