Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49053 - in branches/bcbboost/boost: graph pool thread/pthread
From: nicola.musatti_at_[hidden]
Date: 2008-09-29 18:02:21


Author: nmusatti
Date: 2008-09-29 18:02:20 EDT (Mon, 29 Sep 2008)
New Revision: 49053
URL: http://svn.boost.org/trac/boost/changeset/49053

Log:
Merge from trunk
Text files modified:
   branches/bcbboost/boost/graph/sloan_ordering.hpp | 11 ++---
   branches/bcbboost/boost/graph/topological_sort.hpp | 2
   branches/bcbboost/boost/pool/pool_alloc.hpp | 77 +++++++++++++++++++++++++++++++++++----
   branches/bcbboost/boost/thread/pthread/recursive_mutex.hpp | 2
   branches/bcbboost/boost/thread/pthread/shared_mutex.hpp | 46 +++++++++++-----------
   5 files changed, 99 insertions(+), 39 deletions(-)

Modified: branches/bcbboost/boost/graph/sloan_ordering.hpp
==============================================================================
--- branches/bcbboost/boost/graph/sloan_ordering.hpp (original)
+++ branches/bcbboost/boost/graph/sloan_ordering.hpp 2008-09-29 18:02:20 EDT (Mon, 29 Sep 2008)
@@ -14,19 +14,18 @@
 
 #define WEIGHT1 1 //default weight for the distance in the Sloan algorithm
 #define WEIGHT2 2 //default weight for the degree in the Sloan algorithm
-#define MAXINT 2147483647 //Maximum value for a 32bit integer
 
 #include <boost/config.hpp>
 #include <vector>
 #include <queue>
+#include <algorithm>
+#include <limits>
 #include <boost/pending/queue.hpp>
 #include <boost/graph/graph_traits.hpp>
 #include <boost/graph/breadth_first_search.hpp>
 #include <boost/graph/properties.hpp>
 #include <boost/pending/indirect_cmp.hpp>
 #include <boost/property_map.hpp>
-#include <algorithm>
-#include <utility>
 #include <boost/graph/visitors.hpp>
 #include <boost/graph/adjacency_list.hpp>
 #include <boost/graph/cuthill_mckee_ordering.hpp>
@@ -195,9 +194,9 @@
       //end 3 & 4
 
       
- //step 5
- //Initializing w
- w_e = MAXINT;
+ // step 5
+ // Initializing w
+ w_e = std::numeric_limits<unsigned>::max();
       //end 5
       
       

Modified: branches/bcbboost/boost/graph/topological_sort.hpp
==============================================================================
--- branches/bcbboost/boost/graph/topological_sort.hpp (original)
+++ branches/bcbboost/boost/graph/topological_sort.hpp 2008-09-29 18:02:20 EDT (Mon, 29 Sep 2008)
@@ -37,7 +37,7 @@
       : m_iter(_iter) { }
     
     template <typename Edge, typename Graph>
- void back_edge(const Edge& u, Graph&) { throw not_a_dag(); }
+ void back_edge(const Edge&, Graph&) { throw not_a_dag(); }
     
     template <typename Vertex, typename Graph>
     void finish_vertex(const Vertex& u, Graph&) { *m_iter++ = u; }

Modified: branches/bcbboost/boost/pool/pool_alloc.hpp
==============================================================================
--- branches/bcbboost/boost/pool/pool_alloc.hpp (original)
+++ branches/bcbboost/boost/pool/pool_alloc.hpp 2008-09-29 18:02:20 EDT (Mon, 29 Sep 2008)
@@ -14,6 +14,7 @@
 // new, std::bad_alloc
 #include <new>
 
+#include <boost/throw_exception.hpp>
 #include <boost/pool/poolfwd.hpp>
 
 // boost::singleton_pool
@@ -57,7 +58,15 @@
     };
 
   public:
