Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71204 - in sandbox/guild/pool: boost/pool/detail libs/pool/example libs/pool/test
From: john_at_[hidden]
Date: 2011-04-12 12:15:15


Author: johnmaddock
Date: 2011-04-12 12:15:14 EDT (Tue, 12 Apr 2011)
New Revision: 71204
URL: http://svn.boost.org/trac/boost/changeset/71204

Log:
Change mutex to use Boost version.
Add example to test Jamfile.
Text files modified:
   sandbox/guild/pool/boost/pool/detail/mutex.hpp | 139 +--------------------------------------
   sandbox/guild/pool/libs/pool/example/sys_allocator.hpp | 9 ++
   sandbox/guild/pool/libs/pool/test/Jamfile.v2 | 1
   3 files changed, 16 insertions(+), 133 deletions(-)

Modified: sandbox/guild/pool/boost/pool/detail/mutex.hpp
==============================================================================
--- sandbox/guild/pool/boost/pool/detail/mutex.hpp (original)
+++ sandbox/guild/pool/boost/pool/detail/mutex.hpp 2011-04-12 12:15:14 EDT (Tue, 12 Apr 2011)
@@ -10,130 +10,11 @@
 #define BOOST_POOL_MUTEX_HPP
 
 #include <boost/config.hpp> // for workarounds
-
-/*!
-\file
-\brief Extremely Light-Weight wrapper classes for OS thread synchronization.
-\details detail/mutex.hpp provides several mutex types that provide a
-consistent interface for OS-supplied mutex types.
-These are all thread-level mutexes; interprocess mutexes are not supported.
-
-Configuration\n
-This header file will try to guess what kind of system it is on.
-It will auto-configure itself for Win32 or POSIX+pthread systems.
-To stub out all mutex code, bypassing the auto-configuration,
-define BOOST_NO_MT before any inclusion of this header.
-To prevent ODR violations, this should be defined
-in every translation unit in your project, including any library files.
-
-Note:
-Each mutex is always either owned or unowned.
-If owned, then it is owned by a particular thread.
-To "lock" a mutex means to wait until the mutex is unowned,
-and then make it owned by the current thread.
-To "unlock" a mutex means to release ownership from the current thread
-(note that the current thread must own the mutex to release that ownership!).
-As a special case, the null_mutex never waits.
-*/
-// Configuration: for now, we just choose between pthread or Win32 mutexes or none.
-
-#define BOOST_MUTEX_HELPER_NONE 0
-#define BOOST_MUTEX_HELPER_WIN32 1
-#define BOOST_MUTEX_HELPER_PTHREAD 2
-
-#if !defined(BOOST_HAS_THREADS) && !defined(BOOST_NO_MT)
-# define BOOST_NO_MT
-#endif
-
-#ifdef BOOST_NO_MT
- // No multithreading -> make locks into no-ops
- #define BOOST_MUTEX_HELPER BOOST_MUTEX_HELPER_NONE
-#else
- #ifdef BOOST_WINDOWS
- #define BOOST_MUTEX_HELPER BOOST_MUTEX_HELPER_WIN32
- #else
- #if defined(BOOST_HAS_UNISTD_H)
- #include <unistd.h>
- #endif
- #if defined(_POSIX_THREADS) || defined(BOOST_HAS_PTHREADS)
- #define BOOST_MUTEX_HELPER BOOST_MUTEX_HELPER_PTHREAD
- #endif
- #endif
+#ifdef BOOST_HAS_THREADS
+#include <boost/thread/mutex.hpp>
 #endif
 
