Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 31999 invoked from network); 21 Mar 2010 21:55:13 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 21 Mar 2010 21:55:13 -0000 Received: (qmail 39193 invoked by uid 500); 21 Mar 2010 21:55:10 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 39166 invoked by uid 500); 21 Mar 2010 21:55:09 -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 39159 invoked by uid 99); 21 Mar 2010 21:55:09 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 Mar 2010 21:55:09 +0000 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; Sun, 21 Mar 2010 21:55:07 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id DACD723888DD; Sun, 21 Mar 2010 21:54:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r925906 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main: Makefile.am decaf/lang/Exception.h decaf/util/concurrent/Lock.cpp decaf/util/concurrent/Lock.h Date: Sun, 21 Mar 2010 21:54:45 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100321215445.DACD723888DD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Sun Mar 21 21:54:45 2010 New Revision: 925906 URL: http://svn.apache.org/viewvc?rev=925906&view=rev Log: Fix for warnings generated by gcc with -Weffc++ enabled. Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Lock.cpp (with props) Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Exception.h activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Lock.h 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=925906&r1=925905&r2=925906&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Sun Mar 21 21:54:45 2010 @@ -568,6 +568,7 @@ cc_sources = \ decaf/util/TimerTask.cpp \ decaf/util/UUID.cpp \ decaf/util/concurrent/CountDownLatch.cpp \ + decaf/util/concurrent/Lock.cpp \ decaf/util/concurrent/Mutex.cpp \ decaf/util/concurrent/PooledThread.cpp \ decaf/util/concurrent/Semaphore.cpp \ Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Exception.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Exception.h?rev=925906&r1=925905&r2=925906&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Exception.h (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Exception.h Sun Mar 21 21:54:45 2010 @@ -191,7 +191,7 @@ namespace lang{ * Assignment operator. * @param ex const reference to another Exception */ - virtual Exception& operator =( const Exception& ex ); + Exception& operator =( const Exception& ex ); protected: Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Lock.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Lock.cpp?rev=925906&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Lock.cpp (added) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Lock.cpp Sun Mar 21 21:54:45 2010 @@ -0,0 +1,72 @@ +/* + * 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 "Lock.h" + +#include + +using namespace decaf; +using namespace decaf::util; +using namespace decaf::util::concurrent; +using namespace decaf::lang; + +//////////////////////////////////////////////////////////////////////////////// +Lock::Lock( Synchronizable* object, const bool intiallyLocked ) : syncObject( object ), locked( false ) { + + try{ + if( intiallyLocked ) { + lock(); + } + } + DECAF_CATCH_RETHROW( lang::Exception ) + DECAF_CATCHALL_THROW( lang::Exception ) +} + +//////////////////////////////////////////////////////////////////////////////// +Lock::~Lock() { + + try{ + if( locked ) { + syncObject->unlock(); + } + } + DECAF_CATCH_NOTHROW( Exception ) + DECAF_CATCHALL_NOTHROW() +} + +//////////////////////////////////////////////////////////////////////////////// +void Lock::lock() { + try{ + syncObject->lock(); + locked = true; + } + DECAF_CATCH_RETHROW( Exception ) + DECAF_CATCHALL_THROW( Exception ) +} + +//////////////////////////////////////////////////////////////////////////////// +void Lock::unlock() { + + try{ + if( locked ) { + syncObject->unlock(); + locked = false; + } + } + DECAF_CATCH_RETHROW( Exception ) + DECAF_CATCHALL_THROW( Exception ) +} Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Lock.cpp ------------------------------------------------------------------------------ svn:eol-style = native Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Lock.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Lock.h?rev=925906&r1=925905&r2=925906&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Lock.h (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Lock.h Sun Mar 21 21:54:45 2010 @@ -18,7 +18,6 @@ #ifndef _DECAF_UTIL_CONCURRENT_LOCK_H_ #define _DECAF_UTIL_CONCURRENT_LOCK_H_ -#include #include #include @@ -32,14 +31,14 @@ namespace concurrent{ * * @since 1.0 */ - class Lock { + class DECAF_API Lock { private: /** * Flag to indicate whether or not this object has locked the * sync object. */ - bool locked; + volatile bool locked; /** * The synchronizable object to lock/unlock. @@ -56,71 +55,36 @@ namespace concurrent{ /** * Constructor - initializes the object member and locks * the object if desired. - * @param object The sync object to control - * @param intiallyLocked If true, the object will automatically - * be locked. - */ - Lock( Synchronizable* object, const bool intiallyLocked = true ) { - - try{ - syncObject = object; - locked = false; - - if( intiallyLocked ) { - lock(); - } - } - DECAF_CATCH_RETHROW( lang::Exception ) - DECAF_CATCHALL_THROW( lang::Exception ) - } + * + * @param object + * The sync object to control + * @param intiallyLocked + * If true, the object will automatically be locked. + */ + Lock( Synchronizable* object, const bool intiallyLocked = true ); /** * Destructor - Unlocks the object if it is locked. */ - virtual ~Lock() { - try{ - - if( locked ) { - syncObject->unlock(); - } - } - DECAF_CATCH_RETHROW( lang::Exception ) - DECAF_CATCHALL_THROW( lang::Exception ) - } + virtual ~Lock(); /** * Locks the object. */ - void lock() { - try{ - syncObject->lock(); - locked = true; - } - DECAF_CATCH_RETHROW( lang::Exception ) - DECAF_CATCHALL_THROW( lang::Exception ) - } + void lock(); /** * Unlocks the object if it is already locked, otherwise a call to this method has * no effect. */ - void unlock() { - - try{ - if( locked ) { - syncObject->unlock(); - locked = false; - } - } - DECAF_CATCH_RETHROW( lang::Exception ) - DECAF_CATCHALL_THROW( lang::Exception ) - } + void unlock(); /** * Indicates whether or not the object is locked. * @return true if the object is locked, otherwise false. */ bool isLocked() const{ return locked; } + }; }}}