- pool_allocator() { }
+ pool_allocator()
+ {
+ // Required to ensure construction of singleton_pool IFF an
+ // instace of this allocator is constructed during global
+ // initialization. See ticket #2359 for a complete explaination
+ // ( http://svn.boost.org/trac/boost/ticket/2359 )
+ singleton_pool<pool_allocator_tag, sizeof(T), UserAllocator, Mutex,
+ NextSize>::is_from(0);
+ }
 
     // default copy constructor
 
@@ -66,7 +75,14 @@
     // not explicit, mimicking std::allocator [20.4.1]
     template <typename U>
     pool_allocator(const pool_allocator<U, UserAllocator, Mutex, NextSize> &)
- { }
+ {
+ // Required to ensure construction of singleton_pool IFF an
+ // instace of this allocator is constructed during global
+ // initialization. See ticket #2359 for a complete explaination
+ // ( http://svn.boost.org/trac/boost/ticket/2359 )
+ singleton_pool<pool_allocator_tag, sizeof(T), UserAllocator, Mutex,
+ NextSize>::is_from(0);
+ }
 
     // default destructor
 
@@ -95,7 +111,7 @@
           singleton_pool<pool_allocator_tag, sizeof(T), UserAllocator, Mutex,
               NextSize>::ordered_malloc(n) );
       if (ret == 0)
- throw std::bad_alloc();
+ boost::throw_exception(std::bad_alloc());
       return ret;
     }
     static pointer allocate(const size_type n, const void * const)
@@ -111,6 +127,21 @@
     }
 };
 
+template<
+ typename UserAllocator,
+ typename Mutex,
+ unsigned NextSize>
+class pool_allocator<void, UserAllocator, Mutex, NextSize>
+{
+public:
+ typedef void* pointer;
+ typedef const void* const_pointer;
+ typedef void value_type;
+ template <class U> struct rebind {
+ typedef pool_allocator<U, UserAllocator, Mutex, NextSize> other;
+ };
+};
+
 struct fast_pool_allocator_tag { };
 
 template <typename T,
@@ -139,8 +170,16 @@
     };
 
   public:
- fast_pool_allocator() { }
-
+ fast_pool_allocator()
+ {
+ // Required to ensure construction of singleton_pool IFF an
+ // instace of this allocator is constructed during global
+ // initialization. See ticket #2359 for a complete explaination
+ // ( http://svn.boost.org/trac/boost/ticket/2359 )
+ singleton_pool<fast_pool_allocator_tag, sizeof(T),
+ UserAllocator, Mutex, NextSize>::is_from(0);
+ }
+
     // default copy constructor
 
     // default assignment operator
@@ -149,7 +188,14 @@
     template <typename U>
     fast_pool_allocator(
         const fast_pool_allocator<U, UserAllocator, Mutex, NextSize> &)
- { }
+ {
+ // Required to ensure construction of singleton_pool IFF an
+ // instace of this allocator is constructed during global
+ // initialization. See ticket #2359 for a complete explaination
+ // ( http://svn.boost.org/trac/boost/ticket/2359 )
+ singleton_pool<fast_pool_allocator_tag, sizeof(T),
+ UserAllocator, Mutex, NextSize>::is_from(0);
+ }
 
     // default destructor
 
@@ -182,7 +228,7 @@
               singleton_pool<fast_pool_allocator_tag, sizeof(T),
                   UserAllocator, Mutex, NextSize>::ordered_malloc(n) );
       if (ret == 0)
- throw std::bad_alloc();
+ boost::throw_exception(std::bad_alloc());
       return ret;
     }
     static pointer allocate(const size_type n, const void * const)
@@ -193,7 +239,7 @@
           singleton_pool<fast_pool_allocator_tag, sizeof(T),
               UserAllocator, Mutex, NextSize>::malloc() );
       if (ret == 0)
- throw std::bad_alloc();
+ boost::throw_exception(std::bad_alloc());
       return ret;
     }
     static void deallocate(const pointer ptr, const size_type n)