-#ifndef BOOST_MUTEX_HELPER
- #error Unable to determine platform mutex type; define BOOST_NO_MT to assume single-threaded
-#endif
-
-#ifndef BOOST_NO_MT
-# ifdef BOOST_WINDOWS
-# include <windows.h>
-# endif
-# if defined(_POSIX_THREADS) || defined(BOOST_HAS_PTHREADS)
-# include <pthread.h>
-# endif
-#endif
-
-namespace boost {
-
-namespace details {
-namespace pool {
-
-#ifndef BOOST_NO_MT
-
-#ifdef BOOST_WINDOWS
-
-class win32_mutex
-{
- private:
- ::CRITICAL_SECTION mtx;
-
- win32_mutex(const win32_mutex &);
- void operator=(const win32_mutex &);
-
- public:
- win32_mutex()
- { ::InitializeCriticalSection(&mtx); }
-
- ~win32_mutex()
- { ::DeleteCriticalSection(&mtx); }
-
- void lock()
- { ::EnterCriticalSection(&mtx); }
-
- void unlock()
- { ::LeaveCriticalSection(&mtx); }
-};
-
-#endif // defined(BOOST_WINDOWS)
-
-#if defined(_POSIX_THREADS) || defined(BOOST_HAS_PTHREADS)
-
-class pthread_mutex
-{
- private:
- ::pthread_mutex_t mtx;
-
- pthread_mutex(const pthread_mutex &);
- void operator=(const pthread_mutex &);
-
- public:
- pthread_mutex()
- { ::pthread_mutex_init(&mtx, 0); }
-
- ~pthread_mutex()
- { ::pthread_mutex_destroy(&mtx); }
-
- void lock()
- { ::pthread_mutex_lock(&mtx); }
-
- void unlock()
- { ::pthread_mutex_unlock(&mtx); }
-};
-
-#endif // defined(_POSIX_THREADS) || defined(BOOST_HAS_PTHREADS)
-
-#endif // !defined(BOOST_NO_MT)
+namespace boost{ namespace details{ namespace pool{
 
 class null_mutex
 {
@@ -148,22 +29,14 @@
     static void unlock() { }
 };
 
-#if BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_NONE
+#if !defined(BOOST_HAS_THREADS) || defined(BOOST_NO_MT) || defined(BOOST_POOL_NO_MT)
   typedef null_mutex default_mutex;
-#elif BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_WIN32
- typedef win32_mutex default_mutex;
-#elif BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_PTHREAD
- typedef pthread_mutex default_mutex;
+#else
+ typedef boost::mutex default_mutex;
 #endif
 
 } // namespace pool
 } // namespace details
-
 } // namespace boost
 
-#undef BOOST_MUTEX_HELPER_WIN32
-#undef BOOST_MUTEX_HELPER_PTHREAD
-#undef BOOST_MUTEX_HELPER_NONE
-#undef BOOST_MUTEX_HELPER
-
 #endif

Modified: sandbox/guild/pool/libs/pool/example/sys_allocator.hpp
==============================================================================
--- sandbox/guild/pool/libs/pool/example/sys_allocator.hpp (original)
+++ sandbox/guild/pool/libs/pool/example/sys_allocator.hpp 2011-04-12 12:15:14 EDT (Tue, 12 Apr 2011)
@@ -7,6 +7,11 @@
 #ifndef BOOST_SYS_ALLOCATOR_H
 #define BOOST_SYS_ALLOCATOR_H
 
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4100)
+#endif
+
 // Symbols: malloc_allocator, new_delete_allocator
 
 #include <cstddef>
@@ -97,4 +102,8 @@
   { p->~T(); }
 };
 
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
 #endif

Modified: sandbox/guild/pool/libs/pool/test/Jamfile.v2
==============================================================================
--- sandbox/guild/pool/libs/pool/test/Jamfile.v2 (original)
+++ sandbox/guild/pool/libs/pool/test/Jamfile.v2 2011-04-12 12:15:14 EDT (Tue, 12 Apr 2011)
@@ -32,6 +32,7 @@
     [ run test_bug_4960.cpp ]
     [ run test_bug_1252.cpp ]
     [ run test_bug_2696.cpp ]
+ [ run ../example/time_pool_alloc.cpp ]
     [ compile test_poisoned_macros.cpp ]
 
 #


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk