|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r85653 - in branches/release: boost/interprocess boost/interprocess/detail boost/interprocess/sync/spin libs/interprocess/test
From: igaztanaga_at_[hidden]
Date: 2013-09-11 17:02:47
Author: igaztanaga
Date: 2013-09-11 17:02:47 EDT (Wed, 11 Sep 2013)
New Revision: 85653
URL: http://svn.boost.org/trac/boost/changeset/85653
Log:
Merging latest spin_wait improvements + unused typedef removal.
Text files modified:
branches/release/boost/interprocess/detail/os_thread_functions.hpp | 32 +++++++++++++++++++-------------
branches/release/boost/interprocess/segment_manager.hpp | 2 --
branches/release/boost/interprocess/sync/spin/wait.hpp | 37 ++++++++++++++++---------------------
branches/release/libs/interprocess/test/check_equal_containers.hpp | 2 --
branches/release/libs/interprocess/test/data_test.cpp | 1 -
branches/release/libs/interprocess/test/named_allocation_test_template.hpp | 6 ------
branches/release/libs/interprocess/test/shared_ptr_test.cpp | 7 -------
7 files changed, 35 insertions(+), 52 deletions(-)
Modified: branches/release/boost/interprocess/detail/os_thread_functions.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/os_thread_functions.hpp Wed Sep 11 16:59:09 2013 (r85652)
+++ branches/release/boost/interprocess/detail/os_thread_functions.hpp 2013-09-11 17:02:47 EDT (Wed, 11 Sep 2013) (r85653)
@@ -95,7 +95,7 @@
typedef unsigned __int64 OS_highres_count_t;
-inline OS_highres_count_t get_system_tick_in_highres_counts()
+inline unsigned long get_system_tick_in_highres_counts()
{
__int64 freq;
unsigned long curres;
@@ -103,13 +103,13 @@
//Frequency in counts per second
if(!winapi::query_performance_frequency(&freq)){
//Tick resolution in ms
- return (curres-1)/10000u + 1;
+ return (curres-1ul)/10000ul + 1ul;
}
else{
//In femtoseconds
- __int64 count_fs = __int64(1000000000000000LL - 1LL)/freq + 1LL;
- __int64 tick_counts = (__int64(curres)*100000000LL - 1LL)/count_fs + 1LL;
- return static_cast<OS_highres_count_t>(tick_counts);
+ __int64 count_fs = (1000000000000000LL - 1LL)/freq + 1LL;
+ __int64 tick_counts = (static_cast<__int64>(curres)*100000000LL - 1LL)/count_fs + 1LL;
+ return static_cast<unsigned long>(tick_counts);
}
}
@@ -141,6 +141,9 @@
inline bool system_highres_count_less(const OS_highres_count_t &l, const OS_highres_count_t &r)
{ return l < r; }
+inline bool system_highres_count_less_ul(const OS_highres_count_t &l, unsigned long r)
+{ return l < static_cast<OS_highres_count_t>(r); }
+
inline void thread_sleep_tick()
{ winapi::sleep_tick(); }
@@ -278,18 +281,15 @@
#endif
}
-inline OS_highres_count_t get_system_tick_in_highres_counts()
+inline unsigned long get_system_tick_in_highres_counts()
{
#ifndef BOOST_INTERPROCESS_MATCH_ABSOLUTE_TIME
- struct timespec ts;
- ts.tv_sec = 0;
- ts.tv_nsec = get_system_tick_ns();
- return ts;
+ return get_system_tick_ns();
#else
mach_timebase_info_data_t info;
mach_timebase_info(&info);
//ns
- return static_cast<OS_highres_count_t>
+ return static_cast<unsigned long>
(
static_cast<double>(get_system_tick_ns())
/ (static_cast<double>(info.numer) / info.denom)
@@ -346,7 +346,10 @@
}
inline bool system_highres_count_less(const OS_highres_count_t &l, const OS_highres_count_t &r)
-{ return l.tv_sec < r.tv_sec || (l.tv_sec == r.tv_sec && l.tv_nsec < r.tv_nsec); }
+{ return l.tv_sec < r.tv_sec || (l.tv_sec == r.tv_sec && l.tv_nsec < r.tv_nsec); }
+
+inline bool system_highres_count_less_ul(const OS_highres_count_t &l, unsigned long r)
+{ return !l.tv_sec && (static_cast<unsigned long>(l.tv_nsec) < r); }
#else
@@ -367,7 +370,10 @@
{ return l - r; }
inline bool system_highres_count_less(const OS_highres_count_t &l, const OS_highres_count_t &r)
-{ return l < r; }
+{ return l < r; }
+
+inline bool system_highres_count_less_ul(const OS_highres_count_t &l, unsigned long r)
+{ return l < static_cast<OS_highres_count_t>(r); }
#endif
Modified: branches/release/boost/interprocess/segment_manager.hpp
==============================================================================
--- branches/release/boost/interprocess/segment_manager.hpp Wed Sep 11 16:59:09 2013 (r85652)
+++ branches/release/boost/interprocess/segment_manager.hpp 2013-09-11 17:02:47 EDT (Wed, 11 Sep 2013) (r85653)
@@ -847,7 +847,6 @@
{
(void)is_intrusive;
typedef IndexType<ipcdetail::index_config<CharT, MemoryAlgorithm> > index_type;
- typedef ipcdetail::index_key<CharT, void_pointer> index_key_t;
typedef typename index_type::iterator index_it;
//-------------------------------
@@ -949,7 +948,6 @@
{
(void)is_intrusive_index;
typedef IndexType<ipcdetail::index_config<CharT, MemoryAlgorithm> > index_type;
- typedef ipcdetail::index_key<CharT, void_pointer> index_key_t;
typedef typename index_type::iterator index_it;
typedef typename index_type::value_type intrusive_value_type;
Modified: branches/release/boost/interprocess/sync/spin/wait.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/spin/wait.hpp Wed Sep 11 16:59:09 2013 (r85652)
+++ branches/release/boost/interprocess/sync/spin/wait.hpp 2013-09-11 17:02:47 EDT (Wed, 11 Sep 2013) (r85653)
@@ -1,7 +1,7 @@
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Peter Dimov 2008.
-// (C) Copyright Ion Gaztanaga 2013. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2013-2013. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -73,13 +73,11 @@
class spin_wait
{
public:
+
+ static const unsigned int nop_pause_limit = 32u;
spin_wait()
- : m_k(0u)
- {
- (void)m_nop_pause_limit;
- (void)m_yield_only_counts;
- (void)m_count_start;
- }
+ : m_count_start(), m_ul_yield_only_counts(), m_k()
+ {}
#ifdef BOOST_INTERPROCESS_SPIN_WAIT_DEBUG
~spin_wait()
@@ -101,19 +99,19 @@
this->init_limits();
}
//Nop tries
- if( m_k < (m_nop_pause_limit >> 2) ){
+ if( m_k < (nop_pause_limit >> 2) ){
}
//Pause tries if the processor supports it
#if defined(BOOST_INTERPROCESS_SMT_PAUSE)
- else if( m_k < m_nop_pause_limit ){
+ else if( m_k < nop_pause_limit ){
BOOST_INTERPROCESS_SMT_PAUSE
}
#endif
//Yield/Sleep strategy
else{
//Lazy initialization of tick information
- if(m_k == m_nop_pause_limit){
+ if(m_k == nop_pause_limit){
this->init_tick_info();
}
else if( this->yield_or_sleep() ){
@@ -129,7 +127,6 @@
void reset()
{
m_k = 0u;
- m_count_start = ipcdetail::get_current_system_highres_count();
}
private:
@@ -137,45 +134,43 @@
void init_limits()
{
unsigned int num_cores = ipcdetail::num_core_holder<0>::get();
- m_nop_pause_limit = num_cores > 1u ? 32u : 0u;
+ m_k = num_cores > 1u ? 0u : nop_pause_limit;
}
void init_tick_info()
{
- m_yield_only_counts = ipcdetail::get_system_tick_in_highres_counts();
+ m_ul_yield_only_counts = ipcdetail::get_system_tick_in_highres_counts();
m_count_start = ipcdetail::get_current_system_highres_count();
}
//Returns true if yield must be called, false is sleep must be called
bool yield_or_sleep()
{
- if(ipcdetail::is_highres_count_zero(m_yield_only_counts)){ //If yield-only limit was reached then yield one in every two tries
+ if(!m_ul_yield_only_counts){ //If yield-only limit was reached then yield one in every two tries
return (m_k & 1u) != 0;
}
else{ //Try to see if we've reched yield-only time limit
const ipcdetail::OS_highres_count_t now = ipcdetail::get_current_system_highres_count();
const ipcdetail::OS_highres_count_t elapsed = ipcdetail::system_highres_count_subtract(now, m_count_start);
- if(!ipcdetail::system_highres_count_less(elapsed, m_yield_only_counts)){
+ if(!ipcdetail::system_highres_count_less_ul(elapsed, m_ul_yield_only_counts)){
#ifdef BOOST_INTERPROCESS_SPIN_WAIT_DEBUG
std::cout << "elapsed!\n"
- << " m_yield_only_counts: ";
- ipcdetail::ostream_highres_count(std::cout, m_yield_only_counts)
+ << " m_ul_yield_only_counts: " << m_ul_yield_only_counts
<< " system tick(us): " << ipcdetail::get_system_tick_us() << '\n'
<< " m_k: " << m_k << " elapsed counts: ";
ipcdetail::ostream_highres_count(std::cout, elapsed) << std::endl;
#endif
//Yield-only time reached, now it's time to sleep
- ipcdetail::zero_highres_count(m_yield_only_counts);
+ m_ul_yield_only_counts = 0ul;
return false;
}
}
return true; //Otherwise yield
}
- unsigned int m_k;
- unsigned int m_nop_pause_limit;
- ipcdetail::OS_highres_count_t m_yield_only_counts;
ipcdetail::OS_highres_count_t m_count_start;
+ unsigned long m_ul_yield_only_counts;
+ unsigned int m_k;
};
} // namespace interprocess
Modified: branches/release/libs/interprocess/test/check_equal_containers.hpp
==============================================================================
--- branches/release/libs/interprocess/test/check_equal_containers.hpp Wed Sep 11 16:59:09 2013 (r85652)
+++ branches/release/libs/interprocess/test/check_equal_containers.hpp 2013-09-11 17:02:47 EDT (Wed, 11 Sep 2013) (r85653)
@@ -48,8 +48,6 @@
if(shmcont->size() != stdcont->size())
return false;
- typedef typename MyShmCont::value_type value_type;
-
typename MyShmCont::iterator itshm(shmcont->begin()), itshmend(shmcont->end());
typename MyStdCont::iterator itstd(stdcont->begin());
typename MyStdCont::size_type dist = (typename MyStdCont::size_type)std::distance(itshm, itshmend);
Modified: branches/release/libs/interprocess/test/data_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/data_test.cpp Wed Sep 11 16:59:09 2013 (r85652)
+++ branches/release/libs/interprocess/test/data_test.cpp 2013-09-11 17:02:47 EDT (Wed, 11 Sep 2013) (r85653)
@@ -47,7 +47,6 @@
const char *allocName = "testAllocation";
typedef boost::interprocess::vector<int, shmem_allocator_int_t > MyVect;
- typedef boost::interprocess::list<int, shmem_allocator_int_t > MyList;
//---- ALLOC, NAMED_ALLOC, NAMED_NEW TEST ----//
{
Modified: branches/release/libs/interprocess/test/named_allocation_test_template.hpp
==============================================================================
--- branches/release/libs/interprocess/test/named_allocation_test_template.hpp Wed Sep 11 16:59:09 2013 (r85652)
+++ branches/release/libs/interprocess/test/named_allocation_test_template.hpp 2013-09-11 17:02:47 EDT (Wed, 11 Sep 2013) (r85653)
@@ -100,7 +100,6 @@
bool test_named_iterators(ManagedMemory &m)
{
typedef typename ManagedMemory::char_type char_type;
- typedef std::char_traits<char_type> char_traits_type;
std::vector<char*> buffers;
const int BufferLen = 100;
char_type name[BufferLen];
@@ -172,7 +171,6 @@
bool test_shrink_to_fit(ManagedMemory &m)
{
typedef typename ManagedMemory::char_type char_type;
- typedef std::char_traits<char_type> char_traits_type;
std::vector<char*> buffers;
const int BufferLen = 100;
char_type name[BufferLen];
@@ -214,7 +212,6 @@
bool test_direct_named_allocation_destruction(ManagedMemory &m)
{
typedef typename ManagedMemory::char_type char_type;
- typedef std::char_traits<char_type> char_traits_type;
std::vector<char*> buffers;
const int BufferLen = 100;
char_type name[BufferLen];
@@ -255,7 +252,6 @@
bool test_named_allocation_inverse_destruction(ManagedMemory &m)
{
typedef typename ManagedMemory::char_type char_type;
- typedef std::char_traits<char_type> char_traits_type;
std::vector<char*> buffers;
const int BufferLen = 100;
@@ -295,7 +291,6 @@
bool test_named_allocation_mixed_destruction(ManagedMemory &m)
{
typedef typename ManagedMemory::char_type char_type;
- typedef std::char_traits<char_type> char_traits_type;
std::vector<char*> buffers;
const int BufferLen = 100;
@@ -337,7 +332,6 @@
bool test_inverse_named_allocation_destruction(ManagedMemory &m)
{
typedef typename ManagedMemory::char_type char_type;
- typedef std::char_traits<char_type> char_traits_type;
std::vector<char*> buffers;
const int BufferLen = 100;
Modified: branches/release/libs/interprocess/test/shared_ptr_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/shared_ptr_test.cpp Wed Sep 11 16:59:09 2013 (r85652)
+++ branches/release/libs/interprocess/test/shared_ptr_test.cpp 2013-09-11 17:02:47 EDT (Wed, 11 Sep 2013) (r85653)
@@ -53,7 +53,6 @@
typedef deleter<base_class, managed_shared_memory::segment_manager>
base_deleter_t;
typedef shared_ptr<base_class, base_class_allocator, base_deleter_t> base_shared_ptr;
- typedef weak_ptr<base_class, base_class_allocator, base_deleter_t> base_weak_ptr;
std::string process_name;
test::get_process_id_name(process_name);
@@ -561,17 +560,11 @@
typedef allocator<void, managed_shared_memory::segment_manager>
v_allocator_t;
- typedef deleter<alias_tester, managed_shared_memory::segment_manager>
- alias_tester_deleter_t;
-
typedef deleter<int, managed_shared_memory::segment_manager>
int_deleter_t;
- typedef shared_ptr<alias_tester, v_allocator_t, alias_tester_deleter_t> alias_tester_shared_ptr;
-
typedef shared_ptr<int, v_allocator_t, int_deleter_t> int_shared_ptr;
typedef shared_ptr<const int, v_allocator_t, int_deleter_t> const_int_shared_ptr;
- typedef shared_ptr<volatile int, v_allocator_t, int_deleter_t> volatile_int_shared_ptr;
std::string process_name;
test::get_process_id_name(process_name);
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