@@ -216,6 +262,21 @@
     }
 };
 
+template<
+ typename UserAllocator,
+ typename Mutex,
+ unsigned NextSize>
+class fast_pool_allocator<void, UserAllocator, Mutex, NextSize>
+{
+public:
+ typedef void* pointer;
+ typedef const void* const_pointer;
+ typedef void value_type;
+ template <class U> struct rebind {
+ typedef fast_pool_allocator<U, UserAllocator, Mutex, NextSize> other;
+ };
+};
+
 } // namespace boost
 
 #endif

Modified: branches/bcbboost/boost/thread/pthread/recursive_mutex.hpp
==============================================================================
--- branches/bcbboost/boost/thread/pthread/recursive_mutex.hpp (original)
+++ branches/bcbboost/boost/thread/pthread/recursive_mutex.hpp 2008-09-29 18:02:20 EDT (Mon, 29 Sep 2008)
@@ -177,7 +177,7 @@
         {
             struct timespec const timeout=detail::get_timespec(abs_time);
             int const res=pthread_mutex_timedlock(&m,&timeout);
- BOOST_ASSERT(!res || res==EBUSY);
+ BOOST_ASSERT(!res || res==ETIMEDOUT);
             return !res;
         }
 

Modified: branches/bcbboost/boost/thread/pthread/shared_mutex.hpp
==============================================================================
--- branches/bcbboost/boost/thread/pthread/shared_mutex.hpp (original)
+++ branches/bcbboost/boost/thread/pthread/shared_mutex.hpp 2008-09-29 18:02:20 EDT (Mon, 29 Sep 2008)
@@ -57,18 +57,18 @@
         void lock_shared()
         {
             boost::this_thread::disable_interruption do_not_disturb;
- boost::mutex::scoped_lock lock(state_change);
+ boost::mutex::scoped_lock lk(state_change);
                 
             while(state.exclusive || state.exclusive_waiting_blocked)
             {
- shared_cond.wait(lock);
+ shared_cond.wait(lk);
             }
             ++state.shared_count;
         }
 
         bool try_lock_shared()
         {
- boost::mutex::scoped_lock lock(state_change);
+ boost::mutex::scoped_lock lk(state_change);
                 
             if(state.exclusive || state.exclusive_waiting_blocked)
             {
@@ -84,11 +84,11 @@
         bool timed_lock_shared(system_time const& timeout)
         {
             boost::this_thread::disable_interruption do_not_disturb;
- boost::mutex::scoped_lock lock(state_change);
+ boost::mutex::scoped_lock lk(state_change);
                 
             while(state.exclusive || state.exclusive_waiting_blocked)
             {
- if(!shared_cond.timed_wait(lock,timeout))
+ if(!shared_cond.timed_wait(lk,timeout))
                 {
                     return false;
                 }
@@ -105,7 +105,7 @@
 
         void unlock_shared()
         {
- boost::mutex::scoped_lock lock(state_change);
+ boost::mutex::scoped_lock lk(state_change);
             bool const last_reader=!--state.shared_count;
                 
             if(last_reader)
@@ -127,12 +127,12 @@
         void lock()
         {
             boost::this_thread::disable_interruption do_not_disturb;
- boost::mutex::scoped_lock lock(state_change);
+ boost::mutex::scoped_lock lk(state_change);
                 
             while(state.shared_count || state.exclusive)
             {
                 state.exclusive_waiting_blocked=true;
- exclusive_cond.wait(lock);
+ exclusive_cond.wait(lk);
             }
             state.exclusive=true;
         }
@@ -140,12 +140,12 @@
         bool timed_lock(system_time const& timeout)
         {
             boost::this_thread::disable_interruption do_not_disturb;
- boost::mutex::scoped_lock lock(state_change);
+ boost::mutex::scoped_lock lk(state_change);
 
             while(state.shared_count || state.exclusive)
             {
                 state.exclusive_waiting_blocked=true;
- if(!exclusive_cond.timed_wait(lock,timeout))
+ if(!exclusive_cond.timed_wait(lk,timeout))
                 {
                     if(state.shared_count || state.exclusive)
                     {
@@ -168,7 +168,7 @@
 
         bool try_lock()
         {
- boost::mutex::scoped_lock lock(state_change);
+ boost::mutex::scoped_lock lk(state_change);
                 
             if(state.shared_count || state.exclusive)
             {
@@ -184,7 +184,7 @@
 
         void unlock()
         {
- boost::mutex::scoped_lock lock(state_change);
+ boost::mutex::scoped_lock lk(state_change);
             state.exclusive=false;
             state.exclusive_waiting_blocked=false;
             release_waiters();
@@ -193,10 +193,10 @@
         void lock_upgrade()
         {
             boost::this_thread::disable_interruption do_not_disturb;
- boost::mutex::scoped_lock lock(state_change);
+ boost::mutex::scoped_lock lk(state_change);
             while(state.exclusive || state.exclusive_waiting_blocked || state.upgrade)
             {
- shared_cond.wait(lock);
+ shared_cond.wait(lk);
             }
             ++state.shared_count;
             state.upgrade=true;
@@ -205,10 +205,10 @@
         bool timed_lock_upgrade(system_time const& timeout)
         {
             boost::this_thread::disable_interruption do_not_disturb;
- boost::mutex::scoped_lock lock(state_change);
+ boost::mutex::scoped_lock lk(state_change);
             while(state.exclusive || state.exclusive_waiting_blocked || state.upgrade)
             {
- if(!shared_cond.timed_wait(lock,timeout))
+ if(!shared_cond.timed_wait(lk,timeout))
                 {
                     if(state.exclusive || state.exclusive_waiting_blocked || state.upgrade)
                     {
@@ -230,7 +230,7 @@
 
         bool try_lock_upgrade()
         {
- boost::mutex::scoped_lock lock(state_change);
+ boost::mutex::scoped_lock lk(state_change);
             if(state.exclusive || state.exclusive_waiting_blocked || state.upgrade)
             {
                 return false;
@@ -245,7 +245,7 @@
 
         void unlock_upgrade()
         {
- boost::mutex::scoped_lock lock(state_change);
+ boost::mutex::scoped_lock lk(state_change);
             state.upgrade=false;
             bool const last_reader=!--state.shared_count;
                 
@@ -259,11 +259,11 @@
         void unlock_upgrade_and_lock()
         {
             boost::this_thread::disable_interruption do_not_disturb;
- boost::mutex::scoped_lock lock(state_change);
+ boost::mutex::scoped_lock lk(state_change);
             --state.shared_count;
             while(state.shared_count)
             {
- upgrade_cond.wait(lock);
+ upgrade_cond.wait(lk);
             }
             state.upgrade=false;
             state.exclusive=true;
@@ -271,7 +271,7 @@
 
         void unlock_and_lock_upgrade()
         {
- boost::mutex::scoped_lock lock(state_change);
+ boost::mutex::scoped_lock lk(state_change);
             state.exclusive=false;
             state.upgrade=true;
             ++state.shared_count;
@@ -281,7 +281,7 @@
         
         void unlock_and_lock_shared()
         {
- boost::mutex::scoped_lock lock(state_change);
+ boost::mutex::scoped_lock lk(state_change);
             state.exclusive=false;
             ++state.shared_count;
             state.exclusive_waiting_blocked=false;
@@ -290,7 +290,7 @@
         
         void unlock_upgrade_and_lock_shared()
         {
- boost::mutex::scoped_lock lock(state_change);
+ boost::mutex::scoped_lock lk(state_change);
             state.upgrade=false;
             state.exclusive_waiting_blocked=false;
             release_waiters();


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