diff --git a/Interprocess_sync_windows_emulation.txt b/Interprocess_sync_windows_emulation.txt new file mode 100644 index 0000000..f7b544c --- /dev/null +++ b/Interprocess_sync_windows_emulation.txt @@ -0,0 +1,207 @@ +--------------- +--------------- +named_semaphore +--------------- +--------------- + +- Use a file for file lifetime semantics (create, open, unlink...) +- Create on demand (open or create) a windows named semaphore with all access (permissions are on the file). +- Use file id with a "prefix bips." to construct the mutex "Global\prefix bips.XXXXXXXXXXXXXXXXXXX" +- Add getvalue as implemented by cygwin +- Write sem status to file at file close. Use native file locking to serialize. +- See cygwin-1.7.5-1\winsup\cygwin\posix_ipc.cc and thread.cc + + + + +----------- +----------- +named_mutex +----------- +----------- + +- Don't serialize + +--------------- +--------------- +named_condition +--------------- +--------------- + + +--------------- +--------------- +Process shared resources. Use lock reduced versions? +--------------- +--------------- + +what about fast_semaphore (http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.kernel/2005-03/0041.html): + +class fast_semaphore +{ + +public: + + fast_semaphore( LONG init ) + : m_state( init ), + m_waitset( CreateSemaphore( 0, 0, LONG_MAX, 0 ) ) + { if ( ! m_waitset ) { throw; } } + + ~fast_semaphore() + { if ( ! CloseHandle( m_waitset ) ) { abort(); } } + +public: + + void inc() + { + if ( InterlockedIncrement( &m_state ) < 1 ) + { + if ( ! ReleaseSemaphore( m_waitset, 1, 0 ) ) + { + throw; + } + } + } + + void dec() + { + if ( InterlockedDecrement( &m_state ) < 0 ) + { + if ( WaitForSingleObject( m_waitset, INFINITE ) != +WAIT_OBJECT_0 ) + { + throw; + } + } + } + +private: + + volatile LONG m_state; + HANDLE m_waitset; + +}; + +class mutex_from_semaphore +{ + +public: + + mutex_from_semaphore() : m_waitset( 1 ) {} + +public: + + void enter() { m_waitset.dec(); } + void leave() { m_waitset.inc(); } + +private: + + fast_semaphore m_waitset; + +}; + +Or see Java implemenation (http://www.google.com/codesearch/p?hl=es#5qy3uURTOpU/trunk/JobRunner/src/org/ivoa/util/concurrent/FastSemaphore.java&q=%22fast%20semaphore%22&sa=N&cd=1&ct=rc&l=10) + + +For mutex, usefast mutex (see fast_mutex.h in cygwin): + + +class fast_mutex +{ +public: + fast_mutex () : + lock_counter (0), win32_obj_id (0) + { + } + + ~fast_mutex () + { + if(win32_obj_id) + CloseHandle (win32_obj_id); + } + + bool init () + { + lock_counter = 0; + win32_obj_id = ::CreateEvent (&sec_none_nih, false, false, NULL); + if (!win32_obj_id) + { + debug_printf ("CreateEvent failed. %E"); + return false; + } + return true; + } + + void lock () + { + if (InterlockedIncrement ((long *) &lock_counter) != 1) + cancelable_wait (win32_obj_id, INFINITE, cw_no_cancel, cw_sig_resume); + } + + void unlock () + { + if (InterlockedDecrement ((long *) &lock_counter)) + ::SetEvent (win32_obj_id); + } + +private: + unsigned long lock_counter; + HANDLE win32_obj_id; +}; + + +Or this one (http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.kernel/2005-03/0067.html): + + +class fast_mutex +{ + +public: + + fast_mutex + : m_state( 0 ), + m_waitset( CreateEvent( 0, FALSE, FALSE 0 ) ) + { if ( ! m_waitset ) { throw; } } + + ~fast_mutex + { if ( ! CloseHandle( m_waitset ) ) { abort(); } } + +public: + + void enter + { + if ( InterlockedExchange( &m_state, 1 ) ) + { + _asm pause; /* masm */ + + while ( InterlockedExchange( &m_state, 2 ) ) + { + if ( WaitForSingleObject + ( m_waitset, + INFINITE ) != + WAIT_OBJECT_0 ) + { + throw; + } + } + } + } + + void leave() + { + if ( InterlockedExchange( &m_state, 0 ) == 2 ) + { + if ( ! SetEvent( m_waitset ) ) + { + throw; + } + } + } + +private: + + volatile LONG m_state; + HANDLE m_waitset; + +}; + diff --git a/doc/interprocess.qbk b/doc/interprocess.qbk index 46dad37..ceb0fa9 100644 --- a/doc/interprocess.qbk +++ b/doc/interprocess.qbk @@ -5944,7 +5944,7 @@ to the segment manager. Because of this, in [*Boost.Interprocess] all managed memory segments derive from a common class that implements memory-independent (shared memory, memory mapped files) functions: [@../../boost/interprocess/detail/managed_memory_impl.hpp -boost::interprocess::detail::basic_managed_memory_impl] +boost::interprocess::ipcdetail::basic_managed_memory_impl] Deriving from this class, [*Boost.Interprocess] implements several managed memory classes, for different memory backends: @@ -6315,7 +6315,7 @@ that boost::interprocess::rbtree_best_fit class offers: * The [*allocate()] function must return 0 if there is no more available memory. The memory returned by [*my_algorithm] must be aligned to the most restrictive memory alignment of the system, for example, - to the value returned by *detail::alignment_of::value*. + to the value returned by *ipcdetail::alignment_of::value*. This function should be executed with the synchronization capabilities offered by `typename mutex_family::mutex_type` interprocess_mutex. That means, that if we define `typedef mutex_family mutex_family;` then this function should offer diff --git a/example/Jamfile.v2 b/example/Jamfile.v2 index 3b03c03..622ce6a 100644 --- a/example/Jamfile.v2 +++ b/example/Jamfile.v2 @@ -48,4 +48,4 @@ rule test_all return $(all_rules) ; } -test-suite interprocess_example : [ test_all r ] : multi ; +test-suite interprocess_example : [ test_all r ] : multi ; \ No newline at end of file diff --git a/example/doc_file_mapping.cpp b/example/doc_file_mapping.cpp index b2efade..fc6ef75 100644 --- a/example/doc_file_mapping.cpp +++ b/example/doc_file_mapping.cpp @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) //Define file names //<- #if 1 - std::string file_name(boost::interprocess::detail::get_temporary_path()); + std::string file_name(boost::interprocess::ipcdetail::get_temporary_path()); file_name += "/"; file_name += test::get_process_id_name(); const char *FileName = file_name.c_str(); #else diff --git a/example/doc_managed_copy_on_write.cpp b/example/doc_managed_copy_on_write.cpp index 5bd0033..d7adf9c 100644 --- a/example/doc_managed_copy_on_write.cpp +++ b/example/doc_managed_copy_on_write.cpp @@ -25,10 +25,10 @@ int main() //Define file names //<- #if 1 - std::string managed_file(boost::interprocess::detail::get_temporary_path()); + std::string managed_file(boost::interprocess::ipcdetail::get_temporary_path()); managed_file += "/"; managed_file += test::get_process_id_name(); const char *ManagedFile = managed_file.c_str(); - std::string managed_file2(boost::interprocess::detail::get_temporary_path()); + std::string managed_file2(boost::interprocess::ipcdetail::get_temporary_path()); managed_file2 += "/"; managed_file2 += test::get_process_id_name(); managed_file2 += "_2"; const char *ManagedFile2 = managed_file2.c_str(); #else diff --git a/example/doc_managed_mapped_file.cpp b/example/doc_managed_mapped_file.cpp index 1133ff3..6da9e1c 100644 --- a/example/doc_managed_mapped_file.cpp +++ b/example/doc_managed_mapped_file.cpp @@ -29,7 +29,7 @@ int main () //Define file names //<- #if 1 - std::string file(boost::interprocess::detail::get_temporary_path()); + std::string file(boost::interprocess::ipcdetail::get_temporary_path()); file += "/"; file += test::get_process_id_name(); const char *FileName = file.c_str(); #else diff --git a/example/doc_shared_ptr.cpp b/example/doc_shared_ptr.cpp index 6352eea..f2fc673 100644 --- a/example/doc_shared_ptr.cpp +++ b/example/doc_shared_ptr.cpp @@ -51,7 +51,7 @@ int main () //Define file names //<- #if 1 - std::string mapped_file(boost::interprocess::detail::get_temporary_path()); + std::string mapped_file(boost::interprocess::ipcdetail::get_temporary_path()); mapped_file += "/"; mapped_file += test::get_process_id_name(); const char *MappedFile = mapped_file.c_str(); #else diff --git a/example/doc_unique_ptr.cpp b/example/doc_unique_ptr.cpp index 8a4bdc0..6fc66af 100644 --- a/example/doc_unique_ptr.cpp +++ b/example/doc_unique_ptr.cpp @@ -53,7 +53,7 @@ int main () //Define file names //<- #if 1 - std::string mapped_file(boost::interprocess::detail::get_temporary_path()); + std::string mapped_file(boost::interprocess::ipcdetail::get_temporary_path()); mapped_file += "/"; mapped_file += test::get_process_id_name(); const char *MappedFile = mapped_file.c_str(); #else diff --git a/proj/to-do.txt b/proj/to-do.txt index 52d191f..160692b 100644 --- a/proj/to-do.txt +++ b/proj/to-do.txt @@ -238,4 +238,4 @@ MyRobustMutexLockFile() unlink(lockfilename) } -detail::intermodule_singleton::get(); +ipcdetail::intermodule_singleton::get(); diff --git a/proj/vc7ide/Interprocess.sln b/proj/vc7ide/Interprocess.sln index 98e1298..64cdd1b 100644 --- a/proj/vc7ide/Interprocess.sln +++ b/proj/vc7ide/Interprocess.sln @@ -399,6 +399,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pair_test", "pair_test.vcpr ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mutex_timeout_test", "mutex_timeout_test.vcproj", "{83581CCE-487E-3292-A4E7-BA07926D3A27}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug @@ -807,6 +811,10 @@ Global {58CA17C5-A74F-9602-48FE-B06310DA7FA6}.Debug.Build.0 = Debug|Win32 {58CA17C5-A74F-9602-48FE-B06310DA7FA6}.Release.ActiveCfg = Release|Win32 {58CA17C5-A74F-9602-48FE-B06310DA7FA6}.Release.Build.0 = Release|Win32 + {83581CCE-487E-3292-A4E7-BA07926D3A27}.Debug.ActiveCfg = Debug|Win32 + {83581CCE-487E-3292-A4E7-BA07926D3A27}.Debug.Build.0 = Debug|Win32 + {83581CCE-487E-3292-A4E7-BA07926D3A27}.Release.ActiveCfg = Release|Win32 + {83581CCE-487E-3292-A4E7-BA07926D3A27}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection diff --git a/proj/vc7ide/interprocesslib.vcproj b/proj/vc7ide/interprocesslib.vcproj index 81441a1..2effd7c 100644 --- a/proj/vc7ide/interprocesslib.vcproj +++ b/proj/vc7ide/interprocesslib.vcproj @@ -140,125 +140,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/adaptive_node_pool_test.cpp b/test/adaptive_node_pool_test.cpp index 14b7470..365397d 100644 --- a/test/adaptive_node_pool_test.cpp +++ b/test/adaptive_node_pool_test.cpp @@ -18,7 +18,7 @@ typedef managed_shared_memory::segment_manager segment_manager_t; int main () { - typedef detail::private_adaptive_node_pool + typedef ipcdetail::private_adaptive_node_pool node_pool_t; if(!test::test_all_node_pool()) diff --git a/test/adaptive_pool_test.cpp b/test/adaptive_pool_test.cpp index b00c0ef..fe3b85e 100644 --- a/test/adaptive_pool_test.cpp +++ b/test/adaptive_pool_test.cpp @@ -26,14 +26,14 @@ using namespace boost::interprocess; typedef adaptive_pool shmem_node_allocator_t; -typedef detail::adaptive_pool_v1 +typedef ipcdetail::adaptive_pool_v1 shmem_node_allocator_v1_t; //Explicit instantiations to catch compilation errors template class adaptive_pool; -template class detail::adaptive_pool_v1; +template class ipcdetail::adaptive_pool_v1; template class adaptive_pool; -template class detail::adaptive_pool_v1; +template class ipcdetail::adaptive_pool_v1; //Alias list types typedef list MyShmList; diff --git a/test/allocator_v1.hpp b/test/allocator_v1.hpp index e3829b2..612c4c9 100644 --- a/test/allocator_v1.hpp +++ b/test/allocator_v1.hpp @@ -70,9 +70,9 @@ class allocator_v1 ::type pointer; typedef typename boost:: pointer_to_other::type const_pointer; - typedef typename detail::add_reference + typedef typename ipcdetail::add_reference ::type reference; - typedef typename detail::add_reference + typedef typename ipcdetail::add_reference ::type const_reference; typedef typename segment_manager::size_type size_type; typedef typename segment_manager::difference_type difference_type; @@ -86,7 +86,7 @@ class allocator_v1 //!Returns the segment manager. Never throws segment_manager* get_segment_manager()const - { return detail::get_pointer(mp_mngr); } + { return ipcdetail::get_pointer(mp_mngr); } /* //!Returns address of mutable object. Never throws pointer address(reference value) const @@ -116,12 +116,12 @@ class allocator_v1 //!Deallocates memory previously allocated. Never throws void deallocate(const pointer &ptr, size_type) - { mp_mngr->deallocate((void*)detail::get_pointer(ptr)); } + { mp_mngr->deallocate((void*)ipcdetail::get_pointer(ptr)); } //!Construct object, calling constructor. //!Throws if T(const T&) throws void construct(const pointer &ptr, const_reference value) - { new((void*)detail::get_pointer(ptr)) value_type(value); } + { new((void*)ipcdetail::get_pointer(ptr)) value_type(value); } //!Destroys object. Throws if object's destructor throws void destroy(const pointer &ptr) @@ -134,7 +134,7 @@ class allocator_v1 //!Swap segment manager. Does not throw. If each allocator_v1 is placed in //!different memory segments, the result is undefined. friend void swap(self_t &alloc1, self_t &alloc2) - { detail::do_swap(alloc1.mp_mngr, alloc2.mp_mngr); } + { ipcdetail::do_swap(alloc1.mp_mngr, alloc2.mp_mngr); } }; //!Equality test for same type of allocator_v1 diff --git a/test/cached_adaptive_pool_test.cpp b/test/cached_adaptive_pool_test.cpp index bd675a9..2d7f409 100644 --- a/test/cached_adaptive_pool_test.cpp +++ b/test/cached_adaptive_pool_test.cpp @@ -27,15 +27,15 @@ typedef cached_adaptive_pool cached_node_allocator_t; -typedef detail::cached_adaptive_pool_v1 +typedef ipcdetail::cached_adaptive_pool_v1 cached_node_allocator_v1_t; //Explicit instantiations to catch compilation errors template class cached_adaptive_pool; -template class detail::cached_adaptive_pool_v1; +template class ipcdetail::cached_adaptive_pool_v1; template class cached_adaptive_pool; -template class detail::cached_adaptive_pool_v1; +template class ipcdetail::cached_adaptive_pool_v1; //Alias list types typedef list MyShmList; diff --git a/test/cached_node_allocator_test.cpp b/test/cached_node_allocator_test.cpp index 62113fa..555db6b 100644 --- a/test/cached_node_allocator_test.cpp +++ b/test/cached_node_allocator_test.cpp @@ -25,15 +25,15 @@ using namespace boost::interprocess; typedef cached_node_allocator cached_node_allocator_t; -typedef detail::cached_node_allocator_v1 +typedef ipcdetail::cached_node_allocator_v1 cached_node_allocator_v1_t; //Explicit instantiations to catch compilation errors template class cached_node_allocator; -template class detail::cached_node_allocator_v1; +template class ipcdetail::cached_node_allocator_v1; template class cached_node_allocator; -template class detail::cached_node_allocator_v1; +template class ipcdetail::cached_node_allocator_v1; //Alias list types typedef list MyShmList; diff --git a/test/deque_test.cpp b/test/deque_test.cpp index a1fa632..e694fdf 100644 --- a/test/deque_test.cpp +++ b/test/deque_test.cpp @@ -49,14 +49,14 @@ template class boost::interprocess::deque -bool copyable_only(V1 *, V2 *, detail::false_type) +bool copyable_only(V1 *, V2 *, ipcdetail::false_type) { return true; } //Function to check if both sets are equal template -bool copyable_only(V1 *shmdeque, V2 *stddeque, detail::true_type) +bool copyable_only(V1 *shmdeque, V2 *stddeque, ipcdetail::true_type) { typedef typename V1::value_type IntType; std::size_t size = shmdeque->size(); @@ -256,7 +256,7 @@ bool do_test() } if(!copyable_only(shmdeque, stddeque - ,detail::bool_::value>())){ + ,ipcdetail::bool_::value>())){ return false; } diff --git a/test/dummy_test_allocator.hpp b/test/dummy_test_allocator.hpp index 1adb50d..be092fe 100644 --- a/test/dummy_test_allocator.hpp +++ b/test/dummy_test_allocator.hpp @@ -57,9 +57,9 @@ class dummy_test_allocator typedef T value_type; typedef T * pointer; typedef const T * const_pointer; - typedef typename detail::add_reference + typedef typename ipcdetail::add_reference ::type reference; - typedef typename detail::add_reference + typedef typename ipcdetail::add_reference ::type const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; diff --git a/test/emplace_test.hpp b/test/emplace_test.hpp index 2f4e5d7..93408ce 100644 --- a/test/emplace_test.hpp +++ b/test/emplace_test.hpp @@ -158,7 +158,7 @@ static EmplaceIntPair * expected_pair = initialize_emplace_int_pair(); template -bool test_emplace_back(detail::true_) +bool test_emplace_back(ipcdetail::true_) { std::cout << "Starting test_emplace_back." << std::endl << " Class: " << typeid(Container).name() << std::endl; @@ -195,11 +195,11 @@ bool test_emplace_back(detail::true_) } template -bool test_emplace_back(detail::false_) +bool test_emplace_back(ipcdetail::false_) { return true; } template -bool test_emplace_front(detail::true_) +bool test_emplace_front(ipcdetail::true_) { std::cout << "Starting test_emplace_front." << std::endl << " Class: " << typeid(Container).name() << std::endl; @@ -235,11 +235,11 @@ bool test_emplace_front(detail::true_) } template -bool test_emplace_front(detail::false_) +bool test_emplace_front(ipcdetail::false_) { return true; } template -bool test_emplace_before(detail::true_) +bool test_emplace_before(ipcdetail::true_) { std::cout << "Starting test_emplace_before." << std::endl << " Class: " << typeid(Container).name() << std::endl; @@ -310,11 +310,11 @@ bool test_emplace_before(detail::true_) } template -bool test_emplace_before(detail::false_) +bool test_emplace_before(ipcdetail::false_) { return true; } template -bool test_emplace_after(detail::true_) +bool test_emplace_after(ipcdetail::true_) { std::cout << "Starting test_emplace_after." << std::endl << " Class: " << typeid(Container).name() << std::endl; @@ -384,11 +384,11 @@ bool test_emplace_after(detail::true_) } template -bool test_emplace_after(detail::false_) +bool test_emplace_after(ipcdetail::false_) { return true; } template -bool test_emplace_assoc(detail::true_) +bool test_emplace_assoc(ipcdetail::true_) { std::cout << "Starting test_emplace_assoc." << std::endl << " Class: " << typeid(Container).name() << std::endl; @@ -424,11 +424,11 @@ bool test_emplace_assoc(detail::true_) } template -bool test_emplace_assoc(detail::false_) +bool test_emplace_assoc(ipcdetail::false_) { return true; } template -bool test_emplace_hint(detail::true_) +bool test_emplace_hint(ipcdetail::true_) { std::cout << "Starting test_emplace_hint." << std::endl << " Class: " << typeid(Container).name() << std::endl; @@ -467,11 +467,11 @@ bool test_emplace_hint(detail::true_) } template -bool test_emplace_hint(detail::false_) +bool test_emplace_hint(ipcdetail::false_) { return true; } template -bool test_emplace_assoc_pair(detail::true_) +bool test_emplace_assoc_pair(ipcdetail::true_) { std::cout << "Starting test_emplace_assoc_pair." << std::endl << " Class: " << typeid(Container).name() << std::endl; @@ -526,11 +526,11 @@ bool test_emplace_assoc_pair(detail::true_) } template -bool test_emplace_assoc_pair(detail::false_) +bool test_emplace_assoc_pair(ipcdetail::false_) { return true; } template -bool test_emplace_hint_pair(detail::true_) +bool test_emplace_hint_pair(ipcdetail::true_) { std::cout << "Starting test_emplace_hint_pair." << std::endl << " Class: " << typeid(Container).name() << std::endl; @@ -585,14 +585,14 @@ bool test_emplace_hint_pair(detail::true_) } template -bool test_emplace_hint_pair(detail::false_) +bool test_emplace_hint_pair(ipcdetail::false_) { return true; } template struct emplace_active { static const bool value = (0 != (O & Mask)); - typedef detail::bool_ type; + typedef ipcdetail::bool_ type; operator type() const{ return type(); } }; diff --git a/test/expand_bwd_test_allocator.hpp b/test/expand_bwd_test_allocator.hpp index ca1e3dd..b4876d9 100644 --- a/test/expand_bwd_test_allocator.hpp +++ b/test/expand_bwd_test_allocator.hpp @@ -57,9 +57,9 @@ class expand_bwd_test_allocator typedef T value_type; typedef T * pointer; typedef const T * const_pointer; - typedef typename detail::add_reference + typedef typename ipcdetail::add_reference ::type reference; - typedef typename detail::add_reference + typedef typename ipcdetail::add_reference ::type const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; @@ -110,9 +110,9 @@ class expand_bwd_test_allocator friend void swap(self_t &alloc1, self_t &alloc2) { - detail::do_swap(alloc1.mp_buffer, alloc2.mp_buffer); - detail::do_swap(alloc1.m_size, alloc2.m_size); - detail::do_swap(alloc1.m_offset, alloc2.m_offset); + ipcdetail::do_swap(alloc1.mp_buffer, alloc2.mp_buffer); + ipcdetail::do_swap(alloc1.m_size, alloc2.m_size); + ipcdetail::do_swap(alloc1.m_offset, alloc2.m_offset); } //Experimental version 2 expand_bwd_test_allocator functions diff --git a/test/file_lock_test.cpp b/test/file_lock_test.cpp index 039f669..a11ad92 100644 --- a/test/file_lock_test.cpp +++ b/test/file_lock_test.cpp @@ -24,7 +24,7 @@ using namespace boost::interprocess; static const std::size_t FileSize = 1000; inline std::string get_filename() { - std::string ret (detail::get_temporary_path()); + std::string ret (ipcdetail::get_temporary_path()); ret += "/"; ret += test::get_process_id_name(); return ret; diff --git a/test/file_mapping_test.cpp b/test/file_mapping_test.cpp index 044933b..b8e6866 100644 --- a/test/file_mapping_test.cpp +++ b/test/file_mapping_test.cpp @@ -23,7 +23,7 @@ using namespace boost::interprocess; inline std::string get_filename() { - std::string ret (detail::get_temporary_path()); + std::string ret (ipcdetail::get_temporary_path()); ret += "/"; ret += test::get_process_id_name(); return ret; diff --git a/test/get_process_id_name.hpp b/test/get_process_id_name.hpp index 26c51ad..2a2fecb 100644 --- a/test/get_process_id_name.hpp +++ b/test/get_process_id_name.hpp @@ -23,7 +23,7 @@ namespace test{ inline void get_process_id_name(std::string &str) { std::stringstream sstr; - sstr << "process_" << boost::interprocess::detail::get_current_process_id() << std::ends; + sstr << "process_" << boost::interprocess::ipcdetail::get_current_process_id() << std::ends; str = sstr.str().c_str(); } diff --git a/test/heap_allocator_v1.hpp b/test/heap_allocator_v1.hpp index e75361b..07c1560 100644 --- a/test/heap_allocator_v1.hpp +++ b/test/heap_allocator_v1.hpp @@ -70,9 +70,9 @@ class heap_allocator_v1 ::type pointer; typedef typename boost:: pointer_to_other::type const_pointer; - typedef typename detail::add_reference + typedef typename ipcdetail::add_reference ::type reference; - typedef typename detail::add_reference + typedef typename ipcdetail::add_reference ::type const_reference; typedef typename SegmentManager::size_type size_type; typedef typename SegmentManager::difference_type difference_type; @@ -86,7 +86,7 @@ class heap_allocator_v1 //!Returns the segment manager. Never throws segment_manager* get_segment_manager()const - { return detail::get_pointer(mp_mngr); } + { return ipcdetail::get_pointer(mp_mngr); } /* //!Returns address of mutable object. Never throws pointer address(reference value) const @@ -116,12 +116,12 @@ class heap_allocator_v1 //!Deallocates memory previously allocated. Never throws void deallocate(const pointer &ptr, size_type) - { return ::delete[] detail::get_pointer(ptr) ; } + { return ::delete[] ipcdetail::get_pointer(ptr) ; } //!Construct object, calling constructor. //!Throws if T(const T&) throws void construct(const pointer &ptr, const_reference value) - { new((void*)detail::get_pointer(ptr)) value_type(value); } + { new((void*)ipcdetail::get_pointer(ptr)) value_type(value); } //!Destroys object. Throws if object's destructor throws void destroy(const pointer &ptr) @@ -134,7 +134,7 @@ class heap_allocator_v1 //!Swap segment manager. Does not throw. If each heap_allocator_v1 is placed in //!different memory segments, the result is undefined. friend void swap(self_t &alloc1, self_t &alloc2) - { detail::do_swap(alloc1.mp_mngr, alloc2.mp_mngr); } + { ipcdetail::do_swap(alloc1.mp_mngr, alloc2.mp_mngr); } }; //!Equality test for same type of heap_allocator_v1 diff --git a/test/intermodule_singleton_test.cpp b/test/intermodule_singleton_test.cpp index 6ea8b16..a207797 100644 --- a/test/intermodule_singleton_test.cpp +++ b/test/intermodule_singleton_test.cpp @@ -92,12 +92,12 @@ int intermodule_singleton_test() int main () { - if(0 != intermodule_singleton_test()){ + if(0 != intermodule_singleton_test()){ return 1; } #ifdef BOOST_INTERPROCESS_WINDOWS - if(0 != intermodule_singleton_test()){ + if(0 != intermodule_singleton_test()){ return 1; } #endif diff --git a/test/intersegment_ptr_test.cpp b/test/intersegment_ptr_test.cpp index d068624..bfd8b35 100644 --- a/test/intersegment_ptr_test.cpp +++ b/test/intersegment_ptr_test.cpp @@ -27,13 +27,13 @@ bool test_types_and_convertions() typedef intersegment_ptr pvint_t; typedef intersegment_ptr pcvint_t; - if(!detail::is_same::value) + if(!ipcdetail::is_same::value) return false; - if(!detail::is_same::value) + if(!ipcdetail::is_same::value) return false; - if(!detail::is_same::value) + if(!ipcdetail::is_same::value) return false; - if(!detail::is_same::value) + if(!ipcdetail::is_same::value) return false; int dummy_int = 9; diff --git a/test/managed_mapped_file_test.cpp b/test/managed_mapped_file_test.cpp index 1d64341..1157874 100644 --- a/test/managed_mapped_file_test.cpp +++ b/test/managed_mapped_file_test.cpp @@ -20,7 +20,7 @@ using namespace boost::interprocess; inline std::string get_filename() { - std::string ret (detail::get_temporary_path()); + std::string ret (ipcdetail::get_temporary_path()); ret += "/"; ret += test::get_process_id_name(); return ret; diff --git a/test/managed_xsi_shared_memory_test.cpp b/test/managed_xsi_shared_memory_test.cpp index eeb851c..608e546 100644 --- a/test/managed_xsi_shared_memory_test.cpp +++ b/test/managed_xsi_shared_memory_test.cpp @@ -52,7 +52,7 @@ class xsi_shared_memory_remover inline std::string get_filename() { - std::string ret (detail::get_temporary_path()); + std::string ret (ipcdetail::get_temporary_path()); ret += "/"; ret += test::get_process_id_name(); return ret; @@ -65,7 +65,7 @@ int main () const char *const ShmemName = filename.c_str(); file_mapping::remove(ShmemName); - { detail::file_wrapper(create_only, ShmemName, read_write); } + { ipcdetail::file_wrapper(create_only, ShmemName, read_write); } xsi_key key(ShmemName, 1); file_mapping::remove(ShmemName); int shmid; diff --git a/test/mapped_file_test.cpp b/test/mapped_file_test.cpp index 43f862f..74b0f30 100644 --- a/test/mapped_file_test.cpp +++ b/test/mapped_file_test.cpp @@ -26,7 +26,7 @@ using namespace boost::interprocess; static const std::size_t FileSize = 1000; inline std::string get_filename() { - std::string ret (detail::get_temporary_path()); + std::string ret (ipcdetail::get_temporary_path()); ret += "/"; ret += test::get_process_id_name(); return ret; @@ -45,11 +45,11 @@ struct file_destroyer //in generic named_creation_template functions class mapped_file_creation_test_wrapper : public file_destroyer - , public boost::interprocess::detail::managed_open_or_create_impl - + , public boost::interprocess::ipcdetail::managed_open_or_create_impl + { - typedef boost::interprocess::detail::managed_open_or_create_impl - mapped_file; + typedef boost::interprocess::ipcdetail::managed_open_or_create_impl + mapped_file; public: mapped_file_creation_test_wrapper(boost::interprocess::create_only_t) : mapped_file(boost::interprocess::create_only, get_filename().c_str(), FileSize, read_write, 0, permissions()) @@ -66,8 +66,8 @@ class mapped_file_creation_test_wrapper int main () { - typedef boost::interprocess::detail::managed_open_or_create_impl - mapped_file; + typedef boost::interprocess::ipcdetail::managed_open_or_create_impl + mapped_file; file_mapping::remove(get_filename().c_str()); test::test_named_creation(); diff --git a/test/memory_algorithm_test_template.hpp b/test/memory_algorithm_test_template.hpp index 2af20e6..1c95da0 100644 --- a/test/memory_algorithm_test_template.hpp +++ b/test/memory_algorithm_test_template.hpp @@ -679,7 +679,7 @@ bool test_many_equal_allocation(Allocator &a) typename multiallocation_chain::size_type n = chain.size(); while(!chain.empty()){ - buffers.push_back(detail::get_pointer(chain.front())); + buffers.push_back(ipcdetail::get_pointer(chain.front())); chain.pop_front(); } if(n != std::size_t((i+1)*2)) @@ -788,7 +788,7 @@ bool test_many_different_allocation(Allocator &a) break; typename multiallocation_chain::size_type n = chain.size(); while(!chain.empty()){ - buffers.push_back(detail::get_pointer(chain.front())); + buffers.push_back(ipcdetail::get_pointer(chain.front())); chain.pop_front(); } if(n != ArraySize) diff --git a/test/mutex_test_template.hpp b/test/mutex_test_template.hpp index 5e6f455..241ba19 100644 --- a/test/mutex_test_template.hpp +++ b/test/mutex_test_template.hpp @@ -180,6 +180,28 @@ void lock_and_sleep(void *arg, M &sm) pdata->m_value = shared_val; } +template +void lock_and_catch_errors(void *arg, M &sm) +{ + data *pdata = static_cast*>(arg); + try + { + boost::interprocess::scoped_lock l(sm); + if(pdata->m_secs){ + boost::thread::sleep(xsecs(pdata->m_secs)); + } + else{ + boost::thread::sleep(xsecs(2*BaseSeconds)); + } + ++shared_val; + pdata->m_value = shared_val; + } + catch(interprocess_exception const & e) + { + pdata->m_error = e.get_error_code(); + } +} + template void try_lock_and_sleep(void *arg, M &sm) { @@ -243,6 +265,49 @@ void test_mutex_lock() assert(d2.m_value == 2); } +template +void test_mutex_lock_timeout() +{ + shared_val = 0; + + M m1, m2; + M *pm1, *pm2; + + if(SameObject){ + pm1 = pm2 = &m1; + } + else{ + pm1 = &m1; + pm2 = &m2; + } + + int wait_time_s = BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS / 1000; + if (wait_time_s == 0 ) + wait_time_s = 1; + + data d1(1, wait_time_s * 2); + data d2(2, wait_time_s * 2); + + // Locker one launches, and holds the lock for wait_time_s * 2 seconds. + boost::thread tm1(thread_adapter(&lock_and_sleep, &d1, *pm1)); + + //Wait 1*BaseSeconds + boost::thread::sleep(xsecs(wait_time_s)); + + // Locker two launches, and attempts to hold the lock for wait_time_s * 2 seconds. + boost::thread tm2(thread_adapter(&lock_and_catch_errors, &d2, *pm2)); + + //Wait completion + tm1.join(); + boost::thread::sleep(xsecs(1*BaseSeconds)); + tm2.join(); + + assert(d1.m_value == 1); + assert(d2.m_value == -1); + assert(d1.m_error == no_error); + assert(d2.m_error == boost::interprocess::timeout_when_locking_error); +} + template void test_mutex_try_lock() { diff --git a/test/mutex_timeout_test.cpp b/test/mutex_timeout_test.cpp new file mode 100644 index 0000000..75b8974 --- /dev/null +++ b/test/mutex_timeout_test.cpp @@ -0,0 +1,31 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2004-2011. 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) +// +// See http://www.boost.org/libs/interprocess for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +// enable timeout feature +#define BOOST_INTERPROCESS_ENABLE_TIMEOUT_WHEN_LOCKING +#define BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS 1000 + +#include +#include +#include +#include +#include "mutex_test_template.hpp" + +int main () +{ + using namespace boost::interprocess; + + test::test_mutex_lock_timeout(); + test::test_mutex_lock_timeout(); + + return 0; +} + +#include diff --git a/test/named_condition_test.cpp b/test/named_condition_test.cpp index b4d5013..4a12c90 100644 --- a/test/named_condition_test.cpp +++ b/test/named_condition_test.cpp @@ -78,7 +78,7 @@ class named_condition_creation_test_wrapper ~named_condition_creation_test_wrapper() { if(--count_){ - detail::interprocess_tester:: + ipcdetail::interprocess_tester:: dont_close_on_destruction(static_cast(*this)); } } diff --git a/test/named_construct_test.cpp b/test/named_construct_test.cpp index 9a8779e..294e091 100644 --- a/test/named_construct_test.cpp +++ b/test/named_construct_test.cpp @@ -50,11 +50,11 @@ struct unique_name_generator typedef simple_pair simple_type; typedef array_pair array_type; typedef array_it_pair array_it_type; - static const detail::unique_instance_t *get_simple_name() + static const ipcdetail::unique_instance_t *get_simple_name() { return 0; } - static const detail::unique_instance_t *get_array_name() + static const ipcdetail::unique_instance_t *get_array_name() { return 0; } - static const detail::unique_instance_t *get_array_it_name() + static const ipcdetail::unique_instance_t *get_array_it_name() { return 0; } }; @@ -65,11 +65,11 @@ struct anonymous_name_generator typedef simple_pair simple_type; typedef array_pair array_type; typedef array_it_pair array_it_type; - static const detail::anonymous_instance_t *get_simple_name() + static const ipcdetail::anonymous_instance_t *get_simple_name() { return 0; } - static const detail::anonymous_instance_t *get_array_name() + static const ipcdetail::anonymous_instance_t *get_array_name() { return 0; } - static const detail::anonymous_instance_t *get_array_it_name() + static const ipcdetail::anonymous_instance_t *get_array_it_name() { return 0; } }; diff --git a/test/named_mutex_test.cpp b/test/named_mutex_test.cpp index 376b63f..01b770c 100644 --- a/test/named_mutex_test.cpp +++ b/test/named_mutex_test.cpp @@ -38,7 +38,7 @@ class named_mutex_lock_test_wrapper ~named_mutex_lock_test_wrapper() { if(--count_){ - detail::interprocess_tester:: + ipcdetail::interprocess_tester:: dont_close_on_destruction(static_cast(*this)); } } @@ -69,7 +69,7 @@ class named_mutex_creation_test_wrapper ~named_mutex_creation_test_wrapper() { if(--count_){ - detail::interprocess_tester:: + ipcdetail::interprocess_tester:: dont_close_on_destruction(static_cast(*this)); } } diff --git a/test/named_recursive_mutex_test.cpp b/test/named_recursive_mutex_test.cpp index fb8c185..5255ac5 100644 --- a/test/named_recursive_mutex_test.cpp +++ b/test/named_recursive_mutex_test.cpp @@ -38,7 +38,7 @@ class named_recursive_mutex_lock_test_wrapper ~named_recursive_mutex_lock_test_wrapper() { if(--count_){ - detail::interprocess_tester:: + ipcdetail::interprocess_tester:: dont_close_on_destruction(static_cast(*this)); } } @@ -69,7 +69,7 @@ class named_mutex_creation_test_wrapper ~named_mutex_creation_test_wrapper() { if(--count_){ - detail::interprocess_tester:: + ipcdetail::interprocess_tester:: dont_close_on_destruction(static_cast(*this)); } } diff --git a/test/named_semaphore_test.cpp b/test/named_semaphore_test.cpp index 09d70cf..f410a1d 100644 --- a/test/named_semaphore_test.cpp +++ b/test/named_semaphore_test.cpp @@ -55,7 +55,7 @@ class named_semaphore_test_wrapper ~named_semaphore_test_wrapper() { if(--count_){ - detail::interprocess_tester:: + ipcdetail::interprocess_tester:: dont_close_on_destruction(static_cast(*this)); } } diff --git a/test/named_upgradable_mutex_test.cpp b/test/named_upgradable_mutex_test.cpp index da06ebb..692375a 100644 --- a/test/named_upgradable_mutex_test.cpp +++ b/test/named_upgradable_mutex_test.cpp @@ -37,7 +37,7 @@ class named_upgradable_mutex_lock_test_wrapper ~named_upgradable_mutex_lock_test_wrapper() { if(--count_){ - detail::interprocess_tester:: + ipcdetail::interprocess_tester:: dont_close_on_destruction(static_cast(*this)); } } @@ -72,7 +72,7 @@ class named_upgradable_mutex_creation_test_wrapper ~named_upgradable_mutex_creation_test_wrapper() { if(--count_){ - detail::interprocess_tester:: + ipcdetail::interprocess_tester:: dont_close_on_destruction(static_cast(*this)); } } diff --git a/test/node_allocator_test.cpp b/test/node_allocator_test.cpp index 14c2ef0..bf3efd2 100644 --- a/test/node_allocator_test.cpp +++ b/test/node_allocator_test.cpp @@ -25,14 +25,14 @@ using namespace boost::interprocess; //Alias an integer node allocator type typedef node_allocator shmem_node_allocator_t; -typedef detail::node_allocator_v1 +typedef ipcdetail::node_allocator_v1 shmem_node_allocator_v1_t; //Explicit instantiations to catch compilation errors template class node_allocator; -template class detail::node_allocator_v1; +template class ipcdetail::node_allocator_v1; template class node_allocator; -template class detail::node_allocator_v1; +template class ipcdetail::node_allocator_v1; //Alias list types typedef list MyShmList; diff --git a/test/node_pool_test.cpp b/test/node_pool_test.cpp index 5deb582..71c8142 100644 --- a/test/node_pool_test.cpp +++ b/test/node_pool_test.cpp @@ -17,7 +17,7 @@ typedef managed_shared_memory::segment_manager segment_manager_t; int main () { - typedef detail::private_node_pool + typedef ipcdetail::private_node_pool node_pool_t; if(!test::test_all_node_pool()) diff --git a/test/offset_ptr_test.cpp b/test/offset_ptr_test.cpp index dbd6a99..13af11d 100644 --- a/test/offset_ptr_test.cpp +++ b/test/offset_ptr_test.cpp @@ -21,13 +21,13 @@ bool test_types_and_convertions() typedef offset_ptr pvint_t; typedef offset_ptr pcvint_t; - if(!detail::is_same::value) + if(!ipcdetail::is_same::value) return false; - if(!detail::is_same::value) + if(!ipcdetail::is_same::value) return false; - if(!detail::is_same::value) + if(!ipcdetail::is_same::value) return false; - if(!detail::is_same::value) + if(!ipcdetail::is_same::value) return false; int dummy_int = 9; diff --git a/test/private_adaptive_pool_test.cpp b/test/private_adaptive_pool_test.cpp index 27d2dd7..c4d0965 100644 --- a/test/private_adaptive_pool_test.cpp +++ b/test/private_adaptive_pool_test.cpp @@ -25,14 +25,14 @@ using namespace boost::interprocess; //Alias a private adaptive pool that allocates ints typedef private_adaptive_pool priv_node_allocator_t; -typedef detail::private_adaptive_pool_v1 +typedef ipcdetail::private_adaptive_pool_v1 priv_node_allocator_v1_t; //Explicit instantiations to catch compilation errors template class private_adaptive_pool; -template class detail::private_adaptive_pool_v1; +template class ipcdetail::private_adaptive_pool_v1; template class private_adaptive_pool; -template class detail::private_adaptive_pool_v1; +template class ipcdetail::private_adaptive_pool_v1; //Alias list types typedef list MyShmList; diff --git a/test/private_node_allocator_test.cpp b/test/private_node_allocator_test.cpp index 3dd0fa0..f2698e8 100644 --- a/test/private_node_allocator_test.cpp +++ b/test/private_node_allocator_test.cpp @@ -25,14 +25,14 @@ using namespace boost::interprocess; //Alias an integer node allocator type typedef private_node_allocator priv_node_allocator_t; -typedef detail::private_node_allocator_v1 +typedef ipcdetail::private_node_allocator_v1 priv_node_allocator_v1_t; //Explicit instantiations to catch compilation errors template class private_node_allocator; -template class detail::private_node_allocator_v1; +template class ipcdetail::private_node_allocator_v1; template class private_node_allocator; -template class detail::private_node_allocator_v1; +template class ipcdetail::private_node_allocator_v1; //Alias list types typedef list MyShmList; diff --git a/test/robust_emulation_test.cpp b/test/robust_emulation_test.cpp index 188c292..3e0f1ec 100644 --- a/test/robust_emulation_test.cpp +++ b/test/robust_emulation_test.cpp @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) { using namespace boost::interprocess; return test::robust_mutex_test - < detail::robust_emulation_mutex >(argc, argv); + < ipcdetail::robust_emulation_mutex >(argc, argv); } #include diff --git a/test/robust_mutex_test.hpp b/test/robust_mutex_test.hpp index a229cd8..e4292bc 100644 --- a/test/robust_mutex_test.hpp +++ b/test/robust_mutex_test.hpp @@ -66,7 +66,7 @@ int robust_mutex_test(int argc, char *argv[]) //Wait until child locks the mutexes and dies while(!*go_ahead){ - detail::thread_yield(); + ipcdetail::thread_yield(); } std::cout << "... recovering mutex[0]" << std::endl; @@ -163,7 +163,7 @@ int robust_mutex_test(int argc, char *argv[]) //Wait until child locks the 2nd mutex and dies while(!*go_ahead2){ - detail::thread_yield(); + ipcdetail::thread_yield(); } //Done, now try to lock number 3 to see if robust diff --git a/test/robust_recursive_emulation_test.cpp b/test/robust_recursive_emulation_test.cpp index 52d8462..1b8555e 100644 --- a/test/robust_recursive_emulation_test.cpp +++ b/test/robust_recursive_emulation_test.cpp @@ -17,7 +17,7 @@ int main(int argc, char *argv[]) using namespace boost::interprocess; return test::robust_mutex_test - < detail::robust_emulation_mutex >(argc, argv); + < ipcdetail::robust_emulation_mutex >(argc, argv); } #include diff --git a/test/shared_memory_mapping_test.cpp b/test/shared_memory_mapping_test.cpp index 4cc3cea..91b63eb 100644 --- a/test/shared_memory_mapping_test.cpp +++ b/test/shared_memory_mapping_test.cpp @@ -27,20 +27,24 @@ shared_memory_object get_shared_memory_mapping() int main () { + std::string process_id = test::get_process_id_name(); + std::string process_id2(process_id); + process_id2 += "_2"; try{ const std::size_t FileSize = 99999*2; { //Remove shared memory - shared_memory_object::remove(test::get_process_id_name()); + shared_memory_object::remove(process_id.c_str()); + shared_memory_object::remove(process_id2.c_str()); //Create shared memory and file mapping - shared_memory_object mapping(create_only, test::get_process_id_name(), read_write); + shared_memory_object mapping(create_only, process_id.c_str(), read_write); mapping.truncate(FileSize); } { //Create a file mapping - shared_memory_object mapping(open_only, test::get_process_id_name(), read_write); + shared_memory_object mapping(open_only, process_id.c_str(), read_write); //Create two mapped regions, one half of the file each mapped_region region (mapping @@ -77,7 +81,7 @@ int main () //See if the pattern is correct in the file using two mapped regions { //Create a file mapping - shared_memory_object mapping(open_only, test::get_process_id_name(), read_write); + shared_memory_object mapping(open_only, process_id.c_str(), read_write); mapped_region region(mapping, read_write, 0, FileSize/2, 0); mapped_region region2(mapping, read_write, FileSize/2, FileSize - FileSize/2, 0); @@ -107,11 +111,10 @@ int main () //Now check the pattern mapping a single read only mapped_region { //Create a file mapping - shared_memory_object mapping(open_only, test::get_process_id_name(), read_only); + shared_memory_object mapping(open_only, process_id.c_str(), read_only); //Create a single regions, mapping all the file - mapped_region region (mapping - ,read_only); + mapped_region region (mapping, read_only); //Check pattern unsigned char *pattern = static_cast(region.get_address()); @@ -123,6 +126,27 @@ int main () } } } + { + //Check for busy address space + shared_memory_object mapping(open_only, process_id.c_str(), read_only); + mapped_region region (mapping, read_only); + shared_memory_object mapping2(create_only, process_id2.c_str(), read_write); + mapping2.truncate(FileSize); + try{ + mapped_region region2 (mapping2, read_only, 0, FileSize, region.get_address()); + } + catch(interprocess_exception &e){ + shared_memory_object::remove(process_id2.c_str()); + if(e.get_error_code() != busy_error){ + throw e; + } + } + catch(std::exception &){ + shared_memory_object::remove(process_id2.c_str()); + throw; + } + shared_memory_object::remove(process_id2.c_str()); + } { //Now check anonymous mapping mapped_region region(anonymous_shared_memory(FileSize)); @@ -147,7 +171,7 @@ int main () } { //Now test move semantics - shared_memory_object mapping(open_only, test::get_process_id_name(), read_write); + shared_memory_object mapping(open_only, process_id.c_str(), read_write); shared_memory_object move_ctor(boost::interprocess::move(mapping)); shared_memory_object move_assign; move_assign = boost::interprocess::move(move_ctor); @@ -155,10 +179,11 @@ int main () } } catch(std::exception &exc){ - shared_memory_object::remove(test::get_process_id_name()); + shared_memory_object::remove(process_id.c_str()); + shared_memory_object::remove(process_id2.c_str()); std::cout << "Unhandled exception: " << exc.what() << std::endl; return 1; } - shared_memory_object::remove(test::get_process_id_name()); + shared_memory_object::remove(process_id.c_str()); return 0; } diff --git a/test/shared_memory_test.cpp b/test/shared_memory_test.cpp index 5417187..6d953df 100644 --- a/test/shared_memory_test.cpp +++ b/test/shared_memory_test.cpp @@ -31,7 +31,7 @@ struct eraser } }; -typedef detail::managed_open_or_create_impl shared_memory; +typedef ipcdetail::managed_open_or_create_impl shared_memory; //This wrapper is necessary to have a common constructor //in generic named_creation_template functions diff --git a/test/shared_ptr_test.cpp b/test/shared_ptr_test.cpp index ee8c9d9..30bc0b5 100644 --- a/test/shared_ptr_test.cpp +++ b/test/shared_ptr_test.cpp @@ -585,7 +585,7 @@ void test_alias() int_shared_ptr p; int_shared_ptr p2( p, &m ); - BOOST_TEST( detail::get_pointer(p2.get()) == &m ); + BOOST_TEST( ipcdetail::get_pointer(p2.get()) == &m ); BOOST_TEST( p2? true: false ); BOOST_TEST( !!p2 ); BOOST_TEST( p2.use_count() == p.use_count() ); @@ -607,7 +607,7 @@ void test_alias() (shmem.construct(anonymous_instance)(), shmem)); const_int_shared_ptr p2( p, &m ); - BOOST_TEST( detail::get_pointer(p2.get()) == &m ); + BOOST_TEST( ipcdetail::get_pointer(p2.get()) == &m ); BOOST_TEST( p2? true: false ); BOOST_TEST( !!p2 ); BOOST_TEST( p2.use_count() == p.use_count() ); diff --git a/test/tree_test.cpp b/test/tree_test.cpp index e5692bb..5c1da9a 100644 --- a/test/tree_test.cpp +++ b/test/tree_test.cpp @@ -171,7 +171,7 @@ int main () test_move >(); } - using namespace boost::interprocess::detail; + using namespace boost::interprocess::ipcdetail; if(0 != test::set_test struct data { data(int id, int secs=0) - : m_id(id), m_value(-1), m_secs(secs) + : m_id(id), m_value(-1), m_secs(secs), m_error(no_error) {} - int m_id; - int m_value; - int m_secs; + int m_id; + int m_value; + int m_secs; + error_code_t m_error; }; static int shared_val = 0; diff --git a/test/vector_test.hpp b/test/vector_test.hpp index 9005bb7..7c5ee1c 100644 --- a/test/vector_test.hpp +++ b/test/vector_test.hpp @@ -35,14 +35,14 @@ namespace interprocess{ namespace test{ template -bool copyable_only(V1 *, V2 *, boost::interprocess::detail::false_type) +bool copyable_only(V1 *, V2 *, boost::interprocess::ipcdetail::false_type) { return true; } //Function to check if both sets are equal template -bool copyable_only(V1 *shmvector, V2 *stdvector, boost::interprocess::detail::true_type) +bool copyable_only(V1 *shmvector, V2 *stdvector, boost::interprocess::ipcdetail::true_type) { typedef typename V1::value_type IntType; std::size_t size = shmvector->size(); @@ -137,7 +137,7 @@ int vector_test() IntType aux_vect[50]; for(int i = 0; i < 50; ++i){ IntType new_int(-1); - //BOOST_STATIC_ASSERT((::boost::move_detail::is_copy_constructible::value == false)); + //BOOST_STATIC_ASSERT((::boost::move_ipcdetail::is_copy_constructible::value == false)); aux_vect[i] = boost::interprocess::move(new_int); } int aux_vect2[50]; @@ -186,7 +186,7 @@ int vector_test() if(!test::CheckEqualContainers(shmvector, stdvector)) return 1; if(!copyable_only(shmvector, stdvector - ,detail::bool_::value>())){ + ,ipcdetail::bool_::value>())){ return 1; } diff --git a/test/windows_shared_memory_test.cpp b/test/windows_shared_memory_test.cpp index 6087447..d132a3f 100644 --- a/test/windows_shared_memory_test.cpp +++ b/test/windows_shared_memory_test.cpp @@ -32,7 +32,7 @@ static const char *name_initialization_routine() } static const std::size_t ShmSize = 1000; -typedef detail::managed_open_or_create_impl +typedef ipcdetail::managed_open_or_create_impl windows_shared_memory_t; //This wrapper is necessary to have a common constructor diff --git a/test/xsi_shared_memory_mapping_test.cpp b/test/xsi_shared_memory_mapping_test.cpp index 4a5b254..c540ac7 100644 --- a/test/xsi_shared_memory_mapping_test.cpp +++ b/test/xsi_shared_memory_mapping_test.cpp @@ -52,7 +52,7 @@ class xsi_shared_memory_remover inline std::string get_filename() { - std::string ret (detail::get_temporary_path()); + std::string ret (ipcdetail::get_temporary_path()); ret += "/"; ret += test::get_process_id_name(); return ret; @@ -64,7 +64,7 @@ int main (int argc, char *argv[]) const char *names[2] = { filename.c_str(), 0 }; file_mapping::remove(names[0]); - { detail::file_wrapper(create_only, names[0], read_write); } + { ipcdetail::file_wrapper(create_only, names[0], read_write); } xsi_key key(names[0], 1); file_mapping::remove(names[0]); remove_shared_memory(key);