|
Boost-Commit : |
From: anthony_at_[hidden]
Date: 2007-11-05 09:16:23
Author: anthonyw
Date: 2007-11-05 09:16:21 EST (Mon, 05 Nov 2007)
New Revision: 40787
URL: http://svn.boost.org/trac/boost/changeset/40787
Log:
Use pthread_equal for comparing pthread_t IDs; use BOOST_VERIFY instead of BOOST_ASSERT in many places in order to avoid unused variable warnings
Text files modified:
trunk/boost/thread/pthread/condition_variable.hpp | 18 +++++++++---------
trunk/boost/thread/pthread/mutex.hpp | 20 ++++++++++----------
trunk/boost/thread/pthread/once.hpp | 25 ++++---------------------
trunk/boost/thread/pthread/pthread_mutex_scoped_lock.hpp | 4 ++--
trunk/boost/thread/pthread/recursive_mutex.hpp | 32 ++++++++++++++++----------------
trunk/boost/thread/win32/basic_timed_mutex.hpp | 3 +--
trunk/boost/thread/win32/condition_variable.hpp | 3 +--
trunk/boost/thread/win32/once.hpp | 6 ++----
trunk/boost/thread/win32/shared_mutex.hpp | 21 +++++++--------------
trunk/boost/thread/win32/thread_primitives.hpp | 6 ++----
trunk/libs/thread/src/pthread/thread.cpp | 18 +++++++++---------
trunk/libs/thread/src/pthread/tss.cpp | 5 -----
12 files changed, 63 insertions(+), 98 deletions(-)
Modified: trunk/boost/thread/pthread/condition_variable.hpp
==============================================================================
--- trunk/boost/thread/pthread/condition_variable.hpp (original)
+++ trunk/boost/thread/pthread/condition_variable.hpp 2007-11-05 09:16:21 EST (Mon, 05 Nov 2007)
@@ -28,13 +28,13 @@
}
inline condition_variable::~condition_variable()
{
- BOOST_VERIFY(0==pthread_cond_destroy(&cond));
+ BOOST_VERIFY(!pthread_cond_destroy(&cond));
}
inline void condition_variable::wait(unique_lock<mutex>& m)
{
detail::interruption_checker check_for_interruption(&cond);
- BOOST_VERIFY(0==pthread_cond_wait(&cond,m.mutex()->native_handle()));
+ BOOST_VERIFY(!pthread_cond_wait(&cond,m.mutex()->native_handle()));
}
inline bool condition_variable::timed_wait(unique_lock<mutex>& m,boost::system_time const& wait_until)
@@ -52,12 +52,12 @@
inline void condition_variable::notify_one()
{
- BOOST_VERIFY(0==pthread_cond_signal(&cond));
+ BOOST_VERIFY(!pthread_cond_signal(&cond));
}
inline void condition_variable::notify_all()
{
- BOOST_VERIFY(0==pthread_cond_broadcast(&cond));
+ BOOST_VERIFY(!pthread_cond_broadcast(&cond));
}
class condition_variable_any
@@ -79,14 +79,14 @@
int const res2=pthread_cond_init(&cond,NULL);
if(res2)
{
- BOOST_VERIFY(0==pthread_mutex_destroy(&internal_mutex));
+ BOOST_VERIFY(!pthread_mutex_destroy(&internal_mutex));
throw thread_resource_error();
}
}
~condition_variable_any()
{
- BOOST_VERIFY(0==pthread_mutex_destroy(&internal_mutex));
- BOOST_VERIFY(0==pthread_cond_destroy(&cond));
+ BOOST_VERIFY(!pthread_mutex_destroy(&internal_mutex));
+ BOOST_VERIFY(!pthread_cond_destroy(&cond));
}
template<typename lock_type>
@@ -153,13 +153,13 @@
void notify_one()
{
boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex);
- BOOST_VERIFY(0==pthread_cond_signal(&cond));
+ BOOST_VERIFY(!pthread_cond_signal(&cond));
}
void notify_all()
{
boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex);
- BOOST_VERIFY(0==pthread_cond_broadcast(&cond));
+ BOOST_VERIFY(!pthread_cond_broadcast(&cond));
}
};
Modified: trunk/boost/thread/pthread/mutex.hpp
==============================================================================
--- trunk/boost/thread/pthread/mutex.hpp (original)
+++ trunk/boost/thread/pthread/mutex.hpp 2007-11-05 09:16:21 EST (Mon, 05 Nov 2007)
@@ -42,17 +42,17 @@
}
~mutex()
{
- BOOST_VERIFY(0==pthread_mutex_destroy(&m));
+ BOOST_VERIFY(!pthread_mutex_destroy(&m));
}
void lock()
{
- BOOST_VERIFY(0==pthread_mutex_lock(&m));
+ BOOST_VERIFY(!pthread_mutex_lock(&m));
}
void unlock()
{
- BOOST_VERIFY(0==pthread_mutex_unlock(&m));
+ BOOST_VERIFY(!pthread_mutex_unlock(&m));
}
bool try_lock()
@@ -95,7 +95,7 @@
int const res2=pthread_cond_init(&cond,NULL);
if(res2)
{
- BOOST_VERIFY(0==pthread_mutex_destroy(&m));
+ BOOST_VERIFY(!pthread_mutex_destroy(&m));
throw thread_resource_error();
}
is_locked=false;
@@ -103,9 +103,9 @@
}
~timed_mutex()
{
- BOOST_VERIFY(0==pthread_mutex_destroy(&m));
+ BOOST_VERIFY(!pthread_mutex_destroy(&m));
#ifndef BOOST_PTHREAD_HAS_TIMEDLOCK
- BOOST_VERIFY(0==pthread_cond_destroy(&cond));
+ BOOST_VERIFY(!pthread_cond_destroy(&cond));
#endif
}
@@ -118,12 +118,12 @@
#ifdef BOOST_PTHREAD_HAS_TIMEDLOCK
void lock()
{
- BOOST_VERIFY(0==pthread_mutex_lock(&m));
+ BOOST_VERIFY(!pthread_mutex_lock(&m));
}
void unlock()
{
- BOOST_VERIFY(0==pthread_mutex_unlock(&m));
+ BOOST_VERIFY(!pthread_mutex_unlock(&m));
}
bool try_lock()
@@ -145,7 +145,7 @@
boost::pthread::pthread_mutex_scoped_lock const local_lock(&m);
while(is_locked)
{
- BOOST_VERIFY(0==pthread_cond_wait(&cond,&m));
+ BOOST_VERIFY(!pthread_cond_wait(&cond,&m));
}
is_locked=true;
}
@@ -154,7 +154,7 @@
{
boost::pthread::pthread_mutex_scoped_lock const local_lock(&m);
is_locked=false;
- BOOST_VERIFY(0==pthread_cond_signal(&cond));
+ BOOST_VERIFY(!pthread_cond_signal(&cond));
}
bool try_lock()
Modified: trunk/boost/thread/pthread/once.hpp
==============================================================================
--- trunk/boost/thread/pthread/once.hpp (original)
+++ trunk/boost/thread/pthread/once.hpp 2007-11-05 09:16:21 EST (Mon, 05 Nov 2007)
@@ -13,45 +13,28 @@
#include <pthread.h>
#include <boost/assert.hpp>
+#include "pthread_mutex_scoped_lock.hpp"
namespace boost {
struct once_flag
{
pthread_mutex_t mutex;
- unsigned flag;
+ unsigned long flag;
};
#define BOOST_ONCE_INIT {PTHREAD_MUTEX_INITIALIZER,0}
- namespace detail
- {
- struct pthread_mutex_scoped_lock
- {
- pthread_mutex_t * mutex;
-
- explicit pthread_mutex_scoped_lock(pthread_mutex_t* mutex_):
- mutex(mutex_)
- {
- BOOST_VERIFY(0==pthread_mutex_lock(mutex));
- }
- ~pthread_mutex_scoped_lock()
- {
- BOOST_VERIFY(0==pthread_mutex_unlock(mutex));
- }
- };
- }
-
template<typename Function>
void call_once(once_flag& flag,Function f)
{
- long const function_complete_flag_value=0xc15730e2;
+ unsigned long const function_complete_flag_value=0xc15730e2ul;
#ifdef BOOST_PTHREAD_HAS_ATOMICS
if(::boost::detail::interlocked_read_acquire(&flag.flag)!=function_complete_flag_value)
{
#endif
- detail::pthread_mutex_scoped_lock const lock(&flag.mutex);
+ pthread::pthread_mutex_scoped_lock const lock(&flag.mutex);
if(flag.flag!=function_complete_flag_value)
{
f();
Modified: trunk/boost/thread/pthread/pthread_mutex_scoped_lock.hpp
==============================================================================
--- trunk/boost/thread/pthread/pthread_mutex_scoped_lock.hpp (original)
+++ trunk/boost/thread/pthread/pthread_mutex_scoped_lock.hpp 2007-11-05 09:16:21 EST (Mon, 05 Nov 2007)
@@ -14,11 +14,11 @@
explicit pthread_mutex_scoped_lock(pthread_mutex_t* m_):
m(m_)
{
- BOOST_VERIFY(0==pthread_mutex_lock(m));
+ BOOST_VERIFY(!pthread_mutex_lock(m));
}
~pthread_mutex_scoped_lock()
{
- BOOST_VERIFY(0==pthread_mutex_unlock(m));
+ BOOST_VERIFY(!pthread_mutex_unlock(m));
}
};
Modified: trunk/boost/thread/pthread/recursive_mutex.hpp
==============================================================================
--- trunk/boost/thread/pthread/recursive_mutex.hpp (original)
+++ trunk/boost/thread/pthread/recursive_mutex.hpp 2007-11-05 09:16:21 EST (Mon, 05 Nov 2007)
@@ -53,21 +53,21 @@
{
throw thread_resource_error();
}
- BOOST_VERIFY(0==pthread_mutexattr_destroy(&attr));
+ BOOST_VERIFY(!pthread_mutexattr_destroy(&attr));
}
~recursive_mutex()
{
- BOOST_VERIFY(0==pthread_mutex_destroy(&m));
+ BOOST_VERIFY(!pthread_mutex_destroy(&m));
}
void lock()
{
- BOOST_VERIFY(0==pthread_mutex_lock(&m));
+ BOOST_VERIFY(!pthread_mutex_lock(&m));
}
void unlock()
{
- BOOST_VERIFY(0==pthread_mutex_unlock(&m));
+ BOOST_VERIFY(!pthread_mutex_unlock(&m));
}
bool try_lock()
@@ -113,10 +113,10 @@
int const res=pthread_mutex_init(&m,&attr);
if(res)
{
- BOOST_VERIFY(0==pthread_mutexattr_destroy(&attr));
+ BOOST_VERIFY(!pthread_mutexattr_destroy(&attr));
throw thread_resource_error();
}
- BOOST_VERIFY(0==pthread_mutexattr_destroy(&attr));
+ BOOST_VERIFY(!pthread_mutexattr_destroy(&attr));
#else
int const res=pthread_mutex_init(&m,NULL);
if(res)
@@ -126,7 +126,7 @@
int const res2=pthread_cond_init(&cond,NULL);
if(res2)
{
- BOOST_VERIFY(0==pthread_mutex_destroy(&m));
+ BOOST_VERIFY(!pthread_mutex_destroy(&m));
throw thread_resource_error();
}
is_locked=false;
@@ -135,9 +135,9 @@
}
~recursive_timed_mutex()
{
- BOOST_VERIFY(0==pthread_mutex_destroy(&m));
+ BOOST_VERIFY(!pthread_mutex_destroy(&m));
#ifndef BOOST_PTHREAD_HAS_TIMEDLOCK
- BOOST_VERIFY(0==pthread_cond_destroy(&cond));
+ BOOST_VERIFY(!pthread_cond_destroy(&cond));
#endif
}
@@ -150,12 +150,12 @@
#ifdef BOOST_PTHREAD_HAS_TIMEDLOCK
void lock()
{
- BOOST_VERIFY(0==pthread_mutex_lock(&m));
+ BOOST_VERIFY(!pthread_mutex_lock(&m));
}
void unlock()
{
- BOOST_VERIFY(0==pthread_mutex_unlock(&m));
+ BOOST_VERIFY(!pthread_mutex_unlock(&m));
}
bool try_lock()
@@ -175,7 +175,7 @@
void lock()
{
boost::pthread::pthread_mutex_scoped_lock const local_lock(&m);
- if(is_locked && owner==pthread_self())
+ if(is_locked && pthread_equal(owner,pthread_self()))
{
++count;
return;
@@ -183,7 +183,7 @@
while(is_locked)
{
- BOOST_VERIFY(0==pthread_cond_wait(&cond,&m));
+ BOOST_VERIFY(!pthread_cond_wait(&cond,&m));
}
is_locked=true;
++count;
@@ -197,13 +197,13 @@
{
is_locked=false;
}
- BOOST_VERIFY(0==pthread_cond_signal(&cond));
+ BOOST_VERIFY(!pthread_cond_signal(&cond));
}
bool try_lock()
{
boost::pthread::pthread_mutex_scoped_lock const local_lock(&m);
- if(is_locked && owner!=pthread_self())
+ if(is_locked && !pthread_equal(owner,pthread_self()))
{
return false;
}
@@ -217,7 +217,7 @@
{
struct timespec const timeout=detail::get_timespec(abs_time);
boost::pthread::pthread_mutex_scoped_lock const local_lock(&m);
- if(is_locked && owner==pthread_self())
+ if(is_locked && pthread_equal(owner,pthread_self()))
{
++count;
return true;
Modified: trunk/boost/thread/win32/basic_timed_mutex.hpp
==============================================================================
--- trunk/boost/thread/win32/basic_timed_mutex.hpp (original)
+++ trunk/boost/thread/win32/basic_timed_mutex.hpp 2007-11-05 09:16:21 EST (Mon, 05 Nov 2007)
@@ -59,8 +59,7 @@
void lock()
{
- bool const success=timed_lock(::boost::detail::get_system_time_sentinel());
- BOOST_ASSERT(success);
+ BOOST_VERIFY(timed_lock(::boost::detail::get_system_time_sentinel()));
}
bool timed_lock(::boost::system_time const& wait_until)
{
Modified: trunk/boost/thread/win32/condition_variable.hpp
==============================================================================
--- trunk/boost/thread/win32/condition_variable.hpp (original)
+++ trunk/boost/thread/win32/condition_variable.hpp 2007-11-05 09:16:21 EST (Mon, 05 Nov 2007)
@@ -79,8 +79,7 @@
{
if(entry.semaphore)
{
- unsigned long const close_result=detail::win32::CloseHandle(entry.semaphore);
- BOOST_ASSERT(close_result);
+ BOOST_VERIFY(detail::win32::CloseHandle(entry.semaphore));
entry.semaphore=0;
}
entry.notified=false;
Modified: trunk/boost/thread/win32/once.hpp
==============================================================================
--- trunk/boost/thread/win32/once.hpp (original)
+++ trunk/boost/thread/win32/once.hpp 2007-11-05 09:16:21 EST (Mon, 05 Nov 2007)
@@ -40,13 +40,11 @@
explicit win32_mutex_scoped_lock(void* mutex_handle_):
mutex_handle(mutex_handle_)
{
- unsigned long const res=win32::WaitForSingleObject(mutex_handle,win32::infinite);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(!win32::WaitForSingleObject(mutex_handle,win32::infinite));
}
~win32_mutex_scoped_lock()
{
- bool const success=win32::ReleaseMutex(mutex_handle)!=0;
- BOOST_ASSERT(success);
+ BOOST_VERIFY(win32::ReleaseMutex(mutex_handle)!=0);
}
};
Modified: trunk/boost/thread/win32/shared_mutex.hpp
==============================================================================
--- trunk/boost/thread/win32/shared_mutex.hpp (original)
+++ trunk/boost/thread/win32/shared_mutex.hpp 2007-11-05 09:16:21 EST (Mon, 05 Nov 2007)
@@ -57,14 +57,12 @@
{
if(old_state.exclusive_waiting)
{
- bool const success=detail::win32::ReleaseSemaphore(exclusive_sem,1,NULL)!=0;
- BOOST_ASSERT(success);
+ BOOST_VERIFY(detail::win32::ReleaseSemaphore(exclusive_sem,1,NULL)!=0);
}
if(old_state.shared_waiting || old_state.exclusive_waiting)
{
- bool const success=detail::win32::ReleaseSemaphore(unlock_sem,old_state.shared_waiting + (old_state.exclusive_waiting?1:0),NULL)!=0;
- BOOST_ASSERT(success);
+ BOOST_VERIFY(detail::win32::ReleaseSemaphore(unlock_sem,old_state.shared_waiting + (old_state.exclusive_waiting?1:0),NULL)!=0);
}
}
@@ -112,8 +110,7 @@
void lock_shared()
{
- bool const success=timed_lock_shared(::boost::detail::get_system_time_sentinel());
- BOOST_ASSERT(success);
+ BOOST_VERIFY(timed_lock_shared(::boost::detail::get_system_time_sentinel()));
}
bool timed_lock_shared(boost::system_time const& wait_until)
@@ -218,8 +215,7 @@
{
if(old_state.upgrade)
{
- bool const success=detail::win32::ReleaseSemaphore(upgrade_sem,1,NULL)!=0;
- BOOST_ASSERT(success);
+ BOOST_VERIFY(detail::win32::ReleaseSemaphore(upgrade_sem,1,NULL)!=0);
}
else
{
@@ -235,8 +231,7 @@
void lock()
{
- bool const success=timed_lock(::boost::detail::get_system_time_sentinel());
- BOOST_ASSERT(success);
+ BOOST_VERIFY(timed_lock(::boost::detail::get_system_time_sentinel()));
}
bool timed_lock(boost::system_time const& wait_until)
@@ -364,8 +359,7 @@
return;
}
- unsigned long const res=detail::win32::WaitForSingleObject(unlock_sem,detail::win32::infinite);
- BOOST_ASSERT(res==0);
+ BOOST_VERIFY(!detail::win32::WaitForSingleObject(unlock_sem,detail::win32::infinite));
}
}
@@ -421,8 +415,7 @@
{
if(!last_reader)
{
- unsigned long const res=detail::win32::WaitForSingleObject(upgrade_sem,detail::win32::infinite);
- BOOST_ASSERT(res==0);
+ BOOST_VERIFY(!detail::win32::WaitForSingleObject(upgrade_sem,detail::win32::infinite));
}
break;
}
Modified: trunk/boost/thread/win32/thread_primitives.hpp
==============================================================================
--- trunk/boost/thread/win32/thread_primitives.hpp (original)
+++ trunk/boost/thread/win32/thread_primitives.hpp 2007-11-05 09:16:21 EST (Mon, 05 Nov 2007)
@@ -204,8 +204,7 @@
inline void release_semaphore(handle semaphore,long count)
{
- bool const success=ReleaseSemaphore(semaphore,count,0)!=0;
- BOOST_ASSERT(success);
+ BOOST_VERIFY(ReleaseSemaphore(semaphore,count,0)!=0);
}
class handle_manager
@@ -219,8 +218,7 @@
{
if(handle_to_manage && handle_to_manage!=invalid_handle_value)
{
- unsigned long const result=CloseHandle(handle_to_manage);
- BOOST_ASSERT(result);
+ BOOST_VERIFY(CloseHandle(handle_to_manage));
}
}
Modified: trunk/libs/thread/src/pthread/thread.cpp
==============================================================================
--- trunk/libs/thread/src/pthread/thread.cpp (original)
+++ trunk/libs/thread/src/pthread/thread.cpp 2007-11-05 09:16:21 EST (Mon, 05 Nov 2007)
@@ -55,7 +55,7 @@
void create_current_thread_tls_key()
{
- BOOST_VERIFY(0==pthread_key_create(¤t_thread_tls_key,NULL));
+ BOOST_VERIFY(!pthread_key_create(¤t_thread_tls_key,NULL));
}
}
@@ -68,7 +68,7 @@
void set_current_thread_data(detail::thread_data_base* new_data)
{
boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key);
- BOOST_VERIFY(0==pthread_setspecific(current_thread_tls_key,new_data));
+ BOOST_VERIFY(!pthread_setspecific(current_thread_tls_key,new_data));
}
}
@@ -170,7 +170,7 @@
if(do_join)
{
void* result=0;
- BOOST_VERIFY(0==pthread_join(local_thread_info->thread_handle,&result));
+ BOOST_VERIFY(!pthread_join(local_thread_info->thread_handle,&result));
lock_guard<mutex> lock(local_thread_info->data_mutex);
local_thread_info->joined=true;
local_thread_info->done_condition.notify_all();
@@ -217,7 +217,7 @@
if(do_join)
{
void* result=0;
- BOOST_VERIFY(0==pthread_join(local_thread_info->thread_handle,&result));
+ BOOST_VERIFY(!pthread_join(local_thread_info->thread_handle,&result));
lock_guard<mutex> lock(local_thread_info->data_mutex);
local_thread_info->joined=true;
local_thread_info->done_condition.notify_all();
@@ -251,7 +251,7 @@
lock_guard<mutex> lock(local_thread_info->data_mutex);
if(!local_thread_info->join_started)
{
- BOOST_VERIFY(0==pthread_detach(local_thread_info->thread_handle));
+ BOOST_VERIFY(!pthread_detach(local_thread_info->thread_handle));
local_thread_info->join_started=true;
local_thread_info->joined=true;
}
@@ -276,7 +276,7 @@
# if defined(BOOST_HAS_PTHREAD_DELAY_NP)
timespec ts;
to_timespec_duration(xt, ts);
- BOOST_VERIFY(0==pthread_delay_np(&ts));
+ BOOST_VERIFY(!pthread_delay_np(&ts));
# elif defined(BOOST_HAS_NANOSLEEP)
timespec ts;
to_timespec_duration(xt, ts);
@@ -301,9 +301,9 @@
void thread::yield()
{
# if defined(BOOST_HAS_SCHED_YIELD)
- BOOST_VERIFY(0==sched_yield());
+ BOOST_VERIFY(!sched_yield());
# elif defined(BOOST_HAS_PTHREAD_YIELD)
- BOOST_VERIFY(0==pthread_yield());
+ BOOST_VERIFY(!pthread_yield());
# else
xtime xt;
xtime_get(&xt, TIME_UTC);
@@ -338,7 +338,7 @@
local_thread_info->interrupt_requested=true;
if(local_thread_info->current_cond)
{
- BOOST_VERIFY(0==pthread_cond_broadcast(local_thread_info->current_cond));
+ BOOST_VERIFY(!pthread_cond_broadcast(local_thread_info->current_cond));
}
}
}
Modified: trunk/libs/thread/src/pthread/tss.cpp
==============================================================================
--- trunk/libs/thread/src/pthread/tss.cpp (original)
+++ trunk/libs/thread/src/pthread/tss.cpp 2007-11-05 09:16:21 EST (Mon, 05 Nov 2007)
@@ -17,11 +17,6 @@
#include <stdexcept>
#include <cassert>
-#if defined(BOOST_HAS_WINTHREADS)
-# include <windows.h>
-# include <boost/thread/detail/tss_hooks.hpp>
-#endif
-
namespace {
typedef std::vector<void*> tss_slots;
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