|
From: <ric...@us...> - 2008-11-10 05:47:12
|
Revision: 902
http://loki-lib.svn.sourceforge.net/loki-lib/?rev=902&view=rev
Author: rich_sposato
Date: 2008-11-10 05:47:06 +0000 (Mon, 10 Nov 2008)
Log Message:
-----------
Added several more atomic functions.
Modified Paths:
--------------
trunk/include/loki/Threads.h
Modified: trunk/include/loki/Threads.h
===================================================================
--- trunk/include/loki/Threads.h 2008-10-07 04:46:34 UTC (rev 901)
+++ trunk/include/loki/Threads.h 2008-11-10 05:47:06 UTC (rev 902)
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Wesley Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_THREADS_INC_
@@ -27,12 +27,12 @@
///
/// All classes in Loki have configurable threading model.
///
-/// The macro LOKI_DEFAULT_THREADING selects the default
-/// threading model for certain components of Loki
+/// The macro LOKI_DEFAULT_THREADING selects the default
+/// threading model for certain components of Loki
/// (it affects only default template arguments)
-///
+///
/// \par Usage:
-///
+///
/// To use a specific threading model define
///
/// - nothing, single-theading is default
@@ -43,9 +43,9 @@
///
/// - Windows (windows.h)
/// - POSIX (pthread.h):
-/// No recursive mutex support with pthread.
-/// This means: calling Lock() on a Loki::Mutex twice from the
-/// same thread before unlocking the mutex deadlocks the system.
+/// No recursive mutex support with pthread.
+/// This means: calling Lock() on a Loki::Mutex twice from the
+/// same thread before unlocking the mutex deadlocks the system.
/// To avoid this redesign your synchronization. See also:
/// http://sourceforge.net/tracker/index.php?func=detail&aid=1516182&group_id=29557&atid=396647
@@ -55,28 +55,28 @@
#if defined(LOKI_CLASS_LEVEL_THREADING) || defined(LOKI_OBJECT_LEVEL_THREADING)
#define LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL ::Loki::ClassLevelLockable
-
+
#if defined(LOKI_CLASS_LEVEL_THREADING) && !defined(LOKI_OBJECT_LEVEL_THREADING)
#define LOKI_DEFAULT_THREADING ::Loki::ClassLevelLockable
#else
#define LOKI_DEFAULT_THREADING ::Loki::ObjectLevelLockable
#endif
-
+
#if defined(_WIN32) || defined(_WIN64)
- #include <windows.h>
+ #include <windows.h>
#define LOKI_WINDOWS_H
#else
#include <pthread.h>
#define LOKI_PTHREAD_H
#endif
-
+
#else
#define LOKI_DEFAULT_THREADING ::Loki::SingleThreaded
#define LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL ::Loki::SingleThreaded
-
+
#endif
-
+
#ifndef LOKI_DEFAULT_MUTEX
#define LOKI_DEFAULT_MUTEX ::Loki::Mutex
#endif
@@ -92,20 +92,98 @@
#define LOKI_THREADS_MUTEX_CTOR(x)
#define LOKI_THREADS_ATOMIC_FUNCTIONS \
+ static IntType AtomicMultiply(volatile IntType& lval, const IntType val) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ lval *= val; \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicDivide(volatile IntType& lval, const IntType val) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ lval /= val; \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
static IntType AtomicIncrement(volatile IntType& lval) \
- { return InterlockedIncrement(&const_cast<IntType&>(lval)); } \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ ++lval; \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
\
static IntType AtomicDecrement(volatile IntType& lval) \
- { return InterlockedDecrement(&const_cast<IntType&>(lval)); } \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ --lval; \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
\
- static void AtomicAssign(volatile IntType& lval, IntType val) \
+ static void AtomicAssign(volatile IntType& lval, const IntType val) \
{ InterlockedExchange(&const_cast<IntType&>(lval), val); } \
\
- static void AtomicAssign(IntType& lval, volatile IntType& val) \
- { InterlockedExchange(&lval, val); }
+ static void AtomicAssign(IntType& lval, volatile const IntType& val) \
+ { InterlockedExchange(&lval, val); } \
+ \
+ static IntType AtomicIncrement(volatile IntType& lval, const IntType compare, bool & matches ) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ ++lval; \
+ matches = ( lval == compare ); \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicDecrement(volatile IntType& lval, const IntType compare, bool & matches ) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ --lval; \
+ matches = ( lval == compare ); \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicAdd(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ lval += val; \
+ matches = ( lval == compare ); \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicSubtract(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ lval -= val; \
+ matches = ( lval == compare ); \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicMultiply(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ lval *= val; \
+ matches = ( lval == compare ); \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicDivide(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ lval /= val; \
+ matches = ( lval == compare ); \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ }
-
-
#elif defined(LOKI_PTHREAD_H)
@@ -130,32 +208,103 @@
#define LOKI_THREADS_ATOMIC(x) \
pthread_mutex_lock(&atomic_mutex_); \
x; \
- pthread_mutex_unlock(&atomic_mutex_)
-
-#define LOKI_THREADS_ATOMIC_FUNCTIONS \
- private: \
- static pthread_mutex_t atomic_mutex_; \
- public: \
+ pthread_mutex_unlock(&atomic_mutex_)
+
+#define LOKI_THREADS_ATOMIC_FUNCTIONS \
+ private: \
+ static pthread_mutex_t atomic_mutex_; \
+ public: \
+ static IntType AtomicMultiply(volatile IntType& lval, const IntType val) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ lval *= val; \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicDivide(volatile IntType& lval, const IntType val) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ lval /= val; \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
static IntType AtomicIncrement(volatile IntType& lval) \
- { LOKI_THREADS_ATOMIC( lval++ ); return lval; } \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ ++lval; \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
\
static IntType AtomicDecrement(volatile IntType& lval) \
- { LOKI_THREADS_ATOMIC(lval-- ); return lval; } \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ --lval; \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
\
- static void AtomicAssign(volatile IntType& lval, IntType val) \
- { LOKI_THREADS_ATOMIC( lval = val ); } \
+ static void AtomicAssign(volatile IntType& lval, const IntType val) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ lval = val; \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
\
- static void AtomicAssign(IntType& lval, volatile IntType& val) \
- { LOKI_THREADS_ATOMIC( lval = val ); }
+ static void AtomicAssign(IntType& lval, volatile const IntType& val) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ lval = val; \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicIncrement(volatile IntType& lval, const IntType compare, bool & matches ) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ ++lval; \
+ matches = ( compare == lval ); \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicDecrement(volatile IntType& lval, const IntType compare, bool & matches ) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ --lval; \
+ matches = ( compare == lval ); \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ static IntType AtomicMultiply(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ lval *= val; \
+ matches = ( lval == compare ); \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicDivide(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ lval /= val; \
+ matches = ( lval == compare ); \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ }
#else // single threaded
#define LOKI_THREADS_MUTEX(x)
-#define LOKI_THREADS_MUTEX_INIT(x)
-#define LOKI_THREADS_MUTEX_DELETE(x)
-#define LOKI_THREADS_MUTEX_LOCK(x)
-#define LOKI_THREADS_MUTEX_UNLOCK(x)
-#define LOKI_THREADS_LONG
+#define LOKI_THREADS_MUTEX_INIT(x)
+#define LOKI_THREADS_MUTEX_DELETE(x)
+#define LOKI_THREADS_MUTEX_LOCK(x)
+#define LOKI_THREADS_MUTEX_UNLOCK(x)
+#define LOKI_THREADS_LONG
#define LOKI_THREADS_MUTEX_CTOR(x)
#endif
@@ -219,39 +368,82 @@
explicit Lock(const SingleThreaded&) {}
explicit Lock(const SingleThreaded*) {}
};
-
+
typedef Host VolatileType;
- typedef int IntType;
+ typedef int IntType;
- static IntType AtomicAdd(volatile IntType& lval, IntType val)
+ static IntType AtomicAdd(volatile IntType& lval, const IntType val)
{ return lval += val; }
-
- static IntType AtomicSubtract(volatile IntType& lval, IntType val)
+
+ static IntType AtomicSubtract(volatile IntType& lval, const IntType val)
{ return lval -= val; }
- static IntType AtomicMultiply(volatile IntType& lval, IntType val)
+ static IntType AtomicMultiply(volatile IntType& lval, const IntType val)
{ return lval *= val; }
-
- static IntType AtomicDivide(volatile IntType& lval, IntType val)
+
+ static IntType AtomicDivide(volatile IntType& lval, const IntType val)
{ return lval /= val; }
-
+
static IntType AtomicIncrement(volatile IntType& lval)
{ return ++lval; }
-
+
static IntType AtomicDecrement(volatile IntType& lval)
{ return --lval; }
-
- static void AtomicAssign(volatile IntType & lval, IntType val)
+
+ static void AtomicAssign(volatile IntType & lval, const IntType val)
{ lval = val; }
-
+
static void AtomicAssign(IntType & lval, volatile IntType & val)
{ lval = val; }
+
+ static IntType AtomicAdd(volatile IntType& lval, const IntType val, const IntType compare, bool & matches )
+ {
+ lval += val;
+ matches = ( lval == compare );
+ return lval;
+ }
+
+ static IntType AtomicSubtract(volatile IntType& lval, const IntType val, const IntType compare, bool & matches )
+ {
+ lval -= val;
+ matches = ( lval == compare );
+ return lval;
+ }
+
+ static IntType AtomicMultiply(volatile IntType& lval, const IntType val, const IntType compare, bool & matches )
+ {
+ lval *= val;
+ matches = ( lval == compare );
+ return lval;
+ }
+
+ static IntType AtomicDivide(volatile IntType& lval, const IntType val, const IntType compare, bool & matches )
+ {
+ lval /= val;
+ matches = ( lval == compare );
+ return lval;
+ }
+
+ static IntType AtomicIncrement(volatile IntType& lval, const IntType compare, bool & matches )
+ {
+ ++lval;
+ matches = ( lval == compare );
+ return lval;
+ }
+
+ static IntType AtomicDecrement(volatile IntType& lval, const IntType compare, bool & matches )
+ {
+ --lval;
+ matches = ( lval == compare );
+ return lval;
+ }
+
};
-
-#if defined(LOKI_WINDOWS_H) || defined(LOKI_PTHREAD_H)
+#if defined(LOKI_WINDOWS_H) || defined(LOKI_PTHREAD_H)
+
////////////////////////////////////////////////////////////////////////////////
/// \class ObjectLevelLockable
///
@@ -273,13 +465,13 @@
class Lock;
friend class Lock;
-
+
/// \struct Lock
/// Lock class to lock on object level
class Lock
- {
+ {
public:
-
+
/// Lock object
explicit Lock(const ObjectLevelLockable& host) : host_(host)
{
@@ -308,17 +500,17 @@
typedef volatile Host VolatileType;
- typedef LOKI_THREADS_LONG IntType;
-
- LOKI_THREADS_ATOMIC_FUNCTIONS
-
+ typedef LOKI_THREADS_LONG IntType;
+
+ LOKI_THREADS_ATOMIC_FUNCTIONS
+
};
#ifdef LOKI_PTHREAD_H
template <class Host, class MutexPolicy>
pthread_mutex_t ObjectLevelLockable<Host, MutexPolicy>::atomic_mutex_ = PTHREAD_MUTEX_INITIALIZER;
#endif
-
+
////////////////////////////////////////////////////////////////////////////////
/// \class ClassLevelLockable
///
@@ -330,7 +522,7 @@
class ClassLevelLockable
{
struct Initializer
- {
+ {
bool init_;
MutexPolicy mtx_;
@@ -355,7 +547,7 @@
/// \struct Lock
/// Lock class to lock on class level
class Lock
- {
+ {
public:
/// Lock class
@@ -393,23 +585,23 @@
typedef volatile Host VolatileType;
- typedef LOKI_THREADS_LONG IntType;
+ typedef LOKI_THREADS_LONG IntType;
LOKI_THREADS_ATOMIC_FUNCTIONS
-
+
};
-#ifdef LOKI_PTHREAD_H
+#ifdef LOKI_PTHREAD_H
template <class Host, class MutexPolicy>
pthread_mutex_t ClassLevelLockable<Host, MutexPolicy>::atomic_mutex_ = PTHREAD_MUTEX_INITIALIZER;
#endif
template < class Host, class MutexPolicy >
- typename ClassLevelLockable< Host, MutexPolicy >::Initializer
+ typename ClassLevelLockable< Host, MutexPolicy >::Initializer
ClassLevelLockable< Host, MutexPolicy >::initializer_;
-#endif // #if defined(LOKI_WINDOWS_H) || defined(LOKI_PTHREAD_H)
-
+#endif // #if defined(LOKI_WINDOWS_H) || defined(LOKI_PTHREAD_H)
+
} // namespace Loki
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ric...@us...> - 2009-02-02 07:45:56
|
Revision: 985
http://loki-lib.svn.sourceforge.net/loki-lib/?rev=985&view=rev
Author: rich_sposato
Date: 2009-02-02 07:45:50 +0000 (Mon, 02 Feb 2009)
Log Message:
-----------
Fixed bug 1776032 by changing class to singleton.
Modified Paths:
--------------
trunk/include/loki/Threads.h
Modified: trunk/include/loki/Threads.h
===================================================================
--- trunk/include/loki/Threads.h 2009-02-02 06:23:28 UTC (rev 984)
+++ trunk/include/loki/Threads.h 2009-02-02 07:45:50 UTC (rev 985)
@@ -523,6 +523,19 @@
{
struct Initializer
{
+
+ /// This function provides a Scott-Meyers type of Singleton as the initializer
+ /// for the shared mutex.
+ static Initializer & GetIt( void )
+ {
+ static Initializer initializer_;
+ return initializer_;
+ }
+
+ inline bool IsInit( void ) { return init_; }
+ inline MutexPolicy & GetMutex( void ) { return mtx_; }
+
+ private:
bool init_;
MutexPolicy mtx_;
@@ -535,10 +548,11 @@
{
assert(init_);
}
+
+ Initializer( const Initializer & );
+ Initializer & operator = ( const Initializer & );
};
- static Initializer initializer_;
-
public:
class Lock;
@@ -553,29 +567,33 @@
/// Lock class
Lock()
{
- assert(initializer_.init_);
- initializer_.mtx_.Lock();
+ Initializer & initializer = Initializer::GetIt();
+ assert( initializer.IsInit() );
+ initializer.GetMutex().Lock();
}
/// Lock class
explicit Lock(const ClassLevelLockable&)
{
- assert(initializer_.init_);
- initializer_.mtx_.Lock();
+ Initializer & initializer = Initializer::GetIt();
+ assert( initializer.IsInit() );
+ initializer.GetMutex().Lock();
}
/// Lock class
explicit Lock(const ClassLevelLockable*)
{
- assert(initializer_.init_);
- initializer_.mtx_.Lock();
+ Initializer & initializer = Initializer::GetIt();
+ assert( initializer.IsInit() );
+ initializer.GetMutex().Lock();
}
/// Unlock class
~Lock()
{
- assert(initializer_.init_);
- initializer_.mtx_.Unlock();
+ Initializer & initializer = Initializer::GetIt();
+ assert( initializer.IsInit() );
+ initializer.GetMutex().Unlock();
}
private:
@@ -596,10 +614,6 @@
pthread_mutex_t ClassLevelLockable<Host, MutexPolicy>::atomic_mutex_ = PTHREAD_MUTEX_INITIALIZER;
#endif
- template < class Host, class MutexPolicy >
- typename ClassLevelLockable< Host, MutexPolicy >::Initializer
- ClassLevelLockable< Host, MutexPolicy >::initializer_;
-
#endif // #if defined(LOKI_WINDOWS_H) || defined(LOKI_PTHREAD_H)
} // namespace Loki
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <syn...@us...> - 2009-08-16 20:30:16
|
Revision: 1015
http://loki-lib.svn.sourceforge.net/loki-lib/?rev=1015&view=rev
Author: syntheticpp
Date: 2009-08-16 20:29:58 +0000 (Sun, 16 Aug 2009)
Log Message:
-----------
fix bug
https://sourceforge.net/tracker/?func=detail&atid=396644&aid=2807089&group_id=29557
Modified Paths:
--------------
trunk/include/loki/Threads.h
Modified: trunk/include/loki/Threads.h
===================================================================
--- trunk/include/loki/Threads.h 2009-04-11 06:02:59 UTC (rev 1014)
+++ trunk/include/loki/Threads.h 2009-08-16 20:29:58 UTC (rev 1015)
@@ -92,6 +92,9 @@
#define LOKI_THREADS_MUTEX_CTOR(x)
#define LOKI_THREADS_ATOMIC_FUNCTIONS \
+ private: \
+ static CRITICAL_SECTION atomic_mutex_; \
+ public: \
static IntType AtomicMultiply(volatile IntType& lval, const IntType val) \
{ \
::EnterCriticalSection( &atomic_mutex_ ); \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ric...@us...> - 2011-06-21 03:32:25
|
Revision: 1086
http://loki-lib.svn.sourceforge.net/loki-lib/?rev=1086&view=rev
Author: rich_sposato
Date: 2011-06-21 03:32:19 +0000 (Tue, 21 Jun 2011)
Log Message:
-----------
Minor changes to preprocessor statements.
Modified Paths:
--------------
trunk/include/loki/Threads.h
Modified: trunk/include/loki/Threads.h
===================================================================
--- trunk/include/loki/Threads.h 2011-06-21 03:29:50 UTC (rev 1085)
+++ trunk/include/loki/Threads.h 2011-06-21 03:32:19 UTC (rev 1086)
@@ -52,7 +52,7 @@
#include <cassert>
-#if defined(LOKI_CLASS_LEVEL_THREADING) || defined(LOKI_OBJECT_LEVEL_THREADING)
+#if defined( LOKI_CLASS_LEVEL_THREADING ) || defined( LOKI_OBJECT_LEVEL_THREADING )
#define LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL ::Loki::ClassLevelLockable
@@ -77,11 +77,11 @@
#endif
-#ifndef LOKI_DEFAULT_MUTEX
-#define LOKI_DEFAULT_MUTEX ::Loki::Mutex
+#if !defined( LOKI_DEFAULT_MUTEX )
+ #define LOKI_DEFAULT_MUTEX ::Loki::Mutex
#endif
-#ifdef LOKI_WINDOWS_H
+#if defined( LOKI_WINDOWS_H )
#define LOKI_THREADS_MUTEX(x) CRITICAL_SECTION (x);
#define LOKI_THREADS_MUTEX_INIT(x) ::InitializeCriticalSection (x)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ric...@us...> - 2011-09-06 23:21:44
|
Revision: 1090
http://loki-lib.svn.sourceforge.net/loki-lib/?rev=1090&view=rev
Author: rich_sposato
Date: 2011-09-06 23:21:38 +0000 (Tue, 06 Sep 2011)
Log Message:
-----------
Added return type and return statements to fix bug 3399654.
Modified Paths:
--------------
trunk/include/loki/Threads.h
Modified: trunk/include/loki/Threads.h
===================================================================
--- trunk/include/loki/Threads.h 2011-09-06 23:01:26 UTC (rev 1089)
+++ trunk/include/loki/Threads.h 2011-09-06 23:21:38 UTC (rev 1090)
@@ -127,11 +127,17 @@
return lval; \
} \
\
- static void AtomicAssign(volatile IntType& lval, const IntType val) \
- { InterlockedExchange(&const_cast<IntType&>(lval), val); } \
+ static IntType AtomicAssign(volatile IntType& lval, const IntType val) \
+ { \
+ InterlockedExchange(&const_cast<IntType&>(lval), val); \
+ return lval; \
+ } \
\
- static void AtomicAssign(IntType& lval, volatile const IntType& val) \
- { InterlockedExchange(&lval, val); } \
+ static IntType AtomicAssign(IntType& lval, volatile const IntType& val) \
+ { \
+ InterlockedExchange(&lval, val); \
+ return lval; \
+ } \
\
static IntType AtomicIncrement(volatile IntType& lval, const IntType compare, bool & matches ) \
{ \
@@ -249,7 +255,7 @@
return lval; \
} \
\
- static void AtomicAssign(volatile IntType& lval, const IntType val) \
+ static IntType AtomicAssign(volatile IntType& lval, const IntType val) \
{ \
::pthread_mutex_lock( &atomic_mutex_ ); \
lval = val; \
@@ -257,7 +263,7 @@
return lval; \
} \
\
- static void AtomicAssign(IntType& lval, volatile const IntType& val) \
+ static IntType AtomicAssign(IntType& lval, volatile const IntType& val) \
{ \
::pthread_mutex_lock( &atomic_mutex_ ); \
lval = val; \
@@ -394,11 +400,17 @@
static IntType AtomicDecrement(volatile IntType& lval)
{ return --lval; }
- static void AtomicAssign(volatile IntType & lval, const IntType val)
- { lval = val; }
+ static IntType AtomicAssign(volatile IntType & lval, const IntType val)
+ {
+ lval = val;
+ return lval;
+ }
- static void AtomicAssign(IntType & lval, volatile IntType & val)
- { lval = val; }
+ static IntType AtomicAssign(IntType & lval, volatile IntType & val)
+ {
+ lval = val;
+ return lval;
+ }
static IntType AtomicAdd(volatile IntType& lval, const IntType val, const IntType compare, bool & matches )
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|