Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 36059 invoked from network); 11 Mar 2009 18:56:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Mar 2009 18:56:19 -0000 Received: (qmail 97976 invoked by uid 500); 11 Mar 2009 18:56:19 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 97957 invoked by uid 500); 11 Mar 2009 18:56:19 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 97948 invoked by uid 99); 11 Mar 2009 18:56:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Mar 2009 11:56:19 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Mar 2009 18:56:16 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BDE592388B67; Wed, 11 Mar 2009 18:55:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r752573 - in /activemq/activemq-cpp/trunk/src: main/ main/activemq/transport/failover/ main/activemq/util/ test/ test/activemq/transport/failover/ test/activemq/util/ Date: Wed, 11 Mar 2009 18:55:54 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090311185554.BDE592388B67@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Wed Mar 11 18:55:53 2009 New Revision: 752573 URL: http://svn.apache.org/viewvc?rev=752573&view=rev Log: http://issues.apache.org/activemq/browse/AMQCPP-100 Fixes for shutdown issues in the Failover transport as well as some code cleanup. Added a new unit test for the TaskRunner classes added to activemq/util Added: activemq/activemq-cpp/trunk/src/main/activemq/util/Task.h (with props) activemq/activemq-cpp/trunk/src/main/activemq/util/TaskRunner.cpp (with props) activemq/activemq-cpp/trunk/src/main/activemq/util/TaskRunner.h (with props) activemq/activemq-cpp/trunk/src/test/activemq/util/TaskRunnerTest.cpp (with props) activemq/activemq-cpp/trunk/src/test/activemq/util/TaskRunnerTest.h (with props) Modified: activemq/activemq-cpp/trunk/src/main/Makefile.am activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransport.cpp activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransport.h activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/ReconnectTask.cpp activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/ReconnectTask.h activemq/activemq-cpp/trunk/src/test/Makefile.am activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/FailoverTransportTest.cpp activemq/activemq-cpp/trunk/src/test/testRegistry.cpp Modified: activemq/activemq-cpp/trunk/src/main/Makefile.am URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/Makefile.am?rev=752573&r1=752572&r2=752573&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/Makefile.am (original) +++ activemq/activemq-cpp/trunk/src/main/Makefile.am Wed Mar 11 18:55:53 2009 @@ -27,6 +27,7 @@ activemq/util/URISupport.cpp \ activemq/util/MemoryUsage.cpp \ activemq/util/CompositeData.cpp \ + activemq/util/TaskRunner.cpp \ activemq/cmsutil/DynamicDestinationResolver.cpp \ activemq/cmsutil/ResourceLifecycleManager.cpp \ activemq/cmsutil/CmsAccessor.cpp \ @@ -229,7 +230,9 @@ activemq/util/URISupport.h \ activemq/util/MemoryUsage.h \ activemq/util/Usage.h \ - activemq/util/CompositeData.h \ + activemq/util/CompositeData.h \ + activemq/util/Task.h \ + activemq/util/TaskRunner.h \ activemq/wireformat/WireFormat.h \ activemq/wireformat/WireFormatNegotiator.h \ activemq/wireformat/WireFormatFactory.h \ Modified: activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransport.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransport.cpp?rev=752573&r1=752572&r2=752573&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransport.cpp (original) +++ activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransport.cpp Wed Mar 11 18:55:53 2009 @@ -65,6 +65,7 @@ this->stateTracker.setTrackTransactions( true ); this->myTransportListener.reset( new FailoverTransportListener( this ) ); this->reconnectTask.reset( new ReconnectTask( this ) ); + this->taskRunner.reset( new TaskRunner( reconnectTask.get() ) ); } //////////////////////////////////////////////////////////////////////////////// @@ -399,7 +400,7 @@ sleepMutex.notifyAll(); } - reconnectTask->shutdown( 500 ); + taskRunner->shutdown( 500 ); if( transportToStop != NULL ) { transportToStop->close(); @@ -411,7 +412,7 @@ synchronized( &reconnectMutex ) { if( started ) { - reconnectTask->wakeup(); + taskRunner->wakeup(); } } } @@ -467,7 +468,7 @@ connectedTransportURI.reset( NULL ); connected = false; if( reconnectOk ) { - reconnectTask->wakeup(); + taskRunner->wakeup(); } } Modified: activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransport.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransport.h?rev=752573&r1=752572&r2=752573&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransport.h (original) +++ activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransport.h Wed Mar 11 18:55:53 2009 @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -43,6 +44,7 @@ using namespace decaf::lang; using decaf::net::URI; using namespace decaf::util; + using namespace activemq::util; using activemq::commands::Command; using activemq::commands::Response; @@ -88,6 +90,7 @@ Pointer connectedTransport; Pointer connectionFailure; Pointer reconnectTask; + Pointer taskRunner; Pointer disposedListener; Pointer myTransportListener; TransportListener* transportListener; Modified: activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/ReconnectTask.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/ReconnectTask.cpp?rev=752573&r1=752572&r2=752573&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/ReconnectTask.cpp (original) +++ activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/ReconnectTask.cpp Wed Mar 11 18:55:53 2009 @@ -36,48 +36,6 @@ throw NullPointerException( __FILE__, __LINE__, "Parent FailoverTransport passed was null" ); } - - this->threadTerminated = false; - this->pending = false; - this->shutDown = false; - - this->start(); -} - -//////////////////////////////////////////////////////////////////////////////// -ReconnectTask::~ReconnectTask() { - try{ - this->shutdown(); - } - AMQ_CATCHALL_NOTHROW() -} - -//////////////////////////////////////////////////////////////////////////////// -void ReconnectTask::shutdown( unsigned int timeout ) { - - synchronized( &mutex ) { - shutDown = true; - pending = true; - mutex.notifyAll(); - - // Wait till the thread stops ( no need to wait if shutdown - // is called from thread that is shutting down) - if( !threadTerminated ) { - mutex.wait( timeout ); - } - } -} - -//////////////////////////////////////////////////////////////////////////////// -void ReconnectTask::wakeup() { - - synchronized( &mutex ) { - if( shutDown) { - return; - } - pending = true; - mutex.notifyAll(); - } } //////////////////////////////////////////////////////////////////////////////// @@ -98,49 +56,8 @@ } else { // build backups on the next iteration result = true; - this->wakeup(); + parent->taskRunner->wakeup(); } return result; } - -//////////////////////////////////////////////////////////////////////////////// -void ReconnectTask::run() { - - try { - - while( true ) { - - synchronized( &mutex ) { - pending = false; - if( shutDown ) { - return; - } - } - - if( !this->iterate() ) { - - // wait to be notified. - synchronized( &mutex ) { - if( shutDown ) { - return; - } - while( !pending ) { - mutex.wait(); - } - } - } - - } - } - AMQ_CATCH_NOTHROW( Exception ) - AMQ_CATCHALL_NOTHROW() - - // Make sure we notify any waiting threads that thread - // has terminated. - synchronized( &mutex ) { - threadTerminated = true; - mutex.notifyAll(); - } - -} Modified: activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/ReconnectTask.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/ReconnectTask.h?rev=752573&r1=752572&r2=752573&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/ReconnectTask.h (original) +++ activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/ReconnectTask.h Wed Mar 11 18:55:53 2009 @@ -20,9 +20,7 @@ #include -#include -#include -#include +#include namespace activemq { namespace transport { @@ -30,37 +28,18 @@ class FailoverTransport; - class AMQCPP_API ReconnectTask : public decaf::lang::Thread { + class AMQCPP_API ReconnectTask : public activemq::util::Task { private: - decaf::util::concurrent::Mutex mutex; - - bool threadTerminated; - bool pending; - bool shutDown; - FailoverTransport* parent; public: ReconnectTask( FailoverTransport* parent ); - - virtual ~ReconnectTask(); - - void shutdown( unsigned int timeout ); - - void shutdown() { - this->shutdown( 0 ); - } - - void wakeup(); - - protected: + virtual ~ReconnectTask() {} bool iterate(); - virtual void run(); - }; }}} Added: activemq/activemq-cpp/trunk/src/main/activemq/util/Task.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/util/Task.h?rev=752573&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/util/Task.h (added) +++ activemq/activemq-cpp/trunk/src/main/activemq/util/Task.h Wed Mar 11 18:55:53 2009 @@ -0,0 +1,48 @@ +/* + * 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 _ACTIVEMQ_UTIL_TASK_H_ +#define _ACTIVEMQ_UTIL_TASK_H_ + +namespace activemq { +namespace util { + + /** + * Represents a unit of work that requires one or more iterations to complete. + * + * @since 3.0 + */ + class Task { + public: + + virtual ~Task() {} + + /** + * Perform one iteration of work, returns true if the task needs + * to run again to complete or false to indicate that the task is now + * complete. + * + * @return true if the task should be run again or false if the task + * has completed and the runner should wait for a wakeup call. + */ + virtual bool iterate() = 0; + + }; + +}} + +#endif /* _ACTIVEMQ_UTIL_TASK_H_ */ Propchange: activemq/activemq-cpp/trunk/src/main/activemq/util/Task.h ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/activemq-cpp/trunk/src/main/activemq/util/TaskRunner.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/util/TaskRunner.cpp?rev=752573&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/util/TaskRunner.cpp (added) +++ activemq/activemq-cpp/trunk/src/main/activemq/util/TaskRunner.cpp Wed Mar 11 18:55:53 2009 @@ -0,0 +1,134 @@ +/* + * 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 "TaskRunner.h" + +#include + +using namespace activemq; +using namespace activemq::util; +using namespace activemq::exceptions; +using namespace decaf; +using namespace decaf::lang; +using namespace decaf::lang::exceptions; + +//////////////////////////////////////////////////////////////////////////////// +TaskRunner::TaskRunner( Task* task ) : task( task ) { + + if( this->task == NULL ) { + throw NullPointerException( + __FILE__, __LINE__, "Task passed was null" ); + } + + this->threadTerminated = false; + this->pending = false; + this->shutDown = false; + + this->thread.reset( new Thread( this ) ); + this->thread->start(); +} + +//////////////////////////////////////////////////////////////////////////////// +TaskRunner::~TaskRunner() { + try{ + this->shutdown(); + } + AMQ_CATCHALL_NOTHROW() +} + +//////////////////////////////////////////////////////////////////////////////// +void TaskRunner::shutdown( unsigned int timeout ) { + + synchronized( &mutex ) { + shutDown = true; + pending = true; + mutex.notifyAll(); + + // Wait till the thread stops ( no need to wait if shutdown + // is called from thread that is shutting down) + if( !threadTerminated ) { + mutex.wait( timeout ); + } + } +} + +//////////////////////////////////////////////////////////////////////////////// +void TaskRunner::shutdown() { + + synchronized( &mutex ) { + shutDown = true; + pending = true; + mutex.notifyAll(); + } + + // Wait till the thread stops + if( !threadTerminated ) { + this->thread->join(); + } +} + +//////////////////////////////////////////////////////////////////////////////// +void TaskRunner::wakeup() { + + synchronized( &mutex ) { + if( shutDown) { + return; + } + pending = true; + mutex.notifyAll(); + } +} + +//////////////////////////////////////////////////////////////////////////////// +void TaskRunner::run() { + + try { + + while( true ) { + + synchronized( &mutex ) { + pending = false; + if( shutDown ) { + return; + } + } + + if( !this->task->iterate() ) { + + // wait to be notified. + synchronized( &mutex ) { + if( shutDown ) { + return; + } + while( !pending ) { + mutex.wait(); + } + } + } + + } + } + AMQ_CATCH_NOTHROW( Exception ) + AMQ_CATCHALL_NOTHROW() + + // Make sure we notify any waiting threads that thread + // has terminated. + synchronized( &mutex ) { + threadTerminated = true; + mutex.notifyAll(); + } +} Propchange: activemq/activemq-cpp/trunk/src/main/activemq/util/TaskRunner.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/activemq-cpp/trunk/src/main/activemq/util/TaskRunner.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/util/TaskRunner.h?rev=752573&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/util/TaskRunner.h (added) +++ activemq/activemq-cpp/trunk/src/main/activemq/util/TaskRunner.h Wed Mar 11 18:55:53 2009 @@ -0,0 +1,79 @@ +/* + * 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 _ACTIVEMQ_UTIL_TASKRUNNER_H_ +#define _ACTIVEMQ_UTIL_TASKRUNNER_H_ + +#include + +#include +#include +#include +#include + +namespace activemq { +namespace util { + + using decaf::lang::Pointer; + + class TaskRunner : public decaf::lang::Runnable { + private: + + decaf::util::concurrent::Mutex mutex; + + Pointer thread; + + bool threadTerminated; + bool pending; + bool shutDown; + + Task* task; + + public: + + TaskRunner( Task* task ); + virtual ~TaskRunner(); + + /** + * Shutdown after a timeout, does not guarantee that the task's iterate + * method has completed and the thread halted. + * + * @param timeout - Time in Milliseconds to wait for the task to stop. + */ + void shutdown( unsigned int timeout ); + + /** + * Shutdown once the task has finished and the TaskRunner's thread has exited. + */ + void shutdown(); + + /** + * Signal the TaskRunner to wakeup and execute another iteration cycle on + * the task, the Task instance will be run until its iterate method has + * returned false indicating it is done. + */ + void wakeup(); + + protected: + + virtual void run(); + + }; + +}} + +#endif /*_ACTIVEMQ_UTIL_TASKRUNNER_H_*/ Propchange: activemq/activemq-cpp/trunk/src/main/activemq/util/TaskRunner.h ------------------------------------------------------------------------------ svn:eol-style = native Modified: activemq/activemq-cpp/trunk/src/test/Makefile.am URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/Makefile.am?rev=752573&r1=752572&r2=752573&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/Makefile.am (original) +++ activemq/activemq-cpp/trunk/src/test/Makefile.am Wed Mar 11 18:55:53 2009 @@ -47,6 +47,7 @@ activemq/util/URISupportTest.cpp \ activemq/util/MemoryUsageTest.cpp \ activemq/util/LongSequenceGeneratorTest.cpp \ + activemq/util/TaskRunnerTest.cpp \ activemq/wireformat/WireFormatRegistryTest.cpp \ activemq/wireformat/openwire/OpenWireFormatTest.cpp \ activemq/wireformat/openwire/marshal/PrimitiveMapMarshallerTest.cpp \ @@ -147,6 +148,7 @@ activemq/util/URISupportTest.h \ activemq/util/MemoryUsageTest.h \ activemq/util/LongSequenceGeneratorTest.h \ + activemq/util/TaskRunnerTest.h \ activemq/wireformat/WireFormatRegistryTest.h \ activemq/wireformat/openwire/OpenWireFormatTest.h \ activemq/wireformat/openwire/marshal/PrimitiveMapMarshallerTest.h \ Modified: activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/FailoverTransportTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/FailoverTransportTest.cpp?rev=752573&r1=752572&r2=752573&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/FailoverTransportTest.cpp (original) +++ activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/FailoverTransportTest.cpp Wed Mar 11 18:55:53 2009 @@ -54,7 +54,7 @@ CPPUNIT_ASSERT( failover != NULL ); CPPUNIT_ASSERT( failover->isRandomize() == false ); -// transport->start(); + transport->start(); transport->close(); } Added: activemq/activemq-cpp/trunk/src/test/activemq/util/TaskRunnerTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/util/TaskRunnerTest.cpp?rev=752573&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/src/test/activemq/util/TaskRunnerTest.cpp (added) +++ activemq/activemq-cpp/trunk/src/test/activemq/util/TaskRunnerTest.cpp Wed Mar 11 18:55:53 2009 @@ -0,0 +1,102 @@ +/* + * 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 "TaskRunnerTest.h" + +#include + +#include +#include + +#include +#include + +using namespace activemq; +using namespace activemq::util; +using namespace decaf::lang; +using namespace decaf::lang::exceptions; + +//////////////////////////////////////////////////////////////////////////////// +class SimpleCountingTask : public Task { +private: + + unsigned int count; + +public: + + SimpleCountingTask() : count(0) {} + virtual ~SimpleCountingTask() {} + + virtual bool iterate() { + + count++; + return false; + } + + unsigned int getCount() const { return count; } +}; + +//////////////////////////////////////////////////////////////////////////////// +class InfiniteCountingTask : public Task { +private: + + unsigned int count; + +public: + + InfiniteCountingTask() : count(0) {} + virtual ~InfiniteCountingTask() {} + + virtual bool iterate() { + + count++; + return true; + } + + unsigned int getCount() const { return count; } +}; + +//////////////////////////////////////////////////////////////////////////////// +void TaskRunnerTest::testSimple() { + + CPPUNIT_ASSERT_THROW_MESSAGE( + "Should throw a NullPointerException", + std::auto_ptr( new TaskRunner( NULL ) ), + NullPointerException ); + + SimpleCountingTask simpleTask; + CPPUNIT_ASSERT( simpleTask.getCount() == 0 ); + TaskRunner simpleTaskRunner( &simpleTask ); + + simpleTaskRunner.wakeup(); + Thread::sleep( 250 ); + CPPUNIT_ASSERT( simpleTask.getCount() >= 1 ); + simpleTaskRunner.wakeup(); + Thread::sleep( 250 ); + CPPUNIT_ASSERT( simpleTask.getCount() >= 2 ); + + InfiniteCountingTask infiniteTask; + CPPUNIT_ASSERT( infiniteTask.getCount() == 0 ); + TaskRunner infiniteTaskRunner( &infiniteTask ); + Thread::sleep( 500 ); + CPPUNIT_ASSERT( infiniteTask.getCount() != 0 ); + infiniteTaskRunner.shutdown(); + int count = infiniteTask.getCount(); + Thread::sleep( 250 ); + CPPUNIT_ASSERT( infiniteTask.getCount() == count ); + +} Propchange: activemq/activemq-cpp/trunk/src/test/activemq/util/TaskRunnerTest.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/activemq-cpp/trunk/src/test/activemq/util/TaskRunnerTest.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/util/TaskRunnerTest.h?rev=752573&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/src/test/activemq/util/TaskRunnerTest.h (added) +++ activemq/activemq-cpp/trunk/src/test/activemq/util/TaskRunnerTest.h Wed Mar 11 18:55:53 2009 @@ -0,0 +1,44 @@ +/* + * 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 _ACTIVEMQ_UTIL_TASKRUNNERTEST_H_ +#define _ACTIVEMQ_UTIL_TASKRUNNERTEST_H_ + +#include +#include + +namespace activemq { +namespace util { + + class TaskRunnerTest : public CppUnit::TestFixture { + + CPPUNIT_TEST_SUITE( TaskRunnerTest ); + CPPUNIT_TEST( testSimple ); + CPPUNIT_TEST_SUITE_END(); + + public: + + TaskRunnerTest() {} + virtual ~TaskRunnerTest() {} + + void testSimple(); + + }; + +}} + +#endif /* _ACTIVEMQ_UTIL_TASKRUNNERTEST_H_ */ Propchange: activemq/activemq-cpp/trunk/src/test/activemq/util/TaskRunnerTest.h ------------------------------------------------------------------------------ svn:eol-style = native Modified: activemq/activemq-cpp/trunk/src/test/testRegistry.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/testRegistry.cpp?rev=752573&r1=752572&r2=752573&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/testRegistry.cpp (original) +++ activemq/activemq-cpp/trunk/src/test/testRegistry.cpp Wed Mar 11 18:55:53 2009 @@ -105,6 +105,8 @@ //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::URISupportTest ); //#include //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::MemoryUsageTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::TaskRunnerTest ); // //#include //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::wireformat::WireFormatRegistryTest );