├── .gitattributes ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── CMakeLists.txt ├── build.jam ├── doc ├── Jamfile.v2 ├── index.idx └── interprocess.qbk ├── example ├── Jamfile.v2 ├── comp_doc_anonymous_conditionA.cpp ├── comp_doc_anonymous_conditionB.cpp ├── comp_doc_anonymous_mutexA.cpp ├── comp_doc_anonymous_mutexB.cpp ├── comp_doc_anonymous_semaphoreA.cpp ├── comp_doc_anonymous_semaphoreB.cpp ├── comp_doc_anonymous_upgradable_mutexA.cpp ├── comp_doc_anonymous_upgradable_mutexB.cpp ├── comp_doc_message_queueA.cpp ├── comp_doc_message_queueB.cpp ├── doc_adaptive_pool.cpp ├── doc_allocator.cpp ├── doc_anonymous_condition_shared_data.hpp ├── doc_anonymous_mutex_shared_data.hpp ├── doc_anonymous_semaphore_shared_data.hpp ├── doc_anonymous_shared_memory.cpp ├── doc_bufferstream.cpp ├── doc_cached_adaptive_pool.cpp ├── doc_cached_node_allocator.cpp ├── doc_complex_map.cpp ├── doc_cont.cpp ├── doc_file_mapping.cpp ├── doc_intrusive.cpp ├── doc_ipc_message.cpp ├── doc_managed_aligned_allocation.cpp ├── doc_managed_allocation_command.cpp ├── doc_managed_construction_info.cpp ├── doc_managed_copy_on_write.cpp ├── doc_managed_external_buffer.cpp ├── doc_managed_grow.cpp ├── doc_managed_heap_memory.cpp ├── doc_managed_mapped_file.cpp ├── doc_managed_multiple_allocation.cpp ├── doc_managed_raw_allocation.cpp ├── doc_map.cpp ├── doc_multi_index.cpp ├── doc_named_alloc.cpp ├── doc_named_condition_shared_data.hpp ├── doc_named_mutex.cpp ├── doc_node_allocator.cpp ├── doc_offset_ptr.cpp ├── doc_private_adaptive_pool.cpp ├── doc_private_node_allocator.cpp ├── doc_scoped_ptr.cpp ├── doc_shared_memory.cpp ├── doc_shared_ptr.cpp ├── doc_shared_ptr_explicit.cpp ├── doc_spawn_vector.cpp ├── doc_unique_ptr.cpp ├── doc_unordered_map.cpp ├── doc_upgradable_mutex_shared_data.hpp ├── doc_vectorstream.cpp ├── doc_where_allocate.cpp ├── doc_windows_shared_memory.cpp └── doc_xsi_shared_memory.cpp ├── extra ├── boost_interprocess.natvis └── boost_interprocess_printers.py ├── include └── boost │ └── interprocess │ ├── allocators │ ├── adaptive_pool.hpp │ ├── allocator.hpp │ ├── cached_adaptive_pool.hpp │ ├── cached_node_allocator.hpp │ ├── detail │ │ ├── adaptive_node_pool.hpp │ │ ├── allocator_common.hpp │ │ ├── node_pool.hpp │ │ └── node_tools.hpp │ ├── node_allocator.hpp │ ├── private_adaptive_pool.hpp │ └── private_node_allocator.hpp │ ├── anonymous_shared_memory.hpp │ ├── containers │ ├── allocation_type.hpp │ ├── containers_fwd.hpp │ ├── deque.hpp │ ├── flat_map.hpp │ ├── flat_set.hpp │ ├── list.hpp │ ├── map.hpp │ ├── pair.hpp │ ├── set.hpp │ ├── slist.hpp │ ├── stable_vector.hpp │ ├── string.hpp │ ├── vector.hpp │ └── version_type.hpp │ ├── creation_tags.hpp │ ├── detail │ ├── atomic.hpp │ ├── cast_tags.hpp │ ├── char_wchar_holder.hpp │ ├── config_begin.hpp │ ├── config_end.hpp │ ├── config_external_begin.hpp │ ├── config_external_end.hpp │ ├── file_locking_helpers.hpp │ ├── file_wrapper.hpp │ ├── intermodule_singleton.hpp │ ├── intermodule_singleton_common.hpp │ ├── interprocess_tester.hpp │ ├── managed_global_memory.hpp │ ├── managed_memory_impl.hpp │ ├── managed_open_or_create_impl.hpp │ ├── math_functions.hpp │ ├── min_max.hpp │ ├── move.hpp │ ├── mpl.hpp │ ├── named_proxy.hpp │ ├── nothrow.hpp │ ├── os_file_functions.hpp │ ├── os_thread_functions.hpp │ ├── pointer_type.hpp │ ├── portable_intermodule_singleton.hpp │ ├── robust_emulation.hpp │ ├── segment_manager_helper.hpp │ ├── shared_dir_helpers.hpp │ ├── simple_swap.hpp │ ├── std_fwd.hpp │ ├── timed_utils.hpp │ ├── transform_iterator.hpp │ ├── type_traits.hpp │ ├── utilities.hpp │ ├── variadic_templates_tools.hpp │ ├── win32_api.hpp │ ├── windows_intermodule_singleton.hpp │ ├── workaround.hpp │ └── xsi_shared_memory_file_wrapper.hpp │ ├── errors.hpp │ ├── exceptions.hpp │ ├── file_mapping.hpp │ ├── indexes │ ├── flat_map_index.hpp │ ├── iset_index.hpp │ ├── iunordered_set_index.hpp │ ├── map_index.hpp │ └── null_index.hpp │ ├── interprocess_fwd.hpp │ ├── interprocess_printers.hpp │ ├── ipc │ └── message_queue.hpp │ ├── managed_external_buffer.hpp │ ├── managed_heap_memory.hpp │ ├── managed_mapped_file.hpp │ ├── managed_shared_memory.hpp │ ├── managed_windows_shared_memory.hpp │ ├── managed_xsi_shared_memory.hpp │ ├── mapped_region.hpp │ ├── mem_algo │ ├── detail │ │ ├── mem_algo_common.hpp │ │ └── simple_seq_fit_impl.hpp │ ├── rbtree_best_fit.hpp │ └── simple_seq_fit.hpp │ ├── offset_ptr.hpp │ ├── permissions.hpp │ ├── segment_manager.hpp │ ├── shared_memory_object.hpp │ ├── smart_ptr │ ├── deleter.hpp │ ├── detail │ │ ├── bad_weak_ptr.hpp │ │ ├── shared_count.hpp │ │ ├── sp_counted_base.hpp │ │ ├── sp_counted_base_atomic.hpp │ │ └── sp_counted_impl.hpp │ ├── enable_shared_from_this.hpp │ ├── intrusive_ptr.hpp │ ├── scoped_ptr.hpp │ ├── shared_ptr.hpp │ ├── unique_ptr.hpp │ └── weak_ptr.hpp │ ├── streams │ ├── bufferstream.hpp │ └── vectorstream.hpp │ ├── sync │ ├── cv_status.hpp │ ├── detail │ │ ├── common_algorithms.hpp │ │ ├── condition_algorithm_8a.hpp │ │ ├── condition_any_algorithm.hpp │ │ └── locks.hpp │ ├── file_lock.hpp │ ├── interprocess_condition.hpp │ ├── interprocess_condition_any.hpp │ ├── interprocess_mutex.hpp │ ├── interprocess_recursive_mutex.hpp │ ├── interprocess_semaphore.hpp │ ├── interprocess_sharable_mutex.hpp │ ├── interprocess_upgradable_mutex.hpp │ ├── lock_options.hpp │ ├── mutex_family.hpp │ ├── named_condition.hpp │ ├── named_condition_any.hpp │ ├── named_mutex.hpp │ ├── named_recursive_mutex.hpp │ ├── named_semaphore.hpp │ ├── named_sharable_mutex.hpp │ ├── named_upgradable_mutex.hpp │ ├── null_mutex.hpp │ ├── posix │ │ ├── condition.hpp │ │ ├── mutex.hpp │ │ ├── named_mutex.hpp │ │ ├── named_semaphore.hpp │ │ ├── pthread_helpers.hpp │ │ ├── recursive_mutex.hpp │ │ ├── semaphore.hpp │ │ ├── semaphore_wrapper.hpp │ │ └── timepoint_to_timespec.hpp │ ├── scoped_lock.hpp │ ├── sharable_lock.hpp │ ├── shm │ │ ├── named_condition.hpp │ │ ├── named_condition_any.hpp │ │ ├── named_creation_functor.hpp │ │ ├── named_mutex.hpp │ │ ├── named_recursive_mutex.hpp │ │ ├── named_semaphore.hpp │ │ └── named_upgradable_mutex.hpp │ ├── spin │ │ ├── condition.hpp │ │ ├── interprocess_barrier.hpp │ │ ├── mutex.hpp │ │ ├── recursive_mutex.hpp │ │ ├── semaphore.hpp │ │ └── wait.hpp │ ├── upgradable_lock.hpp │ └── windows │ │ ├── condition.hpp │ │ ├── mutex.hpp │ │ ├── named_condition.hpp │ │ ├── named_condition_any.hpp │ │ ├── named_mutex.hpp │ │ ├── named_recursive_mutex.hpp │ │ ├── named_semaphore.hpp │ │ ├── named_sync.hpp │ │ ├── recursive_mutex.hpp │ │ ├── semaphore.hpp │ │ ├── sync_utils.hpp │ │ ├── winapi_mutex_wrapper.hpp │ │ ├── winapi_semaphore_wrapper.hpp │ │ └── winapi_wrapper_common.hpp │ ├── timed_utils.hpp │ ├── windows_shared_memory.hpp │ ├── xsi_key.hpp │ └── xsi_shared_memory.hpp ├── index.html ├── meta └── libraries.json └── test ├── Jamfile.v2 ├── adaptive_node_pool_test.cpp ├── adaptive_pool_test.cpp ├── allocator_v1.hpp ├── allocexcept_test.cpp ├── anonymous_shared_memory_test.cpp ├── boost_interprocess_check.hpp ├── boost_use_windows_h.cpp ├── bufferstream_test.cpp ├── cached_adaptive_pool_test.cpp ├── cached_node_allocator_test.cpp ├── check_equal_containers.hpp ├── condition_any_test.cpp ├── condition_test.cpp ├── condition_test_template.hpp ├── data_test.cpp ├── deque_test.cpp ├── dummy_test_allocator.hpp ├── emplace_test.hpp ├── enable_shared_from_this_test.cpp ├── expand_bwd_test_allocator.hpp ├── expand_bwd_test_template.hpp ├── file_lock_test.cpp ├── file_mapping_test.cpp ├── flat_map_index_allocation_test.cpp ├── flat_tree_test.cpp ├── get_process_id_name.hpp ├── heap_allocator_v1.hpp ├── include_but_no_use_windows_h.cpp ├── intermodule_singleton_test.cpp ├── intrusive_ptr_test.cpp ├── iset_index_allocation_test.cpp ├── iunordered_set_index_allocation_test.cpp ├── list_test.cpp ├── list_test.hpp ├── managed_force_native_emulation_test.cpp ├── managed_mapped_file_test.cpp ├── managed_shared_memory_test.cpp ├── managed_windows_shared_memory_test.cpp ├── managed_xsi_shared_memory_test.cpp ├── map_index_allocation_test.cpp ├── map_test.hpp ├── mapped_file_test.cpp ├── memory_algorithm_test.cpp ├── memory_algorithm_test_template.hpp ├── message_queue_test.cpp ├── movable_int.hpp ├── mp_managed_shared_memory_test.cpp ├── mutex_owner_dead_test.cpp ├── mutex_test.cpp ├── mutex_test_template.hpp ├── mutex_timeout_test.cpp ├── named_allocation_test_template.hpp ├── named_condition_any_test.cpp ├── named_condition_test.cpp ├── named_condition_test_helpers.hpp ├── named_construct_test.cpp ├── named_creation_template.hpp ├── named_mutex_test.cpp ├── named_mutex_test_helpers.hpp ├── named_recursive_mutex_test.cpp ├── named_semaphore_test.cpp ├── named_semaphore_test_helpers.hpp ├── named_sharable_mutex_test.cpp ├── named_upgradable_mutex_test.cpp ├── node_allocator_test.cpp ├── node_pool_test.cpp ├── node_pool_test.hpp ├── null_index_test.cpp ├── offset_ptr_test.cpp ├── print_container.hpp ├── private_adaptive_pool_test.cpp ├── private_node_allocator_test.cpp ├── recursive_mutex_test.cpp ├── robust_emulation_test.cpp ├── robust_mutex_test.hpp ├── robust_recursive_emulation_test.cpp ├── segment_manager_test.cpp ├── segment_manager_test.hpp ├── segment_manager_v1_test.cpp ├── semaphore_test.cpp ├── semaphore_test_template.hpp ├── set_test.hpp ├── sharable_mutex_test.cpp ├── sharable_mutex_test_template.hpp ├── shared_memory_mapping_test.cpp ├── shared_memory_test.cpp ├── shared_ptr_test.cpp ├── shm_named_condition_test.cpp ├── shm_named_mutex_test.cpp ├── shm_named_recursive_mutex_test.cpp ├── shm_named_semaphore_test.cpp ├── slist_test.cpp ├── spin_condition_test.cpp ├── spin_mutex_test.cpp ├── spin_recursive_mutex_test.cpp ├── spin_semaphore_test.cpp ├── stable_vector_test.cpp ├── string_test.cpp ├── tree_test.cpp ├── unique_ptr_test.cpp ├── unordered_test.cpp ├── upgradable_mutex_test.cpp ├── user_buffer_test.cpp ├── util.hpp ├── vector_test.cpp ├── vector_test.hpp ├── vectorstream_test.cpp ├── winapi_condition_test.cpp ├── winapi_mutex_test.cpp ├── winapi_named_condition_test.cpp ├── winapi_named_mutex_test.cpp ├── winapi_named_recursive_mutex_test.cpp ├── winapi_named_semaphore_test.cpp ├── winapi_recursive_mutex_test.cpp ├── winapi_semaphore_test.cpp ├── windows_eventlog_shared_memory_test.cpp ├── windows_shared_dir_func.cpp ├── windows_shared_dir_path.cpp ├── windows_shared_memory_mapping_test.cpp ├── windows_shared_memory_test.cpp └── xsi_shared_memory_mapping_test.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # This .gitignore file was automatically created by Microsoft(R) Visual Studio. 3 | ################################################################################ 4 | 5 | /test/test_intermod_holder.cpp.wrk 6 | /test/test_intermod_holder.hpp.wrk 7 | /test/intermod_holder_dll.hpp 8 | /test/test_intermod_holder_main.cpp.wrk 9 | /proj/vs 10 | /doc/autodoc.xml 11 | /doc/html 12 | /Bin 13 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Generated by `boostdep --cmake interprocess` 2 | # Copyright 2020 Peter Dimov 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # https://www.boost.org/LICENSE_1_0.txt 5 | 6 | cmake_minimum_required(VERSION 3.5...3.16) 7 | 8 | project(boost_interprocess VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) 9 | 10 | add_library(boost_interprocess INTERFACE) 11 | add_library(Boost::interprocess ALIAS boost_interprocess) 12 | 13 | target_include_directories(boost_interprocess INTERFACE include) 14 | 15 | target_link_libraries(boost_interprocess 16 | INTERFACE 17 | Boost::assert 18 | Boost::config 19 | Boost::container 20 | Boost::intrusive 21 | Boost::move 22 | Boost::winapi 23 | ) 24 | 25 | if(CMAKE_VERSION VERSION_GREATER 3.18 AND CMAKE_GENERATOR MATCHES "Visual Studio") 26 | 27 | file(GLOB_RECURSE boost_interprocess_IDEFILES CONFIGURE_DEPENDS include/*.hpp) 28 | source_group(TREE ${PROJECT_SOURCE_DIR}/include FILES ${boost_interprocess_IDEFILES} PREFIX "Header Files") 29 | list(APPEND boost_interprocess_IDEFILES extra/boost_interprocess.natvis) 30 | target_sources(boost_interprocess PRIVATE ${boost_interprocess_IDEFILES}) 31 | 32 | endif() 33 | 34 | if (CMAKE_SYSTEM_NAME STREQUAL "Linux") 35 | target_link_libraries(boost_interprocess INTERFACE rt) 36 | elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows") 37 | target_link_libraries(boost_interprocess INTERFACE ole32 oleaut32 psapi advapi32) 38 | endif() 39 | 40 | if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") 41 | 42 | add_subdirectory(test) 43 | 44 | endif() 45 | 46 | -------------------------------------------------------------------------------- /build.jam: -------------------------------------------------------------------------------- 1 | # Copyright René Ferdinand Rivera Morell 2023-2024 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | require-b2 5.2 ; 7 | 8 | constant boost_dependencies : 9 | /boost/assert//boost_assert 10 | /boost/config//boost_config 11 | /boost/container//boost_container 12 | /boost/intrusive//boost_intrusive 13 | /boost/move//boost_move 14 | /boost/winapi//boost_winapi ; 15 | 16 | project /boost/interprocess 17 | : common-requirements 18 | include 19 | ; 20 | 21 | explicit 22 | [ alias boost_interprocess : : : : $(boost_dependencies) ] 23 | [ alias all : boost_interprocess example test ] 24 | ; 25 | 26 | call-if : boost-library interprocess 27 | ; 28 | 29 | -------------------------------------------------------------------------------- /doc/index.idx: -------------------------------------------------------------------------------- 1 | !scan-path "boost/interprocess" ".*.hpp" false 2 | !scan-path "boost/interprocess/allocators" ".*.hpp" false 3 | !scan-path "boost/interprocess/containers" ".*.hpp" false 4 | !scan-path "boost/interprocess/indexes" ".*.hpp" false 5 | !scan-path "boost/interprocess/ipc" ".*.hpp" false 6 | !scan-path "boost/interprocess/mem_algo" ".*.hpp" false 7 | !scan-path "boost/interprocess/smart_ptr" ".*.hpp" false 8 | !scan-path "boost/interprocess/streams" ".*.hpp" false 9 | !scan-path "boost/interprocess/sync" ".*.hpp" false 10 | -------------------------------------------------------------------------------- /example/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # Boost Interprocess Library Example Jamfile 2 | 3 | # (C) Copyright Ion Gaztanaga 2006-2012. 4 | # Use, modification and distribution are subject to the 5 | # Boost Software License, Version 1.0. (See accompanying file 6 | # LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | # Adapted from John Maddock's TR1 Jamfile.v2 9 | # Copyright John Maddock 2005. 10 | # Use, modification and distribution are subject to the 11 | # Boost Software License, Version 1.0. (See accompanying file 12 | # LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 13 | 14 | import testing ; 15 | 16 | # this rule enumerates through all the sources and invokes 17 | # the run rule for each source, the result is a list of all 18 | # the run rules, which we can pass on to the test_suite rule: 19 | 20 | project : requirements 21 | /boost/interprocess//boost_interprocess 22 | acc:-lrt 23 | acc-pa_risc:-lrt 24 | gcc,windows:"-lole32 -loleaut32 -lpsapi -ladvapi32" 25 | hpux,gcc:"-Wl,+as,mpas" 26 | windows,clang:"-lole32 -loleaut32 -lpsapi -ladvapi32" 27 | linux:"-lrt" 28 | #cygwin with -std=c++XX does not include POSIX 29 | cygwin:XOPEN_SOURCE=600 30 | /boost/multi_index//boost_multi_index 31 | /boost/unordered//boost_unordered 32 | ; 33 | 34 | rule test_all 35 | { 36 | local all_rules = ; 37 | 38 | for local fileb in [ glob comp*.cpp ] 39 | { 40 | all_rules += [ link $(fileb) ] ; 41 | } 42 | 43 | for local fileb in [ glob doc_*.cpp ] 44 | { 45 | all_rules += [ run $(fileb) ] ; 46 | } 47 | 48 | return $(all_rules) ; 49 | } 50 | 51 | test-suite interprocess_example : [ test_all r ] : multi ; 52 | -------------------------------------------------------------------------------- /example/comp_doc_anonymous_conditionB.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | //[doc_anonymous_conditionB 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "doc_anonymous_condition_shared_data.hpp" 18 | //<- 19 | #include "../test/get_process_id_name.hpp" 20 | //-> 21 | 22 | using namespace boost::interprocess; 23 | 24 | int main () 25 | { 26 | //Create a shared memory object. 27 | shared_memory_object shm 28 | (open_only //only create 29 | , test::get_process_id_name() //name 30 | ,read_write //read-write mode 31 | ); 32 | 33 | BOOST_INTERPROCESS_TRY{ 34 | //Map the whole shared memory in this process 35 | mapped_region region 36 | (shm //What to map 37 | ,read_write //Map it as read-write 38 | ); 39 | 40 | //Get the address of the mapped region 41 | void * addr = region.get_address(); 42 | 43 | //Obtain a pointer to the shared structure 44 | trace_queue * data = static_cast(addr); 45 | 46 | //Print messages until the other process marks the end 47 | bool end_loop = false; 48 | do{ 49 | scoped_lock lock(data->mutex); 50 | if(!data->message_in){ 51 | data->cond_empty.wait(lock); 52 | } 53 | if(std::strcmp(data->items, "last message") == 0){ 54 | end_loop = true; 55 | } 56 | else{ 57 | //Print the message 58 | std::cout << data->items << std::endl; 59 | //Notify the other process that the buffer is empty 60 | data->message_in = false; 61 | data->cond_full.notify_one(); 62 | } 63 | } 64 | while(!end_loop); 65 | } 66 | BOOST_INTERPROCESS_CATCH(interprocess_exception &ex){ 67 | std::cout << ex.what() << std::endl; 68 | return 1; 69 | } BOOST_INTERPROCESS_CATCH_END 70 | 71 | return 0; 72 | } 73 | //] 74 | 75 | -------------------------------------------------------------------------------- /example/comp_doc_anonymous_mutexB.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | //[doc_anonymous_mutexB 12 | #include 13 | #include 14 | #include 15 | #include "doc_anonymous_mutex_shared_data.hpp" 16 | #include 17 | #include 18 | //<- 19 | #include "../test/get_process_id_name.hpp" 20 | //-> 21 | 22 | using namespace boost::interprocess; 23 | 24 | int main () 25 | { 26 | //Remove shared memory on destruction 27 | struct shm_remove 28 | { 29 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } 30 | } remover; 31 | //<- 32 | (void)remover; 33 | //-> 34 | 35 | //Open the shared memory object. 36 | shared_memory_object shm 37 | (open_only //only create 38 | , test::get_process_id_name() //name 39 | , read_write //read-write mode 40 | ); 41 | 42 | //Map the whole shared memory in this process 43 | mapped_region region 44 | (shm //What to map 45 | ,read_write //Map it as read-write 46 | ); 47 | 48 | //Get the address of the mapped region 49 | void * addr = region.get_address(); 50 | 51 | //Construct the shared structure in memory 52 | shared_memory_log * data = static_cast(addr); 53 | 54 | //Write some logs 55 | for(int i = 0; i < 100; ++i){ 56 | //Lock the mutex 57 | scoped_lock lock(data->mutex); 58 | std::sprintf(data->items[(data->current_line++) % shared_memory_log::NumItems] 59 | ,"%s_%d", "process_a", i); 60 | if(i == (shared_memory_log::NumItems-1)) 61 | data->end_b = true; 62 | //Mutex is released here 63 | } 64 | 65 | //Wait until the other process ends 66 | while(1){ 67 | scoped_lock lock(data->mutex); 68 | if(data->end_a) 69 | break; 70 | } 71 | return 0; 72 | } 73 | //] 74 | 75 | -------------------------------------------------------------------------------- /example/comp_doc_anonymous_semaphoreA.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | //[doc_anonymous_semaphoreA 12 | #include 13 | #include 14 | #include 15 | #include "doc_anonymous_semaphore_shared_data.hpp" 16 | //<- 17 | #include "../test/get_process_id_name.hpp" 18 | //-> 19 | 20 | using namespace boost::interprocess; 21 | 22 | int main () 23 | { 24 | //Remove shared memory on construction and destruction 25 | struct shm_remove 26 | { 27 | shm_remove() { shared_memory_object::remove(test::get_process_id_name()); } 28 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } 29 | } remover; 30 | //<- 31 | (void)remover; 32 | //-> 33 | 34 | //Create a shared memory object. 35 | shared_memory_object shm 36 | ( create_only //only create 37 | , test::get_process_id_name() //name 38 | , read_write //read-write mode 39 | ); 40 | 41 | //Set size 42 | shm.truncate(sizeof(shared_memory_buffer)); 43 | 44 | //Map the whole shared memory in this process 45 | mapped_region region 46 | (shm //What to map 47 | ,read_write //Map it as read-write 48 | ); 49 | 50 | //Get the address of the mapped region 51 | void * addr = region.get_address(); 52 | 53 | //Construct the shared structure in memory 54 | shared_memory_buffer * data = new (addr) shared_memory_buffer; 55 | 56 | const int NumMsg = 100; 57 | 58 | //Insert data in the array 59 | for(int i = 0; i < NumMsg; ++i){ 60 | data->nempty.wait(); 61 | data->mutex.wait(); 62 | data->items[i % shared_memory_buffer::NumItems] = i; 63 | data->mutex.post(); 64 | data->nstored.post(); 65 | } 66 | 67 | return 0; 68 | } 69 | //] 70 | 71 | -------------------------------------------------------------------------------- /example/comp_doc_anonymous_semaphoreB.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | //[doc_anonymous_semaphoreB 12 | #include 13 | #include 14 | #include 15 | #include "doc_anonymous_semaphore_shared_data.hpp" 16 | //<- 17 | #include "../test/get_process_id_name.hpp" 18 | //-> 19 | 20 | 21 | using namespace boost::interprocess; 22 | 23 | int main () 24 | { 25 | //Remove shared memory on destruction 26 | struct shm_remove 27 | { 28 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } 29 | } remover; 30 | //<- 31 | (void)remover; 32 | //-> 33 | 34 | //Create a shared memory object. 35 | shared_memory_object shm 36 | ( open_only //only open 37 | , test::get_process_id_name() //name 38 | , read_write //read-write mode 39 | ); 40 | 41 | //Map the whole shared memory in this process 42 | mapped_region region 43 | (shm //What to map 44 | ,read_write //Map it as read-write 45 | ); 46 | 47 | //Get the address of the mapped region 48 | void * addr = region.get_address(); 49 | 50 | //Obtain the shared structure 51 | shared_memory_buffer * data = static_cast(addr); 52 | 53 | const int NumMsg = 100; 54 | 55 | int extracted_data [NumMsg]; 56 | //<- 57 | (void)extracted_data; 58 | //-> 59 | 60 | //Extract the data 61 | for(int i = 0; i < NumMsg; ++i){ 62 | data->nstored.wait(); 63 | data->mutex.wait(); 64 | extracted_data[i] = data->items[i % shared_memory_buffer::NumItems]; 65 | data->mutex.post(); 66 | data->nempty.post(); 67 | } 68 | return 0; 69 | } 70 | //] 71 | 72 | -------------------------------------------------------------------------------- /example/comp_doc_anonymous_upgradable_mutexA.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | //[doc_anonymous_upgradable_mutexA 12 | #include 13 | #include 14 | #include 15 | #include "doc_upgradable_mutex_shared_data.hpp" 16 | #include 17 | #include 18 | //<- 19 | #include "../test/get_process_id_name.hpp" 20 | //-> 21 | 22 | using namespace boost::interprocess; 23 | 24 | int main () 25 | { 26 | //Remove shared memory on destruction 27 | struct shm_remove 28 | { 29 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } 30 | } remover; 31 | //<- 32 | (void)remover; 33 | //-> 34 | 35 | //Create a shared memory object. 36 | shared_memory_object shm 37 | ( create_only //only create 38 | , test::get_process_id_name() //name 39 | , read_write //read-write mode 40 | ); 41 | 42 | //Set size 43 | shm.truncate(sizeof(shared_data)); 44 | 45 | //Map the whole shared memory in this process 46 | mapped_region region 47 | (shm //What to map 48 | ,read_write //Map it as read-write 49 | ); 50 | 51 | //Get the address of the mapped region 52 | void * addr = region.get_address(); 53 | 54 | //Construct the shared structure in memory 55 | shared_data * data = new (addr) shared_data; 56 | 57 | //Write some logs 58 | for(int i = 0; i < shared_data::NumItems; ++i){ 59 | //Lock the upgradable_mutex 60 | scoped_lock lock(data->upgradable_mutex); 61 | std::sprintf(data->items[(data->current_line++) % shared_data::NumItems] 62 | ,"%s_%d", "process_a", i); 63 | if(i == (shared_data::NumItems-1)) 64 | data->end_a = true; 65 | //Mutex is released here 66 | } 67 | 68 | //Wait until the other process ends 69 | while(1){ 70 | scoped_lock lock(data->upgradable_mutex); 71 | if(data->end_b) 72 | break; 73 | } 74 | 75 | return 0; 76 | } 77 | //] 78 | 79 | -------------------------------------------------------------------------------- /example/comp_doc_anonymous_upgradable_mutexB.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | 12 | //[doc_anonymous_upgradable_mutexB 13 | #include 14 | #include 15 | #include 16 | #include "doc_upgradable_mutex_shared_data.hpp" 17 | #include 18 | #include 19 | //<- 20 | #include "../test/get_process_id_name.hpp" 21 | //-> 22 | 23 | using namespace boost::interprocess; 24 | 25 | int main () 26 | { 27 | //Remove shared memory on destruction 28 | struct shm_remove 29 | { 30 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name() 31 | ); } 32 | } remover; 33 | //<- 34 | (void)remover; 35 | //-> 36 | 37 | //Open the shared memory object. 38 | shared_memory_object shm 39 | ( open_only //only create 40 | , test::get_process_id_name() //name 41 | , read_write //read-write mode 42 | ); 43 | 44 | //Map the whole shared memory in this process 45 | mapped_region region 46 | ( shm //What to map 47 | , read_write //Map it as read-write 48 | ); 49 | 50 | //Get the address of the mapped region 51 | void * addr = region.get_address(); 52 | 53 | //Construct the shared structure in memory 54 | shared_data * data = static_cast(addr); 55 | 56 | //Write some logs 57 | for(int i = 0; i < 100; ++i){ 58 | //Lock the upgradable_mutex 59 | scoped_lock lock(data->upgradable_mutex); 60 | std::sprintf(data->items[(data->current_line++) % shared_data::NumItems] 61 | ,"%s_%d", "process_a", i); 62 | if(i == (shared_data::NumItems-1)) 63 | data->end_b = true; 64 | //Mutex is released here 65 | } 66 | 67 | //Wait until the other process ends 68 | while(1){ 69 | scoped_lock lock(data->upgradable_mutex); 70 | if(data->end_a) 71 | break; 72 | } 73 | return 0; 74 | } 75 | //] 76 | 77 | 78 | -------------------------------------------------------------------------------- /example/comp_doc_message_queueA.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | //[doc_message_queueA 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace boost::interprocess; 17 | 18 | int main () 19 | { 20 | BOOST_INTERPROCESS_TRY{ 21 | //Erase previous message queue 22 | message_queue::remove("message_queue"); 23 | 24 | //Create a message_queue. 25 | message_queue mq 26 | (create_only //only create 27 | ,"message_queue" //name 28 | ,100 //max message number 29 | ,sizeof(int) //max message size 30 | ); 31 | 32 | //Send 100 numbers 33 | for(int i = 0; i < 100; ++i){ 34 | mq.send(&i, sizeof(i), 0); 35 | } 36 | } 37 | BOOST_INTERPROCESS_CATCH(interprocess_exception &ex){ 38 | std::cout << ex.what() << std::endl; 39 | return 1; 40 | } BOOST_INTERPROCESS_CATCH_END 41 | 42 | return 0; 43 | } 44 | //] 45 | 46 | -------------------------------------------------------------------------------- /example/comp_doc_message_queueB.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | //[doc_message_queueB 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace boost::interprocess; 17 | 18 | int main () 19 | { 20 | BOOST_INTERPROCESS_TRY{ 21 | //Open a message queue. 22 | message_queue mq 23 | (open_only //only open 24 | ,"message_queue" //name 25 | ); 26 | 27 | unsigned int priority; 28 | message_queue::size_type recvd_size; 29 | 30 | //Receive 100 numbers 31 | for(int i = 0; i < 100; ++i){ 32 | int number; 33 | mq.receive(&number, sizeof(number), recvd_size, priority); 34 | if(number != i || recvd_size != sizeof(number)) 35 | return 1; 36 | } 37 | } 38 | BOOST_INTERPROCESS_CATCH(interprocess_exception &ex){ 39 | message_queue::remove("message_queue"); 40 | std::cout << ex.what() << std::endl; 41 | return 1; 42 | } BOOST_INTERPROCESS_CATCH_END 43 | message_queue::remove("message_queue"); 44 | return 0; 45 | } 46 | //] 47 | 48 | -------------------------------------------------------------------------------- /example/doc_adaptive_pool.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | //[doc_adaptive_pool 13 | #include 14 | #include 15 | #include 16 | //<- 17 | #include "../test/get_process_id_name.hpp" 18 | //-> 19 | 20 | using namespace boost::interprocess; 21 | 22 | int main () 23 | { 24 | //Remove shared memory on construction and destruction 25 | struct shm_remove 26 | { 27 | shm_remove() { shared_memory_object::remove(test::get_process_id_name()); } 28 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } 29 | } remover; 30 | //<- 31 | (void)remover; 32 | //-> 33 | 34 | //Create shared memory 35 | managed_shared_memory segment(create_only,test::get_process_id_name(), 65536); 36 | 37 | //Create a adaptive_pool that allocates ints from the managed segment 38 | //The number of chunks per segment is the default value 39 | typedef adaptive_pool 40 | adaptive_pool_t; 41 | adaptive_pool_t allocator_instance(segment.get_segment_manager()); 42 | 43 | //Create another adaptive_pool. Since the segment manager address 44 | //is the same, this adaptive_pool will be 45 | //attached to the same pool so "allocator_instance2" can deallocate 46 | //nodes allocated by "allocator_instance" 47 | adaptive_pool_t allocator_instance2(segment.get_segment_manager()); 48 | 49 | //Create another adaptive_pool using copy-constructor. This 50 | //adaptive_pool will also be attached to the same pool 51 | adaptive_pool_t allocator_instance3(allocator_instance2); 52 | 53 | //All allocators are equal 54 | assert(allocator_instance == allocator_instance2); 55 | assert(allocator_instance2 == allocator_instance3); 56 | 57 | //So memory allocated with one can be deallocated with another 58 | allocator_instance2.deallocate(allocator_instance.allocate(1), 1); 59 | allocator_instance3.deallocate(allocator_instance2.allocate(1), 1); 60 | 61 | //The common pool will be destroyed here, since no allocator is 62 | //attached to the pool 63 | return 0; 64 | } 65 | //] 66 | 67 | -------------------------------------------------------------------------------- /example/doc_allocator.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | //[doc_allocator 13 | #include 14 | #include 15 | #include 16 | //<- 17 | #include "../test/get_process_id_name.hpp" 18 | //-> 19 | 20 | using namespace boost::interprocess; 21 | 22 | int main () 23 | { 24 | //Remove shared memory on construction and destruction 25 | struct shm_remove 26 | { 27 | shm_remove() { shared_memory_object::remove(test::get_process_id_name()); } 28 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } 29 | } remover; 30 | //<- 31 | (void)remover; 32 | //-> 33 | 34 | //Create shared memory 35 | managed_shared_memory segment(create_only,test::get_process_id_name(), 65536); 36 | 37 | //Create an allocator that allocates ints from the managed segment 38 | allocator 39 | allocator_instance(segment.get_segment_manager()); 40 | 41 | //Copy constructed allocator is equal 42 | allocator 43 | allocator_instance2(allocator_instance); 44 | assert(allocator_instance2 == allocator_instance); 45 | 46 | //Allocate and deallocate memory for 100 ints 47 | allocator_instance2.deallocate(allocator_instance.allocate(100), 100); 48 | 49 | return 0; 50 | } 51 | //] 52 | 53 | -------------------------------------------------------------------------------- /example/doc_anonymous_condition_shared_data.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #include 11 | //[doc_anonymous_condition_shared_data 12 | #include 13 | #include 14 | 15 | struct trace_queue 16 | { 17 | enum { LineSize = 100 }; 18 | 19 | trace_queue() 20 | : message_in(false) 21 | {} 22 | 23 | //Mutex to protect access to the queue 24 | boost::interprocess::interprocess_mutex mutex; 25 | 26 | //Condition to wait when the queue is empty 27 | boost::interprocess::interprocess_condition cond_empty; 28 | 29 | //Condition to wait when the queue is full 30 | boost::interprocess::interprocess_condition cond_full; 31 | 32 | //Items to fill 33 | char items[LineSize]; 34 | 35 | //Is there any message 36 | bool message_in; 37 | }; 38 | //] 39 | #include 40 | -------------------------------------------------------------------------------- /example/doc_anonymous_mutex_shared_data.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #include 11 | //[doc_anonymous_mutex_shared_data 12 | #include 13 | 14 | struct shared_memory_log 15 | { 16 | enum { NumItems = 100 }; 17 | enum { LineSize = 100 }; 18 | 19 | shared_memory_log() 20 | : current_line(0) 21 | , end_a(false) 22 | , end_b(false) 23 | {} 24 | 25 | //Mutex to protect access to the queue 26 | boost::interprocess::interprocess_mutex mutex; 27 | 28 | //Items to fill 29 | char items[NumItems][LineSize]; 30 | int current_line; 31 | bool end_a; 32 | bool end_b; 33 | }; 34 | //] 35 | #include 36 | -------------------------------------------------------------------------------- /example/doc_anonymous_semaphore_shared_data.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | //[doc_anonymous_semaphore_shared_data 11 | #include 12 | 13 | struct shared_memory_buffer 14 | { 15 | enum { NumItems = 10 }; 16 | 17 | shared_memory_buffer() 18 | : mutex(1), nempty(NumItems), nstored(0) 19 | {} 20 | 21 | //Semaphores to protect and synchronize access 22 | boost::interprocess::interprocess_semaphore 23 | mutex, nempty, nstored; 24 | 25 | //Items to fill 26 | int items[NumItems]; 27 | }; 28 | //] 29 | -------------------------------------------------------------------------------- /example/doc_anonymous_shared_memory.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | //[doc_anonymous_shared_memory 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | int main () 18 | { 19 | using namespace boost::interprocess; 20 | BOOST_INTERPROCESS_TRY{ 21 | //Create an anonymous shared memory segment with size 1000 22 | mapped_region region(anonymous_shared_memory(1000)); 23 | 24 | //Write all the memory to 1 25 | std::memset(region.get_address(), 1, region.get_size()); 26 | 27 | //The segment is unmapped when "region" goes out of scope 28 | } 29 | BOOST_INTERPROCESS_CATCH(interprocess_exception &ex){ 30 | std::cout << ex.what() << std::endl; 31 | return 1; 32 | } BOOST_INTERPROCESS_CATCH_END 33 | return 0; 34 | } 35 | //] 36 | 37 | -------------------------------------------------------------------------------- /example/doc_cont.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | //[doc_cont 13 | #include 14 | #include 15 | #include 16 | //<- 17 | #include "../test/get_process_id_name.hpp" 18 | //-> 19 | 20 | int main () 21 | { 22 | using namespace boost::interprocess; 23 | //Remove shared memory on construction and destruction 24 | struct shm_remove 25 | { 26 | shm_remove() { shared_memory_object::remove(test::get_process_id_name()); } 27 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } 28 | } remover; 29 | //<- 30 | (void)remover; 31 | //-> 32 | 33 | //A managed shared memory where we can construct objects 34 | //associated with a c-string 35 | managed_shared_memory segment(create_only,test::get_process_id_name(), 65536); 36 | 37 | //Alias an STL-like allocator of ints that allocates ints from the segment 38 | typedef allocator 39 | ShmemAllocator; 40 | 41 | //Alias a vector that uses the previous STL-like allocator 42 | typedef boost::container::vector MyVector; 43 | 44 | int initVal[] = {0, 1, 2, 3, 4, 5, 6 }; 45 | const int *begVal = initVal; 46 | const int *endVal = initVal + sizeof(initVal)/sizeof(initVal[0]); 47 | 48 | //Initialize the STL-like allocator 49 | const ShmemAllocator alloc_inst (segment.get_segment_manager()); 50 | 51 | //Construct the vector in the shared memory segment with the STL-like allocator 52 | //from a range of iterators 53 | MyVector *myvector = 54 | segment.construct 55 | ("MyVector")/*object name*/ 56 | (begVal /*first ctor parameter*/ 57 | ,endVal /*second ctor parameter*/ 58 | ,alloc_inst /*third ctor parameter*/); 59 | 60 | //Use vector as your want 61 | std::sort(myvector->rbegin(), myvector->rend()); 62 | // . . . 63 | //When done, destroy and delete vector from the segment 64 | segment.destroy("MyVector"); 65 | return 0; 66 | } 67 | //] 68 | 69 | -------------------------------------------------------------------------------- /example/doc_managed_aligned_allocation.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | //[doc_managed_aligned_allocation 11 | #include 12 | #include 13 | //<- 14 | #include "../test/get_process_id_name.hpp" 15 | //-> 16 | 17 | int main() 18 | { 19 | using namespace boost::interprocess; 20 | 21 | //Remove shared memory on construction and destruction 22 | struct shm_remove 23 | { 24 | shm_remove() { shared_memory_object::remove(test::get_process_id_name()); } 25 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } 26 | } remover; 27 | //<- 28 | (void)remover; 29 | //-> 30 | 31 | //Managed memory segment that allocates portions of a shared memory 32 | //segment with the default management algorithm 33 | managed_shared_memory managed_shm(create_only, test::get_process_id_name(), 65536); 34 | 35 | const std::size_t Alignment = 128; 36 | 37 | //Allocate 100 bytes aligned to Alignment from segment, throwing version 38 | void *ptr = managed_shm.allocate_aligned(100, Alignment); 39 | 40 | //Check alignment 41 | assert(std::size_t(static_cast(ptr)-static_cast(0)) % Alignment == 0); 42 | 43 | //Deallocate it 44 | managed_shm.deallocate(ptr); 45 | 46 | //Non throwing version 47 | ptr = managed_shm.allocate_aligned(100, Alignment, std::nothrow); 48 | 49 | //Check alignment 50 | assert(std::size_t(static_cast(ptr)-static_cast(0)) % Alignment == 0); 51 | 52 | //Deallocate it 53 | managed_shm.deallocate(ptr); 54 | 55 | //If we want to efficiently allocate aligned blocks of memory 56 | //use managed_shared_memory::PayloadPerAllocation value 57 | assert(Alignment > managed_shared_memory::PayloadPerAllocation); 58 | 59 | //This allocation will maximize the size of the aligned memory 60 | //and will increase the possibility of finding more aligned memory 61 | ptr = managed_shm.allocate_aligned 62 | (3u*Alignment - managed_shared_memory::PayloadPerAllocation, Alignment); 63 | 64 | //Check alignment 65 | assert(std::size_t(static_cast(ptr)-static_cast(0)) % Alignment == 0); 66 | 67 | //Deallocate it 68 | managed_shm.deallocate(ptr); 69 | 70 | return 0; 71 | } 72 | //] 73 | 74 | -------------------------------------------------------------------------------- /example/doc_managed_construction_info.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | //[doc_managed_construction_info 12 | #include 13 | #include 14 | #include 15 | //<- 16 | #include "../test/get_process_id_name.hpp" 17 | //-> 18 | 19 | class my_class 20 | { 21 | //... 22 | }; 23 | 24 | int main() 25 | { 26 | using namespace boost::interprocess; 27 | 28 | //Remove shared memory on construction and destruction 29 | struct shm_remove 30 | { 31 | shm_remove() { shared_memory_object::remove(test::get_process_id_name()); } 32 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } 33 | } remover; 34 | //<- 35 | (void)remover; 36 | //-> 37 | 38 | managed_shared_memory managed_shm(create_only, test::get_process_id_name(), 10000*sizeof(std::size_t)); 39 | 40 | //Construct objects 41 | my_class *named_object = managed_shm.construct("Object name")[1](); 42 | my_class *unique_object = managed_shm.construct(unique_instance)[2](); 43 | my_class *anon_object = managed_shm.construct(anonymous_instance)[3](); 44 | 45 | //Now test "get_instance_name" function. 46 | assert(0 == std::strcmp(managed_shared_memory::get_instance_name(named_object), "Object name")); 47 | assert(0 == std::strcmp(managed_shared_memory::get_instance_name(unique_object), typeid(my_class).name())); 48 | assert(0 == managed_shared_memory::get_instance_name(anon_object)); 49 | 50 | //Now test "get_instance_type" function. 51 | assert(named_type == managed_shared_memory::get_instance_type(named_object)); 52 | assert(unique_type == managed_shared_memory::get_instance_type(unique_object)); 53 | assert(anonymous_type == managed_shared_memory::get_instance_type(anon_object)); 54 | 55 | //Now test "get_instance_length" function. 56 | assert(1 == managed_shared_memory::get_instance_length(named_object)); 57 | assert(2 == managed_shared_memory::get_instance_length(unique_object)); 58 | assert(3 == managed_shared_memory::get_instance_length(anon_object)); 59 | 60 | managed_shm.destroy_ptr(named_object); 61 | managed_shm.destroy_ptr(unique_object); 62 | managed_shm.destroy_ptr(anon_object); 63 | return 0; 64 | } 65 | //] 66 | 67 | -------------------------------------------------------------------------------- /example/doc_managed_grow.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | //[doc_managed_grow 12 | #include 13 | #include 14 | #include 15 | //<- 16 | #include "../test/get_process_id_name.hpp" 17 | //-> 18 | 19 | class MyClass 20 | { 21 | //... 22 | }; 23 | 24 | int main() 25 | { 26 | using namespace boost::interprocess; 27 | //Remove shared memory on construction and destruction 28 | struct shm_remove 29 | { 30 | shm_remove() { shared_memory_object::remove(test::get_process_id_name()); } 31 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } 32 | } remover; 33 | //<- 34 | (void)remover; 35 | //-> 36 | 37 | { 38 | //Create a managed shared memory 39 | managed_shared_memory shm(create_only, test::get_process_id_name(), 1000); 40 | 41 | //Check size 42 | assert(shm.get_size() == 1000); 43 | //Construct a named object 44 | MyClass *myclass = shm.construct("MyClass")(); 45 | //The managed segment is unmapped here 46 | //<- 47 | (void)myclass; 48 | //-> 49 | } 50 | { 51 | //Now that the segment is not mapped grow it adding extra 500 bytes 52 | managed_shared_memory::grow(test::get_process_id_name(), 500); 53 | 54 | //Map it again 55 | managed_shared_memory shm(open_only, test::get_process_id_name()); 56 | 57 | //Check size 58 | assert(shm.get_size() == 1500); 59 | //Check "MyClass" is still there 60 | MyClass *myclass = shm.find("MyClass").first; 61 | assert(myclass != 0); 62 | //<- 63 | (void)myclass; 64 | //-> 65 | //The managed segment is unmapped here 66 | } 67 | { 68 | //Now minimize the size of the segment 69 | managed_shared_memory::shrink_to_fit(test::get_process_id_name()); 70 | 71 | //Map it again 72 | managed_shared_memory shm(open_only, test::get_process_id_name()); 73 | 74 | //Check size 75 | assert(shm.get_size() < 1000); 76 | //Check "MyClass" is still there 77 | MyClass *myclass = shm.find("MyClass").first; 78 | assert(myclass != 0); 79 | //The managed segment is unmapped here 80 | //<- 81 | (void)myclass; 82 | //-> 83 | } 84 | return 0; 85 | } 86 | //] 87 | 88 | -------------------------------------------------------------------------------- /example/doc_managed_heap_memory.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | //[doc_managed_heap_memory 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace boost::interprocess; 19 | typedef boost::container::list > 20 | MyList; 21 | 22 | int main () 23 | { 24 | //We will create a buffer of 1000 bytes to store a list 25 | managed_heap_memory heap_memory(1000); 26 | 27 | MyList * mylist = heap_memory.construct("MyList") 28 | (heap_memory.get_segment_manager()); 29 | 30 | //Obtain handle, that identifies the list in the buffer 31 | managed_heap_memory::handle_t list_handle = heap_memory.get_handle_from_address(mylist); 32 | 33 | //Fill list until there is no more memory in the buffer 34 | BOOST_INTERPROCESS_TRY{ 35 | while(1) { 36 | mylist->insert(mylist->begin(), 0); 37 | } 38 | } 39 | BOOST_INTERPROCESS_CATCH(const bad_alloc &){ 40 | //memory is full 41 | } BOOST_INTERPROCESS_CATCH_END 42 | //Let's obtain the size of the list 43 | MyList::size_type old_size = mylist->size(); 44 | //<- 45 | (void)old_size; 46 | //-> 47 | 48 | //To make the list bigger, let's increase the heap buffer 49 | //in 1000 bytes more. 50 | heap_memory.grow(1000); 51 | 52 | //If memory has been reallocated, the old pointer is invalid, so 53 | //use previously obtained handle to find the new pointer. 54 | mylist = static_cast 55 | (heap_memory.get_address_from_handle(list_handle)); 56 | 57 | //Fill list until there is no more memory in the buffer 58 | BOOST_INTERPROCESS_TRY{ 59 | while(1) { 60 | mylist->insert(mylist->begin(), 0); 61 | } 62 | } 63 | BOOST_INTERPROCESS_CATCH(const bad_alloc &){ 64 | //memory is full 65 | } BOOST_INTERPROCESS_CATCH_END 66 | 67 | //Let's obtain the new size of the list 68 | MyList::size_type new_size = mylist->size(); 69 | //<- 70 | (void)new_size; 71 | //-> 72 | 73 | assert(new_size > old_size); 74 | 75 | //Destroy list 76 | heap_memory.destroy_ptr(mylist); 77 | 78 | return 0; 79 | } 80 | //] 81 | 82 | -------------------------------------------------------------------------------- /example/doc_managed_raw_allocation.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | //[doc_managed_raw_allocation 12 | #include 13 | //<- 14 | #include "../test/get_process_id_name.hpp" 15 | //-> 16 | 17 | int main() 18 | { 19 | using namespace boost::interprocess; 20 | 21 | //Remove shared memory on construction and destruction 22 | struct shm_remove 23 | { 24 | shm_remove() { shared_memory_object::remove(test::get_process_id_name()); } 25 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } 26 | } remover; 27 | //<- 28 | (void)remover; 29 | //-> 30 | 31 | //Managed memory segment that allocates portions of a shared memory 32 | //segment with the default management algorithm 33 | managed_shared_memory managed_shm(create_only,test::get_process_id_name(), 65536); 34 | 35 | //Allocate 100 bytes of memory from segment, throwing version 36 | void *ptr = managed_shm.allocate(100); 37 | 38 | //Deallocate it 39 | managed_shm.deallocate(ptr); 40 | 41 | //Non throwing version 42 | ptr = managed_shm.allocate(100, std::nothrow); 43 | 44 | //Deallocate it 45 | managed_shm.deallocate(ptr); 46 | return 0; 47 | } 48 | //] 49 | 50 | -------------------------------------------------------------------------------- /example/doc_named_condition_shared_data.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #include 11 | #include 12 | 13 | struct trace_queue 14 | { 15 | enum { LineSize = 100 }; 16 | 17 | trace_queue() 18 | : message_in(false) 19 | {} 20 | 21 | //Mutex to protect access to the queue 22 | boost::interprocess::interprocess_mutex mutex; 23 | 24 | //Condition to wait when the queue is empty 25 | boost::interprocess::interprocess_condition cond_empty; 26 | 27 | //Condition to wait when the queue is full 28 | boost::interprocess::interprocess_condition cond_full; 29 | 30 | //Items to fill 31 | char items[LineSize]; 32 | 33 | //Is there any message 34 | bool message_in; 35 | }; 36 | -------------------------------------------------------------------------------- /example/doc_named_mutex.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | //[doc_named_mutex 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | //<- 19 | #include "../test/get_process_id_name.hpp" 20 | //-> 21 | 22 | int main () 23 | { 24 | using namespace boost::interprocess; 25 | BOOST_INTERPROCESS_TRY{ 26 | struct file_remove 27 | { 28 | file_remove() { std::remove(test::get_process_id_name()); } 29 | ~file_remove(){ std::remove(test::get_process_id_name()); } 30 | } file_remover; 31 | struct mutex_remove 32 | { 33 | mutex_remove() { named_mutex::remove(test::get_process_id_name()); } 34 | ~mutex_remove(){ named_mutex::remove(test::get_process_id_name()); } 35 | } remover; 36 | //<- 37 | (void)file_remover; 38 | (void)remover; 39 | //-> 40 | 41 | //Open or create the named mutex 42 | named_mutex mutex(open_or_create, test::get_process_id_name()); 43 | 44 | std::ofstream file(test::get_process_id_name()); 45 | 46 | for(int i = 0; i < 10; ++i){ 47 | 48 | //Do some operations... 49 | 50 | //Write to file atomically 51 | scoped_lock lock(mutex); 52 | file << "Process name, "; 53 | file << "This is iteration #" << i; 54 | file << std::endl; 55 | } 56 | } 57 | BOOST_INTERPROCESS_CATCH(interprocess_exception &ex){ 58 | std::cout << ex.what() << std::endl; 59 | return 1; 60 | } BOOST_INTERPROCESS_CATCH_END 61 | return 0; 62 | } 63 | //] 64 | 65 | -------------------------------------------------------------------------------- /example/doc_node_allocator.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | //[doc_node_allocator 13 | #include 14 | #include 15 | #include 16 | //<- 17 | #include "../test/get_process_id_name.hpp" 18 | //-> 19 | 20 | using namespace boost::interprocess; 21 | 22 | int main () 23 | { 24 | //Remove shared memory on construction and destruction 25 | struct shm_remove 26 | { 27 | shm_remove() { shared_memory_object::remove(test::get_process_id_name()); } 28 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } 29 | } remover; 30 | //<- 31 | (void)remover; 32 | //-> 33 | 34 | //Create shared memory 35 | managed_shared_memory segment(create_only, 36 | test::get_process_id_name(), //segment name 37 | 65536); 38 | 39 | //Create a node_allocator that allocates ints from the managed segment 40 | //The number of chunks per segment is the default value 41 | typedef node_allocator 42 | node_allocator_t; 43 | node_allocator_t allocator_instance(segment.get_segment_manager()); 44 | 45 | //Create another node_allocator. Since the segment manager address 46 | //is the same, this node_allocator will be 47 | //attached to the same pool so "allocator_instance2" can deallocate 48 | //nodes allocated by "allocator_instance" 49 | node_allocator_t allocator_instance2(segment.get_segment_manager()); 50 | 51 | //Create another node_allocator using copy-constructor. This 52 | //node_allocator will also be attached to the same pool 53 | node_allocator_t allocator_instance3(allocator_instance2); 54 | 55 | //All allocators are equal 56 | assert(allocator_instance == allocator_instance2); 57 | assert(allocator_instance2 == allocator_instance3); 58 | 59 | //So memory allocated with one can be deallocated with another 60 | allocator_instance2.deallocate(allocator_instance.allocate(1), 1); 61 | allocator_instance3.deallocate(allocator_instance2.allocate(1), 1); 62 | 63 | //The common pool will be destroyed here, since no allocator is 64 | //attached to the pool 65 | return 0; 66 | } 67 | //] 68 | 69 | -------------------------------------------------------------------------------- /example/doc_offset_ptr.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | //[doc_offset_ptr 13 | #include 14 | #include 15 | //<- 16 | #include "../test/get_process_id_name.hpp" 17 | //-> 18 | 19 | using namespace boost::interprocess; 20 | 21 | //Shared memory linked list node 22 | struct list_node 23 | { 24 | offset_ptr next; 25 | int value; 26 | }; 27 | 28 | int main () 29 | { 30 | //Remove shared memory on construction and destruction 31 | struct shm_remove 32 | { 33 | shm_remove() { shared_memory_object::remove(test::get_process_id_name()); } 34 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } 35 | } remover; 36 | //<- 37 | (void)remover; 38 | //-> 39 | 40 | //Create shared memory 41 | managed_shared_memory segment(create_only, 42 | test::get_process_id_name(), //segment name 43 | 65536); 44 | 45 | //Create linked list with 10 nodes in shared memory 46 | offset_ptr prev = 0, current, first; 47 | 48 | int i; 49 | for(i = 0; i < 10; ++i, prev = current){ 50 | current = static_cast(segment.allocate(sizeof(list_node))); 51 | current->value = i; 52 | current->next = 0; 53 | 54 | if(!prev) 55 | first = current; 56 | else 57 | prev->next = current; 58 | } 59 | 60 | //Communicate list to other processes 61 | //. . . 62 | //When done, destroy list 63 | for(current = first; current; /**/){ 64 | prev = current; 65 | current = current->next; 66 | segment.deallocate(prev.get()); 67 | } 68 | return 0; 69 | } 70 | //] 71 | 72 | -------------------------------------------------------------------------------- /example/doc_private_adaptive_pool.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | //[doc_private_adaptive_pool 13 | #include 14 | #include 15 | #include 16 | //<- 17 | #include "../test/get_process_id_name.hpp" 18 | //-> 19 | 20 | using namespace boost::interprocess; 21 | 22 | int main () 23 | { 24 | //Remove shared memory on construction and destruction 25 | struct shm_remove 26 | { 27 | shm_remove() { shared_memory_object::remove(test::get_process_id_name()); } 28 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } 29 | } remover; 30 | //<- 31 | (void)remover; 32 | //-> 33 | 34 | //Create shared memory 35 | managed_shared_memory segment(create_only, 36 | test::get_process_id_name(), //segment name 37 | 65536); 38 | 39 | //Create a private_adaptive_pool that allocates ints from the managed segment 40 | //The number of chunks per segment is the default value 41 | typedef private_adaptive_pool 42 | private_adaptive_pool_t; 43 | private_adaptive_pool_t allocator_instance(segment.get_segment_manager()); 44 | 45 | //Create another private_adaptive_pool. 46 | private_adaptive_pool_t allocator_instance2(segment.get_segment_manager()); 47 | 48 | //Although the segment manager address 49 | //is the same, this private_adaptive_pool will have its own pool so 50 | //"allocator_instance2" CAN'T deallocate nodes allocated by "allocator_instance". 51 | //"allocator_instance2" is NOT equal to "allocator_instance" 52 | assert(allocator_instance != allocator_instance2); 53 | 54 | //Create another adaptive_pool using copy-constructor. 55 | private_adaptive_pool_t allocator_instance3(allocator_instance2); 56 | 57 | //This allocator is also unequal to allocator_instance2 58 | assert(allocator_instance2 != allocator_instance3); 59 | 60 | //Pools are destroyed with the allocators 61 | return 0; 62 | } 63 | //] 64 | 65 | -------------------------------------------------------------------------------- /example/doc_private_node_allocator.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | //[doc_private_node_allocator 13 | #include 14 | #include 15 | #include 16 | //<- 17 | #include "../test/get_process_id_name.hpp" 18 | //-> 19 | 20 | using namespace boost::interprocess; 21 | 22 | int main () 23 | { 24 | //Remove shared memory on construction and destruction 25 | struct shm_remove 26 | { 27 | shm_remove() { shared_memory_object::remove(test::get_process_id_name()); } 28 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } 29 | } remover; 30 | //<- 31 | (void)remover; 32 | //-> 33 | 34 | //Create shared memory 35 | managed_shared_memory segment(create_only, 36 | test::get_process_id_name(), //segment name 37 | 65536); 38 | 39 | //Create a private_node_allocator that allocates ints from the managed segment 40 | //The number of chunks per segment is the default value 41 | typedef private_node_allocator 42 | private_node_allocator_t; 43 | private_node_allocator_t allocator_instance(segment.get_segment_manager()); 44 | 45 | //Create another private_node_allocator. 46 | private_node_allocator_t allocator_instance2(segment.get_segment_manager()); 47 | 48 | //Although the segment manager address 49 | //is the same, this private_node_allocator will have its own pool so 50 | //"allocator_instance2" CAN'T deallocate nodes allocated by "allocator_instance". 51 | //"allocator_instance2" is NOT equal to "allocator_instance" 52 | assert(allocator_instance != allocator_instance2); 53 | 54 | //Create another node_allocator using copy-constructor. 55 | private_node_allocator_t allocator_instance3(allocator_instance2); 56 | 57 | //This allocator is also unequal to allocator_instance2 58 | assert(allocator_instance2 != allocator_instance3); 59 | 60 | //Pools are destroyed with the allocators 61 | return 0; 62 | } 63 | //] 64 | 65 | -------------------------------------------------------------------------------- /example/doc_shared_memory.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | //[doc_shared_memory 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | //<- 18 | #include "../test/get_process_id_name.hpp" 19 | //-> 20 | 21 | int main(int argc, char *argv[]) 22 | { 23 | using namespace boost::interprocess; 24 | 25 | if(argc == 1){ //Parent process 26 | //Remove shared memory on construction and destruction 27 | struct shm_remove 28 | { 29 | shm_remove() { shared_memory_object::remove(test::get_process_id_name()); } 30 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } 31 | } remover; 32 | //<- 33 | (void)remover; 34 | //-> 35 | 36 | //Create a shared memory object. 37 | shared_memory_object shm (create_only, test::get_process_id_name(), read_write); 38 | 39 | //Set size 40 | shm.truncate(1000); 41 | 42 | //Map the whole shared memory in this process 43 | mapped_region region(shm, read_write); 44 | 45 | //Write all the memory to 1 46 | std::memset(region.get_address(), 1, region.get_size()); 47 | 48 | //Launch child process 49 | std::string s(argv[0]); s += " child "; 50 | //<- 51 | s += test::get_process_id_name(); 52 | //-> 53 | if(0 != std::system(s.c_str())) 54 | return 1; 55 | } 56 | else{ 57 | //Open already created shared memory object. 58 | shared_memory_object shm (open_only, test::get_argv_2(argv), read_only); 59 | 60 | //Map the whole shared memory in this process 61 | mapped_region region(shm, read_only); 62 | 63 | //Check that memory was initialized to 1 64 | char *mem = static_cast(region.get_address()); 65 | for(std::size_t i = 0; i < region.get_size(); ++i) 66 | if(*mem++ != 1) 67 | return 1; //Error checking memory 68 | } 69 | return 0; 70 | } 71 | //] 72 | 73 | -------------------------------------------------------------------------------- /example/doc_shared_ptr_explicit.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. 4 | // Distributed under the Boost Software License, Version 1.0. 5 | // (See accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | // See http://www.boost.org/libs/interprocess for documentation. 9 | // 10 | ////////////////////////////////////////////////////////////////////////////// 11 | 12 | #include 13 | 14 | //[doc_shared_ptr_explicit 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | //<- 21 | #include "../test/get_process_id_name.hpp" 22 | //-> 23 | 24 | using namespace boost::interprocess; 25 | 26 | //This is type of the object we want to share 27 | class MyType 28 | {}; 29 | 30 | typedef managed_shared_memory::segment_manager segment_manager_type; 31 | typedef allocator void_allocator_type; 32 | typedef deleter deleter_type; 33 | typedef shared_ptr my_shared_ptr; 34 | 35 | int main () 36 | { 37 | //Remove shared memory on construction and destruction 38 | struct shm_remove 39 | { 40 | shm_remove() { shared_memory_object::remove(test::get_process_id_name()); } 41 | ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } 42 | } remover; 43 | //<- 44 | (void)remover; 45 | //-> 46 | 47 | managed_shared_memory segment(create_only, test::get_process_id_name(), 4096); 48 | 49 | //Create a shared pointer in shared memory 50 | //pointing to a newly created object in the segment 51 | my_shared_ptr &shared_ptr_instance = 52 | *segment.construct("shared ptr") 53 | //Arguments to construct the shared pointer 54 | ( segment.construct("object to share")() //object to own 55 | , void_allocator_type(segment.get_segment_manager()) //allocator 56 | , deleter_type(segment.get_segment_manager()) //deleter 57 | ); 58 | assert(shared_ptr_instance.use_count() == 1); 59 | 60 | //Destroy "shared ptr". "object to share" will be automatically destroyed 61 | segment.destroy_ptr(&shared_ptr_instance); 62 | 63 | return 0; 64 | } 65 | //] 66 | 67 | -------------------------------------------------------------------------------- /example/doc_upgradable_mutex_shared_data.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #include 11 | 12 | struct shared_data 13 | { 14 | enum { NumItems = 100 }; 15 | enum { LineSize = 100 }; 16 | 17 | shared_data() 18 | : current_line(0) 19 | , end_a(false) 20 | , end_b(false) 21 | {} 22 | 23 | //Mutex to protect access to the queue 24 | boost::interprocess::interprocess_upgradable_mutex upgradable_mutex; 25 | 26 | //Items to fill 27 | char items[NumItems][LineSize]; 28 | int current_line; 29 | bool end_a; 30 | bool end_b; 31 | }; 32 | -------------------------------------------------------------------------------- /example/doc_windows_shared_memory.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | 13 | #if defined(BOOST_INTERPROCESS_WINDOWS) || defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) 14 | 15 | //[doc_windows_shared_memory 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | //<- 22 | #include "../test/get_process_id_name.hpp" 23 | //-> 24 | 25 | int main(int argc, char *argv[]) 26 | { 27 | using namespace boost::interprocess; 28 | 29 | if(argc == 1){ //Parent process 30 | //Create a native windows shared memory object. 31 | windows_shared_memory shm (create_only, test::get_process_id_name(), read_write, 1000); 32 | 33 | //Map the whole shared memory in this process 34 | mapped_region region(shm, read_write); 35 | 36 | //Write all the memory to 1 37 | std::memset(region.get_address(), 1, region.get_size()); 38 | 39 | //Launch child process 40 | std::string s(argv[0]); s += " child "; 41 | //<- 42 | s += test::get_process_id_name(); 43 | //-> 44 | if(0 != std::system(s.c_str())) 45 | return 1; 46 | //windows_shared_memory is destroyed when the last attached process dies... 47 | } 48 | else{ 49 | //Open already created shared memory object. 50 | windows_shared_memory shm (open_only, test::get_argv_2(argv), read_only); 51 | 52 | //Map the whole shared memory in this process 53 | mapped_region region(shm, read_only); 54 | 55 | //Check that memory was initialized to 1 56 | char *mem = static_cast(region.get_address()); 57 | for(std::size_t i = 0; i < region.get_size(); ++i) 58 | if(*mem++ != 1) 59 | return 1; //Error checking memory 60 | return 0; 61 | } 62 | return 0; 63 | } 64 | //] 65 | 66 | #else //BOOST_INTERPROCESS_WINDOWS 67 | 68 | int main() 69 | { 70 | return 0; 71 | } 72 | 73 | #endif //BOOST_INTERPROCESS_WINDOWS 74 | 75 | 76 | -------------------------------------------------------------------------------- /extra/boost_interprocess.natvis: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | {get()} 22 | 23 | get() 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /extra/boost_interprocess_printers.py: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Braden Ganetsky 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # https://www.boost.org/LICENSE_1_0.txt 4 | 5 | import gdb.printing 6 | 7 | class BoostInterprocessOffsetPtrPrinter: 8 | def __init__(self, val): 9 | self.val = val 10 | 11 | def to_string(self): 12 | return f"{BoostInterprocessOffsetPtrPrinter.get(self.val)}" 13 | 14 | # This is a simplified and inlined version of `offset_ptr::get()` 15 | def get(offset_ptr): 16 | offset = offset_ptr["internal"]["m_offset"] 17 | pointer = offset_ptr.type.template_argument(0).pointer() 18 | if offset == 1: 19 | return gdb.Value(0).cast(pointer) # nullptr 20 | else: 21 | unsigned_char_pointer = gdb.lookup_type("unsigned char").pointer() 22 | this = offset_ptr.address 23 | return (this.cast(unsigned_char_pointer) + offset).cast(pointer) 24 | 25 | def boost_to_address(offset_ptr): 26 | return BoostInterprocessOffsetPtrPrinter.get(offset_ptr) 27 | 28 | # This is a simplified and inlined version of `offset_ptr::operator+=()` 29 | def boost_next(raw_ptr, offset): 30 | unsigned_char_pointer = gdb.lookup_type("unsigned char").pointer() 31 | pointer = raw_ptr.type 32 | aa = raw_ptr.cast(unsigned_char_pointer) 33 | bb = offset * pointer.target().sizeof 34 | return (aa + bb).cast(pointer) 35 | 36 | def boost_interprocess_build_pretty_printer(): 37 | pp = gdb.printing.RegexpCollectionPrettyPrinter("boost_interprocess") 38 | 39 | pp.add_printer("boost::interprocess::offset_ptr", "^boost::interprocess::offset_ptr<.*>$", BoostInterprocessOffsetPtrPrinter) 40 | 41 | return pp 42 | 43 | gdb.printing.register_pretty_printer(gdb.current_objfile(), boost_interprocess_build_pretty_printer()) 44 | -------------------------------------------------------------------------------- /include/boost/interprocess/allocators/detail/node_tools.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2007-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_DETAIL_NODE_TOOLS_HPP 12 | #define BOOST_INTERPROCESS_DETAIL_NODE_TOOLS_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | namespace boost { 28 | namespace interprocess { 29 | namespace ipcdetail { 30 | 31 | 32 | template 33 | struct node_slist 34 | { 35 | //This hook will be used to chain the individual nodes 36 | typedef typename bi::make_slist_base_hook 37 | , bi::link_mode >::type slist_hook_t; 38 | 39 | //A node object will hold node_t when it's not allocated 40 | struct node_t 41 | : public slist_hook_t 42 | {}; 43 | 44 | typedef typename bi::make_slist 45 | , bi::base_hook >::type node_slist_t; 46 | }; 47 | 48 | } //namespace ipcdetail { 49 | } //namespace interprocess { 50 | } //namespace boost { 51 | 52 | #include 53 | 54 | #endif //#ifndef BOOST_INTERPROCESS_DETAIL_NODE_TOOLS_HPP 55 | -------------------------------------------------------------------------------- /include/boost/interprocess/containers/allocation_type.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_CONTAINERS_ALLOCATION_TYPE_HPP 12 | #define BOOST_INTERPROCESS_CONTAINERS_ALLOCATION_TYPE_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | 25 | namespace boost { 26 | namespace interprocess { 27 | 28 | #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) 29 | using boost::container::allocation_type; 30 | #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED 31 | static const allocation_type allocate_new = boost::container::allocate_new; 32 | static const allocation_type expand_fwd = boost::container::expand_fwd; 33 | static const allocation_type expand_bwd = boost::container::expand_bwd; 34 | static const allocation_type shrink_in_place = boost::container::shrink_in_place; 35 | static const allocation_type try_shrink_in_place= boost::container::try_shrink_in_place; 36 | static const allocation_type nothrow_allocation = boost::container::nothrow_allocation; 37 | static const allocation_type zero_memory = boost::container::zero_memory; 38 | 39 | } //namespace interprocess { 40 | } //namespace boost { 41 | 42 | #include 43 | 44 | #endif // #ifndef BOOST_INTERPROCESS_CONTAINERS_ALLOCATION_TYPE_HPP 45 | -------------------------------------------------------------------------------- /include/boost/interprocess/containers/containers_fwd.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2009-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_CONTAINERS_CONTAINERS_FWD_HPP 12 | #define BOOST_INTERPROCESS_CONTAINERS_CONTAINERS_FWD_HPP 13 | 14 | #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) 15 | 16 | #ifndef BOOST_CONFIG_HPP 17 | # include 18 | #endif 19 | # 20 | #if defined(BOOST_HAS_PRAGMA_ONCE) 21 | # pragma once 22 | #endif 23 | 24 | ////////////////////////////////////////////////////////////////////////////// 25 | // Standard predeclarations 26 | ////////////////////////////////////////////////////////////////////////////// 27 | 28 | #include 29 | #include 30 | 31 | namespace boost { 32 | namespace interprocess { 33 | 34 | using boost::container::ordered_range; 35 | using boost::container::ordered_unique_range; 36 | 37 | } //namespace interprocess { 38 | } //namespace boost { 39 | 40 | #include 41 | 42 | #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED 43 | 44 | #endif // #ifndef BOOST_INTERPROCESS_CONTAINERS_CONTAINERS_FWD_HPP 45 | -------------------------------------------------------------------------------- /include/boost/interprocess/containers/deque.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_CONTAINERS_DEQUE_HPP 12 | #define BOOST_INTERPROCESS_CONTAINERS_DEQUE_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace boost { 27 | namespace interprocess { 28 | 29 | using boost::container::deque; 30 | 31 | } //namespace interprocess { 32 | } //namespace boost { 33 | 34 | #include 35 | 36 | #endif // #ifndef BOOST_INTERPROCESS_CONTAINERS_DEQUE_HPP 37 | 38 | -------------------------------------------------------------------------------- /include/boost/interprocess/containers/flat_map.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_CONTAINERS_FLAT_MAP_HPP 12 | #define BOOST_INTERPROCESS_CONTAINERS_FLAT_MAP_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace boost { 27 | namespace interprocess { 28 | 29 | using boost::container::flat_map; 30 | using boost::container::flat_multimap; 31 | 32 | } //namespace interprocess { 33 | } //namespace boost { 34 | 35 | #include 36 | 37 | #endif // #ifndef BOOST_INTERPROCESS_CONTAINERS_FLAT_MAP_HPP 38 | -------------------------------------------------------------------------------- /include/boost/interprocess/containers/flat_set.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_CONTAINERS_FLAT_SET_HPP 12 | #define BOOST_INTERPROCESS_CONTAINERS_FLAT_SET_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace boost { 27 | namespace interprocess { 28 | 29 | using boost::container::flat_set; 30 | using boost::container::flat_multiset; 31 | 32 | } //namespace interprocess { 33 | } //namespace boost { 34 | 35 | #include 36 | 37 | #endif // #ifndef BOOST_INTERPROCESS_CONTAINERS_FLAT_SET_HPP 38 | -------------------------------------------------------------------------------- /include/boost/interprocess/containers/list.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_CONTAINERS_LIST_HPP 12 | #define BOOST_INTERPROCESS_CONTAINERS_LIST_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace boost { 27 | namespace interprocess { 28 | 29 | using boost::container::list; 30 | 31 | } //namespace interprocess { 32 | } //namespace boost { 33 | 34 | #include 35 | 36 | #endif // #ifndef BOOST_INTERPROCESS_CONTAINERS_LIST_HPP 37 | 38 | -------------------------------------------------------------------------------- /include/boost/interprocess/containers/map.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_CONTAINERS_MAP_HPP 12 | #define BOOST_INTERPROCESS_CONTAINERS_MAP_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace boost { 27 | namespace interprocess { 28 | 29 | using boost::container::map; 30 | using boost::container::multimap; 31 | 32 | } //namespace interprocess { 33 | } //namespace boost { 34 | 35 | #include 36 | 37 | #endif // #ifndef BOOST_INTERPROCESS_CONTAINERS_MAP_HPP 38 | -------------------------------------------------------------------------------- /include/boost/interprocess/containers/pair.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_CONTAINERS_PAIR_HPP 12 | #define BOOST_INTERPROCESS_CONTAINERS_PAIR_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace boost { 27 | namespace interprocess { 28 | 29 | using boost::container::dtl::pair; 30 | 31 | } //namespace interprocess { 32 | } //namespace boost { 33 | 34 | #include 35 | 36 | #endif // #ifndef BOOST_INTERPROCESS_CONTAINERS_PAIR_HPP 37 | 38 | -------------------------------------------------------------------------------- /include/boost/interprocess/containers/set.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_CONTAINERS_SET_HPP 12 | #define BOOST_INTERPROCESS_CONTAINERS_SET_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace boost { 27 | namespace interprocess { 28 | 29 | using boost::container::set; 30 | using boost::container::multiset; 31 | 32 | } //namespace interprocess { 33 | } //namespace boost { 34 | 35 | #include 36 | 37 | #endif // #ifndef BOOST_INTERPROCESS_CONTAINERS_SET_HPP 38 | -------------------------------------------------------------------------------- /include/boost/interprocess/containers/slist.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_CONTAINERS_SLIST_HPP 12 | #define BOOST_INTERPROCESS_CONTAINERS_SLIST_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace boost { 27 | namespace interprocess { 28 | 29 | using boost::container::slist; 30 | 31 | } //namespace interprocess { 32 | } //namespace boost { 33 | 34 | #include 35 | 36 | #endif // #ifndef BOOST_INTERPROCESS_CONTAINERS_SLIST_HPP 37 | -------------------------------------------------------------------------------- /include/boost/interprocess/containers/stable_vector.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_CONTAINERS_STABLE_VECTOR_HPP 12 | #define BOOST_INTERPROCESS_CONTAINERS_STABLE_VECTOR_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace boost { 27 | namespace interprocess { 28 | 29 | using boost::container::stable_vector; 30 | 31 | } //namespace interprocess { 32 | } //namespace boost { 33 | 34 | #include 35 | 36 | #endif // #ifndef BOOST_INTERPROCESS_CONTAINERS_STABLE_VECTOR_HPP 37 | -------------------------------------------------------------------------------- /include/boost/interprocess/containers/string.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_CONTAINERS_STRING_HPP 12 | #define BOOST_INTERPROCESS_CONTAINERS_STRING_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace boost { 27 | namespace interprocess { 28 | 29 | using boost::container::basic_string; 30 | using boost::container::string; 31 | 32 | } //namespace interprocess { 33 | } //namespace boost { 34 | 35 | #include 36 | 37 | #endif // #ifndef BOOST_INTERPROCESS_CONTAINERS_STRING_HPP 38 | -------------------------------------------------------------------------------- /include/boost/interprocess/containers/vector.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_CONTAINERS_VECTOR_HPP 12 | #define BOOST_INTERPROCESS_CONTAINERS_VECTOR_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace boost { 27 | namespace interprocess { 28 | 29 | using boost::container::vector; 30 | 31 | } //namespace interprocess { 32 | } //namespace boost { 33 | 34 | #include 35 | 36 | #endif // #ifndef BOOST_INTERPROCESS_CONTAINERS_VECTOR_HPP 37 | 38 | -------------------------------------------------------------------------------- /include/boost/interprocess/containers/version_type.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_CONTAINERS_VERSION_TYPE_HPP 12 | #define BOOST_INTERPROCESS_CONTAINERS_VERSION_TYPE_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | 25 | namespace boost { 26 | namespace interprocess { 27 | 28 | using boost::container::dtl::version_type; 29 | using boost::container::dtl::version; 30 | 31 | } //namespace interprocess { 32 | } //namespace boost { 33 | 34 | #include 35 | 36 | #endif // #ifndef BOOST_INTERPROCESS_CONTAINERS_VERSION_TYPE_HPP 37 | 38 | -------------------------------------------------------------------------------- /include/boost/interprocess/creation_tags.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_CREATION_TAGS_HPP 12 | #define BOOST_INTERPROCESS_CREATION_TAGS_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | 25 | namespace boost { 26 | namespace interprocess { 27 | 28 | //!Tag to indicate that the resource must 29 | //!be only created 30 | struct create_only_t {}; 31 | 32 | //!Tag to indicate that the resource must 33 | //!be only opened 34 | struct open_only_t {}; 35 | 36 | //!Tag to indicate that the resource must 37 | //!be only opened for reading 38 | struct open_read_only_t {}; 39 | 40 | //!Tag to indicate that the resource must 41 | //!be only opened privately for reading 42 | struct open_read_private_t {}; 43 | 44 | //!Tag to indicate that the resource must 45 | //!be only opened for reading 46 | struct open_copy_on_write_t {}; 47 | 48 | //!Tag to indicate that the resource must 49 | //!be created. If already created, it must be opened. 50 | struct open_or_create_t {}; 51 | 52 | //!Value to indicate that the resource must 53 | //!be only created 54 | static const create_only_t create_only = create_only_t(); 55 | 56 | //!Value to indicate that the resource must 57 | //!be only opened 58 | static const open_only_t open_only = open_only_t(); 59 | 60 | //!Value to indicate that the resource must 61 | //!be only opened for reading 62 | static const open_read_only_t open_read_only = open_read_only_t(); 63 | 64 | //!Value to indicate that the resource must 65 | //!be created. If already created, it must be opened. 66 | static const open_or_create_t open_or_create = open_or_create_t(); 67 | 68 | //!Value to indicate that the resource must 69 | //!be only opened for reading 70 | static const open_copy_on_write_t open_copy_on_write = open_copy_on_write_t(); 71 | 72 | namespace ipcdetail { 73 | 74 | enum create_enum_t 75 | { DoCreate, DoOpen, DoOpenOrCreate }; 76 | 77 | } //namespace ipcdetail { 78 | 79 | } //namespace interprocess { 80 | } //namespace boost { 81 | 82 | #include 83 | 84 | #endif //#ifndef BOOST_INTERPROCESS_CREATION_TAGS_HPP 85 | 86 | -------------------------------------------------------------------------------- /include/boost/interprocess/detail/cast_tags.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_DETAIL_CAST_TAGS_HPP 12 | #define BOOST_INTERPROCESS_DETAIL_CAST_TAGS_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | namespace boost { namespace interprocess { namespace ipcdetail { 23 | 24 | struct static_cast_tag {}; 25 | struct const_cast_tag {}; 26 | struct dynamic_cast_tag {}; 27 | struct reinterpret_cast_tag {}; 28 | 29 | }}} //namespace boost { namespace interprocess { namespace ipcdetail { 30 | 31 | #endif //#ifndef BOOST_INTERPROCESS_DETAIL_CAST_TAGS_HPP 32 | -------------------------------------------------------------------------------- /include/boost/interprocess/detail/config_end.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #if defined BOOST_MSVC 11 | #pragma warning (pop) 12 | #endif 13 | 14 | #if (defined(BOOST_GCC) && (BOOST_GCC >= 40600)) || (defined(BOOST_CLANG) && defined(_MSC_VER)) 15 | #pragma GCC diagnostic pop 16 | #endif 17 | -------------------------------------------------------------------------------- /include/boost/interprocess/detail/config_external_begin.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2012-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #ifndef BOOST_INTERPROCESS_EXTERNAL_CONFIG_INCLUDED 11 | #define BOOST_INTERPROCESS_EXTERNAL_CONFIG_INCLUDED 12 | #include 13 | #endif 14 | 15 | #if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 406) 16 | # pragma GCC diagnostic push 17 | # pragma GCC diagnostic ignored "-Wshadow" 18 | # pragma GCC diagnostic ignored "-Wsign-conversion" 19 | # pragma GCC diagnostic ignored "-Wconversion" 20 | # if (BOOST_GCC >= 100000) 21 | # pragma GCC diagnostic ignored "-Warith-conversion" 22 | # endif 23 | #endif 24 | -------------------------------------------------------------------------------- /include/boost/interprocess/detail/config_external_end.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2012-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 406) 11 | # pragma GCC diagnostic pop 12 | #endif 13 | -------------------------------------------------------------------------------- /include/boost/interprocess/detail/intermodule_singleton.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2009-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_INTERMODULE_SINGLETON_HPP 12 | #define BOOST_INTERPROCESS_INTERMODULE_SINGLETON_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | #pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | 25 | #ifdef BOOST_INTERPROCESS_WINDOWS 26 | #include 27 | #else 28 | #include 29 | #endif 30 | 31 | namespace boost{ 32 | namespace interprocess{ 33 | namespace ipcdetail{ 34 | 35 | //Now this class is a singleton, initializing the singleton in 36 | //the first get() function call if LazyInit is true. If false 37 | //then the singleton will be initialized when loading the module. 38 | template 39 | class intermodule_singleton 40 | #ifdef BOOST_INTERPROCESS_WINDOWS 41 | : public windows_intermodule_singleton 42 | #else 43 | : public portable_intermodule_singleton 44 | #endif 45 | {}; 46 | 47 | } //namespace ipcdetail{ 48 | } //namespace interprocess{ 49 | } //namespace boost{ 50 | 51 | #include 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /include/boost/interprocess/detail/interprocess_tester.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2007-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_DETAIL_INTERPROCESS_TESTER_HPP 12 | #define BOOST_INTERPROCESS_DETAIL_INTERPROCESS_TESTER_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | namespace boost{ 23 | namespace interprocess{ 24 | namespace ipcdetail{ 25 | 26 | class interprocess_tester 27 | { 28 | public: 29 | template 30 | static void dont_close_on_destruction(T &t) 31 | { t.dont_close_on_destruction(); } 32 | }; 33 | 34 | } //namespace ipcdetail{ 35 | } //namespace interprocess{ 36 | } //namespace boost{ 37 | 38 | #endif //#ifndef BOOST_INTERPROCESS_DETAIL_INTERPROCESS_TESTER_HPP 39 | 40 | -------------------------------------------------------------------------------- /include/boost/interprocess/detail/min_max.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2005-2012. 4 | // 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // (See accompanying file LICENSE_1_0.txt or copy at 7 | // http://www.boost.org/LICENSE_1_0.txt) 8 | // 9 | // See http://www.boost.org/libs/interprocess for documentation. 10 | // 11 | ////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef BOOST_INTERPROCESS_DETAIL_MIN_MAX_HPP 14 | #define BOOST_INTERPROCESS_DETAIL_MIN_MAX_HPP 15 | 16 | #ifndef BOOST_CONFIG_HPP 17 | # include 18 | #endif 19 | # 20 | #if defined(BOOST_HAS_PRAGMA_ONCE) 21 | # pragma once 22 | #endif 23 | 24 | #include 25 | #include 26 | 27 | namespace boost { 28 | namespace interprocess { 29 | 30 | template 31 | const T &max_value(const T &a, const T &b) 32 | { return a > b ? a : b; } 33 | 34 | template 35 | const T &min_value(const T &a, const T &b) 36 | { return a < b ? a : b; } 37 | 38 | } //namespace interprocess { 39 | } //namespace boost { 40 | 41 | #include 42 | 43 | #endif //#ifndef BOOST_INTERPROCESS_DETAIL_MIN_MAX_HPP 44 | 45 | -------------------------------------------------------------------------------- /include/boost/interprocess/detail/move.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2010-2012. 4 | // Distributed under the Boost Software License, Version 1.0. 5 | // (See accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | // See http://www.boost.org/libs/move for documentation. 9 | // 10 | ////////////////////////////////////////////////////////////////////////////// 11 | 12 | //! \file 13 | 14 | #ifndef BOOST_INTERPROCESS_DETAIL_MOVE_HPP 15 | #define BOOST_INTERPROCESS_DETAIL_MOVE_HPP 16 | 17 | #ifndef BOOST_CONFIG_HPP 18 | # include 19 | #endif 20 | # 21 | #if defined(BOOST_HAS_PRAGMA_ONCE) 22 | # pragma once 23 | #endif 24 | 25 | #include 26 | 27 | namespace boost { 28 | namespace interprocess { 29 | 30 | using ::boost::move; 31 | using ::boost::forward; 32 | 33 | } //namespace interprocess { 34 | } //namespace boost { 35 | 36 | #endif //#ifndef BOOST_INTERPROCESS_DETAIL_MOVE_HPP 37 | -------------------------------------------------------------------------------- /include/boost/interprocess/detail/nothrow.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #ifndef BOOST_INTERPROCESS_DETAIL_NOTHROW_HPP 11 | #define BOOST_INTERPROCESS_DETAIL_NOTHROW_HPP 12 | 13 | #ifndef BOOST_CONFIG_HPP 14 | # include 15 | #endif 16 | # 17 | #if defined(BOOST_HAS_PRAGMA_ONCE) 18 | # pragma once 19 | #endif 20 | 21 | namespace std { //no namespace versioning in clang+libc++ 22 | 23 | struct nothrow_t; 24 | 25 | } //namespace std { 26 | 27 | namespace boost{ namespace interprocess { 28 | 29 | template 30 | struct nothrow 31 | { 32 | static const std::nothrow_t &get() { return *pnothrow; } 33 | static std::nothrow_t *pnothrow; 34 | }; 35 | 36 | template 37 | std::nothrow_t *nothrow::pnothrow = 38 | reinterpret_cast(0x1234); //Avoid sanitizer warnings on references to null 39 | 40 | }} //namespace boost{ namespace interprocess { 41 | 42 | #endif //#ifndef BOOST_INTERPROCESS_DETAIL_NOTHROW_HPP 43 | -------------------------------------------------------------------------------- /include/boost/interprocess/detail/pointer_type.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2005-2012. 4 | // (C) Copyright Gennaro Prota 2003 - 2004. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // (See accompanying file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // See http://www.boost.org/libs/interprocess for documentation. 11 | // 12 | ////////////////////////////////////////////////////////////////////////////// 13 | 14 | #ifndef BOOST_INTERPROCESS_DETAIL_POINTER_TYPE_HPP 15 | #define BOOST_INTERPROCESS_DETAIL_POINTER_TYPE_HPP 16 | 17 | #ifndef BOOST_CONFIG_HPP 18 | # include 19 | #endif 20 | # 21 | #if defined(BOOST_HAS_PRAGMA_ONCE) 22 | # pragma once 23 | #endif 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace boost { 30 | namespace interprocess { 31 | namespace ipcdetail { 32 | 33 | struct two {char _[2];}; 34 | 35 | namespace pointer_type_imp { 36 | 37 | template static two test(...); 38 | template static char test(typename U::pointer* = 0); 39 | 40 | } //namespace pointer_type_imp { 41 | 42 | template 43 | struct has_pointer_type 44 | { 45 | static const bool value = sizeof(pointer_type_imp::test(0)) == 1; 46 | }; 47 | 48 | namespace pointer_type_imp { 49 | 50 | template ::value> 51 | struct pointer_type 52 | { 53 | typedef typename D::pointer type; 54 | }; 55 | 56 | template 57 | struct pointer_type 58 | { 59 | typedef T* type; 60 | }; 61 | 62 | } //namespace pointer_type_imp { 63 | 64 | template 65 | struct pointer_type 66 | { 67 | typedef typename pointer_type_imp::pointer_type::type>::type type; 69 | }; 70 | 71 | } //namespace ipcdetail { 72 | } //namespace interprocess { 73 | } //namespace boost { 74 | 75 | #include 76 | 77 | #endif //#ifndef BOOST_INTERPROCESS_DETAIL_POINTER_TYPE_HPP 78 | 79 | -------------------------------------------------------------------------------- /include/boost/interprocess/detail/simple_swap.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_INTERPROCESS_DETAIL_SWAP_HPP 2 | #define BOOST_INTERPROCESS_DETAIL_SWAP_HPP 3 | ////////////////////////////////////////////////////////////////////////////// 4 | // 5 | // (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | // 9 | // See http://www.boost.org/libs/interprocess for documentation. 10 | // 11 | ////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef BOOST_CONFIG_HPP 14 | # include 15 | #endif 16 | # 17 | #if defined(BOOST_HAS_PRAGMA_ONCE) 18 | # pragma once 19 | #endif 20 | 21 | namespace boost { namespace interprocess { 22 | 23 | template 24 | void simple_swap(T&x, T&y) 25 | { T tmp(x); x = y; y = tmp; } 26 | 27 | }} //namespace boost{ namespace interprocess { 28 | 29 | #endif //#ifndef BOOST_INTERPROCESS_DETAIL_SWAP_HPP 30 | -------------------------------------------------------------------------------- /include/boost/interprocess/detail/std_fwd.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #ifndef BOOST_INTERPROCESS_DETAIL_STD_FWD_HPP 11 | #define BOOST_INTERPROCESS_DETAIL_STD_FWD_HPP 12 | 13 | #ifndef BOOST_CONFIG_HPP 14 | # include 15 | #endif 16 | # 17 | #if defined(BOOST_HAS_PRAGMA_ONCE) 18 | # pragma once 19 | #endif 20 | 21 | ////////////////////////////////////////////////////////////////////////////// 22 | // Standard predeclarations 23 | ////////////////////////////////////////////////////////////////////////////// 24 | 25 | #include 26 | BOOST_MOVE_STD_NS_BEG 27 | 28 | struct input_iterator_tag; 29 | struct forward_iterator_tag; 30 | struct bidirectional_iterator_tag; 31 | struct random_access_iterator_tag; 32 | 33 | template 34 | struct char_traits; 35 | 36 | #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1800) &&defined(BOOST_DINKUMWARE_STDLIB) 37 | #define BOOST_INTERPROCESS_STD_FWD_MSVC_IOS_BUG 38 | // Compiler bug workaround. Previous versions (<= VC11) 39 | // used dummy virtual functions 40 | # pragma vtordisp(push, 2) 41 | #endif 42 | 43 | template 44 | class basic_ostream; 45 | 46 | template 47 | class basic_istream; 48 | 49 | #ifdef BOOST_INTERPROCESS_STD_FWD_MSVC_IOS_BUG 50 | # pragma vtordisp(pop) 51 | # undef BOOST_INTERPROCESS_STD_FWD_MSVC_IOS_BUG 52 | #endif 53 | 54 | BOOST_MOVE_STD_NS_END 55 | #include 56 | 57 | #endif //#ifndef BOOST_INTERPROCESS_DETAIL_STD_FWD_HPP 58 | -------------------------------------------------------------------------------- /include/boost/interprocess/detail/transform_iterator.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2005-2015. 4 | // (C) Copyright Gennaro Prota 2003 - 2004. 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // (See accompanying file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // See http://www.boost.org/libs/interprocess for documentation. 11 | // 12 | ////////////////////////////////////////////////////////////////////////////// 13 | 14 | #ifndef BOOST_INTERPROCESS_DETAIL_TRANSFORM_ITERATORS_HPP 15 | #define BOOST_INTERPROCESS_DETAIL_TRANSFORM_ITERATORS_HPP 16 | 17 | #ifndef BOOST_CONFIG_HPP 18 | # include 19 | #endif 20 | # 21 | #if defined(BOOST_HAS_PRAGMA_ONCE) 22 | # pragma once 23 | #endif 24 | 25 | #include 26 | #include 27 | 28 | // interprocess 29 | #include 30 | // container/detail 31 | #include 32 | 33 | namespace boost { 34 | namespace interprocess { 35 | 36 | using boost::container::make_transform_iterator; 37 | using boost::container::transform_iterator; 38 | 39 | } //namespace interprocess { 40 | } //namespace boost { 41 | 42 | #include 43 | 44 | #endif //#ifndef BOOST_INTERPROCESS_DETAIL_TRANSFORM_ITERATORS_HPP 45 | -------------------------------------------------------------------------------- /include/boost/interprocess/detail/variadic_templates_tools.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP 12 | #define BOOST_INTERPROCESS_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | 24 | namespace boost { 25 | namespace interprocess { 26 | namespace ipcdetail { 27 | 28 | using boost::container::dtl::tuple; 29 | using boost::container::dtl::build_number_seq; 30 | using boost::container::dtl::index_tuple; 31 | using boost::container::dtl::get; 32 | 33 | }}} //namespace boost { namespace interprocess { namespace ipcdetail { 34 | 35 | #endif //#ifndef BOOST_INTERPROCESS_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP 36 | -------------------------------------------------------------------------------- /include/boost/interprocess/indexes/null_index.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #ifndef BOOST_INTERPROCESS_NULL_INDEX_HPP 11 | #define BOOST_INTERPROCESS_NULL_INDEX_HPP 12 | 13 | #ifndef BOOST_CONFIG_HPP 14 | # include 15 | #endif 16 | # 17 | #if defined(BOOST_HAS_PRAGMA_ONCE) 18 | # pragma once 19 | #endif 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | //!\file 27 | //!Describes a null index adaptor, so that if we don't want to construct 28 | //!named objects, we can use this null index type to save resources. 29 | 30 | namespace boost { 31 | namespace interprocess { 32 | 33 | //!Null index type 34 | //!used to save compilation time when 35 | //!named indexes are not needed. 36 | template 37 | class null_index 38 | { 39 | #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) 40 | typedef typename MapConfig:: 41 | segment_manager_base segment_manager_base; 42 | #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED 43 | 44 | public: 45 | typedef int * iterator; 46 | typedef const int * const_iterator; 47 | 48 | //!begin() is equal 49 | //!to end() 50 | const_iterator begin() const 51 | { return const_iterator(0); } 52 | 53 | //!begin() is equal 54 | //!to end() 55 | iterator begin() 56 | { return iterator(0); } 57 | 58 | //!begin() is equal 59 | //!to end() 60 | const_iterator end() const 61 | { return const_iterator(0); } 62 | 63 | //!begin() is equal 64 | //!to end() 65 | iterator end() 66 | { return iterator(0); } 67 | 68 | //!Empty constructor 69 | null_index(segment_manager_base *){} 70 | }; 71 | 72 | }} //namespace boost { namespace interprocess { 73 | 74 | #include 75 | 76 | #endif //#ifndef BOOST_INTERPROCESS_NULL_INDEX_HPP 77 | -------------------------------------------------------------------------------- /include/boost/interprocess/mem_algo/simple_seq_fit.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_SIMPLE_SEQ_FIT_HPP 12 | #define BOOST_INTERPROCESS_SIMPLE_SEQ_FIT_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | //!\file 30 | //!Describes sequential fit algorithm used to allocate objects in shared memory. 31 | 32 | namespace boost { 33 | namespace interprocess { 34 | 35 | //!This class implements the simple sequential fit algorithm with a simply 36 | //!linked list of free buffers. 37 | template 38 | class simple_seq_fit 39 | : public ipcdetail::simple_seq_fit_impl 40 | { 41 | #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) 42 | typedef ipcdetail::simple_seq_fit_impl base_t; 43 | #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED 44 | 45 | public: 46 | typedef typename base_t::size_type size_type; 47 | 48 | //!Constructor. "size" is the total size of the managed memory segment, 49 | //!"extra_hdr_bytes" indicates the extra bytes beginning in the sizeof(simple_seq_fit) 50 | //!offset that the allocator should not use at all.*/ 51 | simple_seq_fit(size_type segment_size, size_type extra_hdr_bytes) 52 | : base_t(segment_size, extra_hdr_bytes){} 53 | }; 54 | 55 | } //namespace interprocess { 56 | 57 | } //namespace boost { 58 | 59 | #include 60 | 61 | #endif //#ifndef BOOST_INTERPROCESS_SIMPLE_SEQ_FIT_HPP 62 | 63 | -------------------------------------------------------------------------------- /include/boost/interprocess/smart_ptr/deleter.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2007-2012. 4 | // 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // (See accompanying file LICENSE_1_0.txt or copy at 7 | // http://www.boost.org/LICENSE_1_0.txt) 8 | // 9 | // See http://www.boost.org/libs/interprocess for documentation. 10 | // 11 | ////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef BOOST_INTERPROCESS_DELETER_HPP 14 | #define BOOST_INTERPROCESS_DELETER_HPP 15 | 16 | #ifndef BOOST_CONFIG_HPP 17 | # include 18 | #endif 19 | # 20 | #if defined(BOOST_HAS_PRAGMA_ONCE) 21 | # pragma once 22 | #endif 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | //!\file 30 | //!Describes the functor to delete objects from the segment. 31 | 32 | namespace boost { 33 | namespace interprocess { 34 | 35 | //!A deleter that uses the segment manager's destroy_ptr 36 | //!function to destroy the passed pointer resource. 37 | //! 38 | //!This deleter is used 39 | template 40 | class deleter 41 | { 42 | public: 43 | typedef typename boost::intrusive:: 44 | pointer_traits::template 45 | rebind_pointer::type pointer; 46 | 47 | private: 48 | typedef typename boost::intrusive:: 49 | pointer_traits::template 50 | rebind_pointer::type segment_manager_pointer; 51 | 52 | segment_manager_pointer mp_mngr; 53 | 54 | public: 55 | deleter(segment_manager_pointer pmngr) BOOST_NOEXCEPT 56 | : mp_mngr(pmngr) 57 | {} 58 | 59 | void operator()(const pointer &p) 60 | { mp_mngr->destroy_ptr(ipcdetail::to_raw_pointer(p)); } 61 | }; 62 | 63 | } //namespace interprocess { 64 | } //namespace boost { 65 | 66 | #include 67 | 68 | #endif //#ifndef BOOST_INTERPROCESS_DELETER_HPP 69 | -------------------------------------------------------------------------------- /include/boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // This file is the adaptation for Interprocess of boost/detail/bad_weak_ptr.hpp 4 | // 5 | // (C) Copyright Peter Dimov and Multi Media Ltd. 2001, 2002, 2003 6 | // (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost 7 | // Software License, Version 1.0. (See accompanying file 8 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // See http://www.boost.org/libs/interprocess for documentation. 11 | // 12 | ////////////////////////////////////////////////////////////////////////////// 13 | #ifndef BOOST_INTERPROCESS_BAD_WEAK_PTR_HPP_INCLUDED 14 | #define BOOST_INTERPROCESS_BAD_WEAK_PTR_HPP_INCLUDED 15 | 16 | #ifndef BOOST_CONFIG_HPP 17 | # include 18 | #endif 19 | # 20 | #if defined(BOOST_HAS_PRAGMA_ONCE) 21 | # pragma once 22 | #endif 23 | 24 | #include 25 | #include 26 | 27 | #ifndef BOOST_NO_EXCEPTIONS 28 | #include 29 | #endif 30 | 31 | namespace boost{ 32 | namespace interprocess{ 33 | 34 | class bad_weak_ptr 35 | : public std::exception 36 | { 37 | public: 38 | 39 | virtual char const * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE 40 | { return "boost::interprocess::bad_weak_ptr"; } 41 | }; 42 | 43 | } // namespace interprocess 44 | } // namespace boost 45 | 46 | #include 47 | 48 | #endif // #ifndef BOOST_INTERPROCESS_BAD_WEAK_PTR_HPP_INCLUDED 49 | -------------------------------------------------------------------------------- /include/boost/interprocess/smart_ptr/detail/sp_counted_base.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2007-2012. 4 | // 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // (See accompanying file LICENSE_1_0.txt or copy at 7 | // http://www.boost.org/LICENSE_1_0.txt) 8 | // 9 | // See http://www.boost.org/libs/interprocess for documentation. 10 | // 11 | ////////////////////////////////////////////////////////////////////////////// 12 | #ifndef BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED 13 | #define BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED 14 | 15 | #ifndef BOOST_CONFIG_HPP 16 | # include 17 | #endif 18 | # 19 | #if defined(BOOST_HAS_PRAGMA_ONCE) 20 | # pragma once 21 | #endif 22 | 23 | # include 24 | 25 | #endif // #ifndef BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED 26 | 27 | -------------------------------------------------------------------------------- /include/boost/interprocess/smart_ptr/detail/sp_counted_base_atomic.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_ATOMIC_HPP_INCLUDED 2 | #define BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_ATOMIC_HPP_INCLUDED 3 | 4 | #ifndef BOOST_CONFIG_HPP 5 | # include 6 | #endif 7 | # 8 | #if defined(BOOST_HAS_PRAGMA_ONCE) 9 | # pragma once 10 | #endif 11 | 12 | // Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. 13 | // Copyright 2004-2005 Peter Dimov 14 | // Copyright 2007-2012 Ion Gaztanaga 15 | // 16 | // Distributed under the Boost Software License, Version 1.0. (See 17 | // accompanying file LICENSE_1_0.txt or copy at 18 | // http://www.boost.org/LICENSE_1_0.txt) 19 | // 20 | // 21 | // Lock-free algorithm by Alexander Terekhov 22 | // 23 | // Thanks to Ben Hitchings for the #weak + (#shared != 0) 24 | // formulation 25 | // 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | namespace boost { 34 | 35 | namespace interprocess { 36 | 37 | namespace ipcdetail { 38 | 39 | class sp_counted_base 40 | { 41 | private: 42 | 43 | sp_counted_base( sp_counted_base const & ); 44 | sp_counted_base & operator= ( sp_counted_base const & ); 45 | 46 | boost::uint32_t use_count_; // #shared 47 | boost::uint32_t weak_count_; // #weak + (#shared != 0) 48 | 49 | public: 50 | 51 | sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) 52 | {} 53 | 54 | ~sp_counted_base() // nothrow 55 | {} 56 | 57 | void add_ref_copy() 58 | { 59 | ipcdetail::atomic_inc32( &use_count_ ); 60 | } 61 | 62 | bool add_ref_lock() // true on success 63 | { 64 | for( ;; ) 65 | { 66 | boost::uint32_t tmp = static_cast< boost::uint32_t const volatile& >( use_count_ ); 67 | if( tmp == 0 ) return false; 68 | if( ipcdetail::atomic_cas32( &use_count_, tmp + 1, tmp ) == tmp ) 69 | return true; 70 | } 71 | } 72 | 73 | bool ref_release() // nothrow 74 | { return 1 == ipcdetail::atomic_dec32( &use_count_ ); } 75 | 76 | void weak_add_ref() // nothrow 77 | { ipcdetail::atomic_inc32( &weak_count_ ); } 78 | 79 | bool weak_release() // nothrow 80 | { return 1 == ipcdetail::atomic_dec32( &weak_count_ ); } 81 | 82 | long use_count() const // nothrow 83 | { return (long)static_cast( use_count_ ); } 84 | }; 85 | 86 | } // namespace ipcdetail 87 | 88 | } // namespace interprocess 89 | 90 | } // namespace boost 91 | 92 | #include 93 | 94 | #endif // #ifndef BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_ATOMIC_HPP_INCLUDED 95 | -------------------------------------------------------------------------------- /include/boost/interprocess/smart_ptr/unique_ptr.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2014. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_UNIQUE_PTR_HPP_INCLUDED 12 | #define BOOST_INTERPROCESS_UNIQUE_PTR_HPP_INCLUDED 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | //!\file 27 | //!This header provides utilities to define a unique_ptr that plays nicely with managed segments. 28 | 29 | namespace boost{ 30 | namespace interprocess{ 31 | 32 | //For backwards compatibility 33 | using ::boost::movelib::unique_ptr; 34 | 35 | //!Returns the type of a unique pointer 36 | //!of type T with boost::interprocess::deleter deleter 37 | //!that can be constructed in the given managed segment type. 38 | template 39 | struct managed_unique_ptr 40 | { 41 | typedef boost::movelib::unique_ptr 42 | < T 43 | , typename ManagedMemory::template deleter::type 44 | > type; 45 | }; 46 | 47 | //!Returns an instance of a unique pointer constructed 48 | //!with boost::interproces::deleter from a pointer 49 | //!of type T that has been allocated in the passed managed segment 50 | template 51 | inline typename managed_unique_ptr::type 52 | make_managed_unique_ptr(T *constructed_object, ManagedMemory &managed_memory) 53 | { 54 | return typename managed_unique_ptr::type 55 | (constructed_object, managed_memory.template get_deleter()); 56 | } 57 | 58 | } //namespace interprocess{ 59 | } //namespace boost{ 60 | 61 | #include 62 | 63 | #endif //#ifndef BOOST_INTERPROCESS_UNIQUE_PTR_HPP_INCLUDED 64 | -------------------------------------------------------------------------------- /include/boost/interprocess/sync/lock_options.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_LOCK_OPTIONS_HPP 12 | #define BOOST_INTERPROCESS_LOCK_OPTIONS_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | 25 | //!\file 26 | //!Describes the lock options with associated with interprocess_mutex lock constructors. 27 | 28 | namespace boost { 29 | namespace interprocess { 30 | 31 | //!Type to indicate to a mutex lock constructor that must not lock the mutex. 32 | struct defer_lock_type{}; 33 | //!Type to indicate to a mutex lock constructor that must try to lock the mutex. 34 | struct try_to_lock_type {}; 35 | //!Type to indicate to a mutex lock constructor that the mutex is already locked. 36 | struct accept_ownership_type{}; 37 | 38 | //!An object indicating that the locking 39 | //!must be deferred. 40 | static const defer_lock_type defer_lock = defer_lock_type(); 41 | 42 | //!An object indicating that a try_lock() 43 | //!operation must be executed. 44 | static const try_to_lock_type try_to_lock = try_to_lock_type(); 45 | 46 | //!An object indicating that the ownership of lockable 47 | //!object must be accepted by the new owner. 48 | static const accept_ownership_type accept_ownership = accept_ownership_type(); 49 | 50 | } // namespace interprocess { 51 | } // namespace boost{ 52 | 53 | #include 54 | 55 | #endif // BOOST_INTERPROCESS_LOCK_OPTIONS_HPP 56 | -------------------------------------------------------------------------------- /include/boost/interprocess/sync/mutex_family.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_MUTEX_FAMILY_HPP 12 | #define BOOST_INTERPROCESS_MUTEX_FAMILY_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | //!\file 30 | //!Describes a shared interprocess_mutex family fit algorithm used to allocate objects in shared memory. 31 | 32 | namespace boost { 33 | 34 | namespace interprocess { 35 | 36 | //!Describes interprocess_mutex family to use with Interprocess framework 37 | //!based on boost::interprocess synchronization objects. 38 | struct mutex_family 39 | { 40 | typedef boost::interprocess::interprocess_mutex mutex_type; 41 | typedef boost::interprocess::interprocess_recursive_mutex recursive_mutex_type; 42 | }; 43 | 44 | //!Describes interprocess_mutex family to use with Interprocess frameworks 45 | //!based on null operation synchronization objects. 46 | struct null_mutex_family 47 | { 48 | typedef boost::interprocess::null_mutex mutex_type; 49 | typedef boost::interprocess::null_mutex recursive_mutex_type; 50 | }; 51 | 52 | } //namespace interprocess { 53 | 54 | } //namespace boost { 55 | 56 | #include 57 | 58 | #endif //#ifndef BOOST_INTERPROCESS_MUTEX_FAMILY_HPP 59 | 60 | 61 | -------------------------------------------------------------------------------- /include/boost/interprocess/sync/posix/semaphore.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_POSIX_SEMAPHORE_HPP 12 | #define BOOST_INTERPROCESS_POSIX_SEMAPHORE_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | namespace boost { 28 | namespace interprocess { 29 | namespace ipcdetail { 30 | 31 | class posix_semaphore 32 | { 33 | posix_semaphore(); 34 | posix_semaphore(const posix_semaphore&); 35 | posix_semaphore &operator= (const posix_semaphore &); 36 | 37 | public: 38 | posix_semaphore(unsigned int initialCount) 39 | { semaphore_init(&m_sem, initialCount); } 40 | 41 | ~posix_semaphore() 42 | { semaphore_destroy(&m_sem); } 43 | 44 | void post() 45 | { semaphore_post(&m_sem); } 46 | 47 | void wait() 48 | { semaphore_wait(&m_sem); } 49 | 50 | bool try_wait() 51 | { return semaphore_try_wait(&m_sem); } 52 | 53 | template 54 | bool timed_wait(const TimePoint &abs_time) 55 | { return semaphore_timed_wait(&m_sem, abs_time); } 56 | 57 | private: 58 | sem_t m_sem; 59 | }; 60 | 61 | } //namespace ipcdetail { 62 | } //namespace interprocess { 63 | } //namespace boost { 64 | 65 | #include 66 | 67 | #endif //#ifndef BOOST_INTERPROCESS_POSIX_SEMAPHORE_HPP 68 | -------------------------------------------------------------------------------- /include/boost/interprocess/sync/shm/named_creation_functor.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2007-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_SYNC_NAMED_CREATION_FUNCTOR_HPP 12 | #define BOOST_INTERPROCESS_SYNC_NAMED_CREATION_FUNCTOR_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace boost { 28 | namespace interprocess { 29 | namespace ipcdetail { 30 | 31 | struct named_creation_functor_no_arg{}; 32 | 33 | template 34 | class named_creation_functor 35 | { 36 | typedef named_creation_functor_no_arg no_arg_t; 37 | public: 38 | named_creation_functor(create_enum_t type, Arg arg = Arg()) 39 | : m_creation_type(type), m_arg(arg){} 40 | 41 | template 42 | void construct(void *address, typename enable_if_c::value>::type * = 0) const 43 | { ::new(address, boost_container_new_t())T; } 44 | 45 | template 46 | void construct(void *address, typename enable_if_c::value>::type * = 0) const 47 | { ::new(address, boost_container_new_t())T(m_arg); } 48 | 49 | bool operator()(void *address, std::size_t, bool created) const 50 | { 51 | switch(m_creation_type){ 52 | case DoOpen: 53 | return true; 54 | break; 55 | case DoCreate: 56 | case DoOpenOrCreate: 57 | if(created){ 58 | construct(address); 59 | } 60 | return true; 61 | break; 62 | 63 | default: 64 | return false; 65 | break; 66 | } 67 | } 68 | 69 | static std::size_t get_min_size() 70 | { return sizeof(T); } 71 | 72 | private: 73 | create_enum_t m_creation_type; 74 | Arg m_arg; 75 | }; 76 | 77 | } //namespace ipcdetail { 78 | } //namespace interprocess { 79 | } //namespace boost { 80 | 81 | #endif //BOOST_INTERPROCESS_SYNC_NAMED_CREATION_FUNCTOR_HPP 82 | -------------------------------------------------------------------------------- /include/boost/interprocess/sync/spin/interprocess_barrier.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | namespace boost { 23 | namespace interprocess { 24 | 25 | inline barrier::barrier(unsigned int count) 26 | : m_threshold(count), m_count(count), m_generation(0) 27 | { 28 | if (count == 0) 29 | throw std::invalid_argument("count cannot be zero."); 30 | } 31 | 32 | inline barrier::~barrier(){} 33 | 34 | inline bool barrier::wait() 35 | { 36 | scoped_lock lock(m_mutex); 37 | unsigned int gen = m_generation; 38 | 39 | if (--m_count == 0){ 40 | m_generation++; 41 | m_count = m_threshold; 42 | m_cond.notify_all(); 43 | return true; 44 | } 45 | 46 | while (gen == m_generation){ 47 | m_cond.wait(lock); 48 | } 49 | return false; 50 | } 51 | 52 | } //namespace interprocess { 53 | } //namespace boost { 54 | -------------------------------------------------------------------------------- /include/boost/interprocess/sync/windows/named_condition.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2011-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_WINDOWS_NAMED_CONDITION_HPP 12 | #define BOOST_INTERPROCESS_WINDOWS_NAMED_CONDITION_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | namespace boost { 29 | namespace interprocess { 30 | namespace ipcdetail { 31 | 32 | typedef winapi_named_condition_any winapi_named_condition; 33 | 34 | } //namespace ipcdetail { 35 | } //namespace interprocess { 36 | } //namespace boost { 37 | 38 | #include 39 | 40 | #endif //BOOST_INTERPROCESS_WINDOWS_NAMED_CONDITION_HPP 41 | -------------------------------------------------------------------------------- /include/boost/interprocess/sync/windows/recursive_mutex.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_DETAIL_WINDOWS_RECURSIVE_MUTEX_HPP 12 | #define BOOST_INTERPROCESS_DETAIL_WINDOWS_RECURSIVE_MUTEX_HPP 13 | 14 | #ifndef BOOST_CONFIG_HPP 15 | # include 16 | #endif 17 | # 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) 19 | # pragma once 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace boost { 27 | namespace interprocess { 28 | namespace ipcdetail { 29 | 30 | //Windows mutex is already recursive 31 | class winapi_recursive_mutex 32 | : public winapi_mutex 33 | { 34 | winapi_recursive_mutex(const winapi_recursive_mutex &); 35 | winapi_recursive_mutex &operator=(const winapi_recursive_mutex &); 36 | public: 37 | winapi_recursive_mutex() : winapi_mutex() {} 38 | }; 39 | 40 | } //namespace ipcdetail { 41 | } //namespace interprocess { 42 | } //namespace boost { 43 | 44 | 45 | #include 46 | 47 | #endif //BOOST_INTERPROCESS_DETAIL_WINDOWS_RECURSIVE_MUTEX_HPP 48 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | Automatic redirection failed, please go to 12 | ../../doc/html/interprocess.html 13 | 14 | 15 | -------------------------------------------------------------------------------- /meta/libraries.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "interprocess", 3 | "name": "Interprocess", 4 | "authors": [ 5 | "Ion Gazta\u00f1aga" 6 | ], 7 | "description": "Shared memory, memory mapped files, process-shared mutexes, condition variables, containers and allocators.", 8 | "category": [ 9 | "Concurrent" 10 | ], 11 | "maintainers": [ 12 | "Ion Gaztanaga " 13 | ], 14 | "cxxstd": "03" 15 | } 16 | -------------------------------------------------------------------------------- /test/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # Boost Interprocess Library Test Jamfile 2 | 3 | # (C) Copyright Ion Gaztanaga 2006. 4 | # Use, modification and distribution are subject to the 5 | # Boost Software License, Version 1.0. (See accompanying file 6 | # LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | # Adapted from John Maddock's TR1 Jamfile.v2 9 | # Copyright John Maddock 2005. 10 | # Use, modification and distribution are subject to the 11 | # Boost Software License, Version 1.0. (See accompanying file 12 | # LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 13 | 14 | # this rule enumerates through all the sources and invokes 15 | # the run rule for each source, the result is a list of all 16 | # the run rules, which we can pass on to the test_suite rule: 17 | 18 | project : requirements 19 | /boost/interprocess//boost_interprocess 20 | #/boost/date_time//boost_date_time 21 | #/boost/chrono//boost_chrono 22 | acc:-lrt 23 | acc-pa_risc:-lrt 24 | gcc,windows:"-lole32 -loleaut32 -lpsapi -ladvapi32" 25 | hpux,gcc:"-Wl,+as,mpas" 26 | windows,clang:"-lole32 -loleaut32 -lpsapi -ladvapi32" 27 | linux:"-lrt" 28 | #cygwin with -std=c++XX does not include POSIX features, so always request them 29 | cygwin:_XOPEN_SOURCE=600 30 | ; 31 | 32 | rule test_all 33 | { 34 | local all_rules = ; 35 | 36 | for local fileb in [ glob *.cpp ] 37 | { 38 | all_rules += [ run $(fileb) ] ; 39 | } 40 | 41 | return $(all_rules) ; 42 | } 43 | 44 | test-suite interprocess_test : [ test_all r ] : multi ; 45 | 46 | -------------------------------------------------------------------------------- /test/adaptive_node_pool_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2007-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #define BOOST_CONTAINER_ADAPTIVE_NODE_POOL_CHECK_INVARIANTS 11 | #include "node_pool_test.hpp" 12 | #include 13 | #include 14 | 15 | using namespace boost::interprocess; 16 | typedef managed_shared_memory::segment_manager segment_manager_t; 17 | 18 | int main () 19 | { 20 | typedef ipcdetail::private_adaptive_node_pool 21 | node_pool_t; 22 | 23 | if(!test::test_all_node_pool()) 24 | return 1; 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /test/adaptive_pool_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #define BOOST_CONTAINER_ADAPTIVE_NODE_POOL_CHECK_INVARIANTS 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "print_container.hpp" 16 | #include "dummy_test_allocator.hpp" 17 | #include "movable_int.hpp" 18 | #include "list_test.hpp" 19 | #include "vector_test.hpp" 20 | 21 | using namespace boost::interprocess; 22 | 23 | //We will work with wide characters for shared memory objects 24 | //Alias an adaptive pool that allocates ints 25 | typedef adaptive_pool 26 | shmem_node_allocator_t; 27 | 28 | typedef ipcdetail::adaptive_pool_v1 29 | shmem_node_allocator_v1_t; 30 | 31 | namespace boost { 32 | namespace interprocess { 33 | 34 | //Explicit instantiations to catch compilation errors 35 | template class adaptive_pool; 36 | template class adaptive_pool; 37 | 38 | namespace ipcdetail { 39 | 40 | template class ipcdetail::adaptive_pool_v1; 41 | template class ipcdetail::adaptive_pool_v1; 42 | 43 | }}} 44 | 45 | //Alias list types 46 | typedef boost::container::list MyShmList; 47 | typedef boost::container::list MyShmListV1; 48 | 49 | //Alias vector types 50 | typedef boost::container::vector MyShmVector; 51 | typedef boost::container::vector MyShmVectorV1; 52 | 53 | int main () 54 | { 55 | if(test::list_test()) 56 | return 1; 57 | 58 | if(test::list_test()) 59 | return 1; 60 | 61 | if(test::vector_test()) 62 | return 1; 63 | 64 | if(test::vector_test()) 65 | return 1; 66 | 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /test/anonymous_shared_memory_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace boost::interprocess; 18 | 19 | int main () 20 | { 21 | BOOST_INTERPROCESS_TRY{ 22 | const std::size_t MemSize = 99999*2; 23 | { 24 | //Now check anonymous mapping 25 | mapped_region region(anonymous_shared_memory(MemSize)); 26 | 27 | //Write pattern 28 | unsigned char *pattern = static_cast(region.get_address()); 29 | for(std::size_t i = 0 30 | ;i < MemSize 31 | ;++i, ++pattern){ 32 | *pattern = static_cast(i); 33 | } 34 | 35 | //Check pattern 36 | pattern = static_cast(region.get_address()); 37 | for(std::size_t i = 0 38 | ;i < MemSize 39 | ;++i, ++pattern){ 40 | if(*pattern != static_cast(i)){ 41 | return 1; 42 | } 43 | } 44 | } 45 | } 46 | BOOST_INTERPROCESS_CATCH(std::exception &exc){ 47 | std::cout << "Unhandled exception: " << exc.what() << std::endl; 48 | return 1; 49 | } BOOST_INTERPROCESS_CATCH_END 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /test/boost_interprocess_check.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_TEST_CHECK_HEADER 12 | #define BOOST_INTERPROCESS_TEST_CHECK_HEADER 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | namespace boost { namespace interprocess { namespace test { 19 | 20 | #define BOOST_INTERPROCESS_CHECK( P ) \ 21 | if(!(P)) do{ assert(P); std::cout << "Failed: " << #P << " file: " << __FILE__ << " line : " << __LINE__ << std::endl; throw boost::interprocess::interprocess_exception(#P);}while(0) 22 | 23 | }}} //namespace boost { namespace interprocess { namespace test { 24 | 25 | #include 26 | 27 | #endif //BOOST_INTERPROCESS_TEST_CHECK_HEADER 28 | -------------------------------------------------------------------------------- /test/boost_use_windows_h.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2014-2014. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #define _WIN32_WINNT 0x0501 11 | #define BOOST_USE_WINDOWS_H 12 | 13 | #include 14 | 15 | #ifdef BOOST_INTERPROCESS_WINDOWS 16 | 17 | #include 18 | 19 | using namespace boost::interprocess; 20 | 21 | int main () 22 | { 23 | windows_shared_memory dummy; 24 | static_cast(dummy); 25 | return 0; 26 | } 27 | 28 | #else 29 | 30 | int main() 31 | { 32 | return 0; 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /test/cached_adaptive_pool_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #define BOOST_CONTAINER_ADAPTIVE_NODE_POOL_CHECK_INVARIANTS 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "print_container.hpp" 16 | #include "dummy_test_allocator.hpp" 17 | #include "movable_int.hpp" 18 | #include "list_test.hpp" 19 | #include "vector_test.hpp" 20 | 21 | using namespace boost::interprocess; 22 | 23 | //We will work with wide characters for shared memory objects 24 | //Alias an cached adaptive pool that allocates ints 25 | typedef cached_adaptive_pool 26 | 27 | cached_node_allocator_t; 28 | 29 | typedef ipcdetail::cached_adaptive_pool_v1 30 | 31 | cached_node_allocator_v1_t; 32 | 33 | namespace boost { 34 | namespace interprocess { 35 | 36 | //Explicit instantiations to catch compilation errors 37 | template class cached_adaptive_pool; 38 | template class cached_adaptive_pool; 39 | 40 | namespace ipcdetail { 41 | 42 | template class ipcdetail::cached_adaptive_pool_v1; 43 | template class ipcdetail::cached_adaptive_pool_v1; 44 | 45 | }}} 46 | 47 | //Alias list types 48 | typedef boost::container::list MyShmList; 49 | typedef boost::container::list MyShmListV1; 50 | 51 | //Alias vector types 52 | typedef boost::container::vector MyShmVector; 53 | typedef boost::container::vector MyShmVectorV1; 54 | 55 | int main () 56 | { 57 | if(test::list_test()) 58 | return 1; 59 | 60 | if(test::list_test()) 61 | return 1; 62 | 63 | if(test::vector_test()) 64 | return 1; 65 | 66 | if(test::vector_test()) 67 | return 1; 68 | 69 | return 0; 70 | } 71 | -------------------------------------------------------------------------------- /test/cached_node_allocator_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "print_container.hpp" 16 | #include "dummy_test_allocator.hpp" 17 | #include "movable_int.hpp" 18 | #include "list_test.hpp" 19 | #include "vector_test.hpp" 20 | 21 | using namespace boost::interprocess; 22 | 23 | //Alias an integer node allocator type 24 | typedef cached_node_allocator 25 | 26 | cached_node_allocator_t; 27 | typedef ipcdetail::cached_node_allocator_v1 28 | 29 | cached_node_allocator_v1_t; 30 | 31 | namespace boost { 32 | namespace interprocess { 33 | 34 | //Explicit instantiations to catch compilation errors 35 | template class cached_node_allocator; 36 | template class cached_node_allocator; 37 | 38 | namespace ipcdetail { 39 | 40 | template class ipcdetail::cached_node_allocator_v1; 41 | template class ipcdetail::cached_node_allocator_v1; 42 | 43 | }}} 44 | 45 | //Alias list types 46 | typedef boost::container::list MyShmList; 47 | typedef boost::container::list MyShmListV1; 48 | 49 | //Alias vector types 50 | typedef boost::container::vector MyShmVector; 51 | typedef boost::container::vector MyShmVectorV1; 52 | 53 | int main () 54 | { 55 | if(test::list_test()) 56 | return 1; 57 | if(test::list_test()) 58 | return 1; 59 | if(test::vector_test()) 60 | return 1; 61 | if(test::vector_test()) 62 | return 1; 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /test/condition_any_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "condition_test_template.hpp" 17 | 18 | using namespace boost::interprocess; 19 | 20 | int main () 21 | { 22 | if(!test::do_test_condition()) 23 | return 1; 24 | if(!test::do_test_condition()) 25 | return 1; 26 | if(!test::do_test_condition()) 27 | return 1; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /test/condition_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include 13 | #include 14 | #include "condition_test_template.hpp" 15 | 16 | using namespace boost::interprocess; 17 | 18 | int main () 19 | { 20 | if(!test::do_test_condition()) 21 | return 1; 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /test/file_lock_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #include 11 | #include 12 | #include 13 | #include "util.hpp" 14 | #include "mutex_test_template.hpp" 15 | #include "sharable_mutex_test_template.hpp" 16 | #include "get_process_id_name.hpp" 17 | #include 18 | #include //std::remove 19 | 20 | using namespace boost::interprocess; 21 | 22 | //This wrapper is necessary to have a default constructor 23 | //in generic mutex_test_template functions 24 | class file_lock_lock_test_wrapper 25 | : public boost::interprocess::file_lock 26 | { 27 | public: 28 | file_lock_lock_test_wrapper() 29 | : boost::interprocess::file_lock(get_filename().c_str()) 30 | {} 31 | }; 32 | 33 | int main () 34 | { 35 | //Destroy and create file 36 | { 37 | std::remove(get_filename().c_str()); 38 | std::ofstream file(get_filename().c_str()); 39 | if(!file){ 40 | return 1; 41 | } 42 | { 43 | file_lock flock(get_filename().c_str()); 44 | { 45 | scoped_lock sl(flock); 46 | } 47 | { 48 | scoped_lock sl(flock, try_to_lock); 49 | } 50 | { 51 | scoped_lock sl(flock, test::ptime_delay_ms(1)); 52 | } 53 | { 54 | scoped_lock sl(flock, test::boost_systemclock_delay_ms(1)); 55 | } 56 | { 57 | scoped_lock sl(flock, test::std_systemclock_delay_ms(1)); 58 | } 59 | } 60 | #if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) 61 | file_lock flock(get_wfilename().c_str()); 62 | #endif 63 | } 64 | { 65 | //Now test move semantics 66 | file_lock mapping(get_filename().c_str()); 67 | file_lock move_ctor(boost::move(mapping)); 68 | file_lock move_assign; 69 | move_assign = boost::move(move_ctor); 70 | mapping.swap(move_assign); 71 | } 72 | 73 | test::test_all_lock(); 74 | //test::test_all_mutex(); 75 | //test::test_all_sharable_mutex(); 76 | std::remove(get_filename().c_str()); 77 | 78 | return 0; 79 | } 80 | 81 | -------------------------------------------------------------------------------- /test/flat_map_index_allocation_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include "named_allocation_test_template.hpp" 13 | 14 | int main () 15 | { 16 | using namespace boost::interprocess; 17 | if(!test::test_named_allocation()){ 18 | return 1; 19 | } 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /test/include_but_no_use_windows_h.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2014-2014. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #include 11 | 12 | #ifdef BOOST_INTERPROCESS_WINDOWS 13 | #include 14 | 15 | #include 16 | 17 | using namespace boost::interprocess; 18 | 19 | int main () 20 | { 21 | windows_shared_memory dummy; 22 | static_cast(dummy); 23 | return 0; 24 | } 25 | 26 | #else 27 | 28 | int main() 29 | { 30 | return 0; 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /test/iset_index_allocation_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #include 11 | #include "named_allocation_test_template.hpp" 12 | 13 | int main () 14 | { 15 | using namespace boost::interprocess; 16 | if(!test::test_named_allocation()){ 17 | return 1; 18 | } 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /test/iunordered_set_index_allocation_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include "named_allocation_test_template.hpp" 13 | 14 | int main () 15 | { 16 | using namespace boost::interprocess; 17 | if(!test::test_named_allocation()){ 18 | return 1; 19 | } 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /test/list_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "dummy_test_allocator.hpp" 16 | #include "list_test.hpp" 17 | #include "movable_int.hpp" 18 | #include "emplace_test.hpp" 19 | 20 | using namespace boost::interprocess; 21 | 22 | typedef allocator ShmemAllocator; 23 | typedef boost::container::list MyList; 24 | 25 | //typedef allocator ShmemVolatileAllocator; 26 | //typedef boost::container::list MyVolatileList; 27 | 28 | typedef allocator ShmemMoveAllocator; 29 | typedef boost::container::list MyMoveList; 30 | 31 | typedef allocator ShmemCopyMoveAllocator; 32 | typedef boost::container::list MyCopyMoveList; 33 | 34 | typedef allocator ShmemCopyAllocator; 35 | typedef boost::container::list MyCopyList; 36 | 37 | int main () 38 | { 39 | if(test::list_test()) 40 | return 1; 41 | 42 | // if(test::list_test()) 43 | // return 1; 44 | 45 | if(test::list_test()) 46 | return 1; 47 | 48 | if(test::list_test()) 49 | return 1; 50 | 51 | if(test::list_test()) 52 | return 1; 53 | 54 | const test::EmplaceOptions Options = (test::EmplaceOptions)(test::EMPLACE_BACK | test::EMPLACE_FRONT | test::EMPLACE_BEFORE); 55 | 56 | if(!boost::interprocess::test::test_emplace, Options>()) 57 | return 1; 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /test/managed_force_native_emulation_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2024-2024. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #define BOOST_INTERPROCESS_FORCE_NATIVE_EMULATION 1 // This is important, doesn't crash otherwise. 12 | 13 | #include 14 | #include "get_process_id_name.hpp" 15 | 16 | using namespace boost::interprocess; 17 | 18 | int main() 19 | { 20 | const int MemSize = 65536; 21 | const char* const MemName = test::get_process_id_name(); 22 | 23 | { 24 | managed_shared_memory mshm(open_or_create, MemName, MemSize); 25 | shared_memory_object::remove(MemName); 26 | 27 | for (std::size_t i = 0; i != 1000; ++i) { 28 | mshm.deallocate(mshm.allocate(i)); 29 | } 30 | } //Force early destruction of shared memory 31 | 32 | return 0; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /test/map_index_allocation_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #define BOOST_CONTAINER_ADAPTIVE_NODE_POOL_CHECK_INVARIANTS 11 | #include 12 | #include "named_allocation_test_template.hpp" 13 | 14 | int main () 15 | { 16 | using namespace boost::interprocess; 17 | if(!test::test_named_allocation()){ 18 | return 1; 19 | } 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /test/mutex_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include 13 | #include "mutex_test_template.hpp" 14 | 15 | int main () 16 | { 17 | using namespace boost::interprocess; 18 | 19 | test::test_all_lock(); 20 | test::test_all_mutex(); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /test/mutex_timeout_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | // enable timeout feature 12 | #define BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS boost::interprocess::test::BaseMs 13 | #define BOOST_INTERPROCESS_ENABLE_TIMEOUT_WHEN_LOCKING 14 | 15 | #include "util.hpp" 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include "mutex_test_template.hpp" 21 | 22 | int main () 23 | { 24 | using namespace boost::interprocess; 25 | test::test_mutex_lock_timeout(); 26 | test::test_mutex_lock_timeout(); 27 | test::test_mutex_lock_timeout(); 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /test/named_condition_any_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include 13 | #include 14 | #include "condition_test_template.hpp" 15 | #include "named_creation_template.hpp" 16 | #include 17 | #include 18 | #include "get_process_id_name.hpp" 19 | #include "named_condition_test_helpers.hpp" 20 | 21 | #if defined(BOOST_INTERPROCESS_WINDOWS) 22 | #include 23 | #include 24 | #endif 25 | 26 | using namespace boost::interprocess; 27 | 28 | int main() 29 | { 30 | int ret; 31 | #if defined(BOOST_INTERPROCESS_WINDOWS) 32 | ret = test::test_named_condition(); 33 | if (ret) 34 | return ret; 35 | #endif 36 | ret = test::test_named_condition(); 37 | 38 | return ret; 39 | } 40 | -------------------------------------------------------------------------------- /test/named_condition_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include 13 | #include "named_condition_test_helpers.hpp" 14 | 15 | using namespace boost::interprocess; 16 | 17 | int main() 18 | { 19 | return test::test_named_condition(); 20 | } 21 | -------------------------------------------------------------------------------- /test/named_mutex_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include "named_mutex_test_helpers.hpp" 13 | 14 | using namespace boost::interprocess; 15 | 16 | int main() 17 | { 18 | return test::test_named_mutex(); 19 | } 20 | -------------------------------------------------------------------------------- /test/named_recursive_mutex_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include "named_mutex_test_helpers.hpp" 13 | 14 | using namespace boost::interprocess; 15 | 16 | int main() 17 | { 18 | return test::test_named_recursive_mutex(); 19 | } 20 | -------------------------------------------------------------------------------- /test/named_semaphore_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include "named_semaphore_test_helpers.hpp" 13 | 14 | using namespace boost::interprocess; 15 | 16 | int main() 17 | { 18 | return test::test_named_semaphore(); 19 | } 20 | -------------------------------------------------------------------------------- /test/named_sharable_mutex_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include "mutex_test_template.hpp" 12 | #include "sharable_mutex_test_template.hpp" 13 | #include "named_creation_template.hpp" 14 | #include 15 | #include 16 | #include "get_process_id_name.hpp" 17 | 18 | using namespace boost::interprocess; 19 | 20 | int main () 21 | { 22 | int ret = 0; 23 | BOOST_INTERPROCESS_TRY{ 24 | named_sharable_mutex::remove(test::get_process_id_name()); 25 | test::test_named_creation< test::named_sync_creation_test_wrapper >(); 26 | #if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) 27 | test::test_named_creation< test::named_sync_creation_test_wrapper_w >(); 28 | #endif //defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) 29 | test::test_all_lock< test::named_sync_wrapper >(); 30 | test::test_all_mutex >(); 31 | test::test_all_sharable_mutex >(); 32 | } 33 | BOOST_INTERPROCESS_CATCH(std::exception &ex){ 34 | std::cout << ex.what() << std::endl; 35 | ret = 1; 36 | } BOOST_INTERPROCESS_CATCH_END 37 | named_sharable_mutex::remove(test::get_process_id_name()); 38 | return ret; 39 | } 40 | -------------------------------------------------------------------------------- /test/named_upgradable_mutex_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include "mutex_test_template.hpp" 12 | #include "sharable_mutex_test_template.hpp" 13 | #include "named_creation_template.hpp" 14 | #include 15 | #include 16 | #include "get_process_id_name.hpp" 17 | 18 | using namespace boost::interprocess; 19 | 20 | int main () 21 | { 22 | int ret = 0; 23 | BOOST_INTERPROCESS_TRY{ 24 | named_upgradable_mutex::remove(test::get_process_id_name()); 25 | test::test_named_creation< test::named_sync_creation_test_wrapper >(); 26 | #if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) 27 | test::test_named_creation< test::named_sync_creation_test_wrapper_w >(); 28 | #endif 29 | test::test_all_lock< test::named_sync_wrapper >(); 30 | test::test_all_mutex >(); 31 | test::test_all_sharable_mutex >(); 32 | } 33 | BOOST_INTERPROCESS_CATCH(std::exception &ex){ 34 | std::cout << ex.what() << std::endl; 35 | ret = 1; 36 | } BOOST_INTERPROCESS_CATCH_END 37 | named_upgradable_mutex::remove(test::get_process_id_name()); 38 | return ret; 39 | } 40 | -------------------------------------------------------------------------------- /test/node_allocator_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "print_container.hpp" 16 | #include "dummy_test_allocator.hpp" 17 | #include "movable_int.hpp" 18 | #include "list_test.hpp" 19 | #include "vector_test.hpp" 20 | 21 | using namespace boost::interprocess; 22 | 23 | //We will work with wide characters for shared memory objects 24 | //Alias an integer node allocator type 25 | typedef node_allocator 26 | shmem_node_allocator_t; 27 | typedef ipcdetail::node_allocator_v1 28 | shmem_node_allocator_v1_t; 29 | 30 | namespace boost { 31 | namespace interprocess { 32 | 33 | //Explicit instantiations to catch compilation errors 34 | template class node_allocator; 35 | template class node_allocator; 36 | 37 | namespace ipcdetail { 38 | 39 | template class ipcdetail::node_allocator_v1; 40 | template class ipcdetail::node_allocator_v1; 41 | 42 | }}} 43 | 44 | //Alias list types 45 | typedef boost::container::list MyShmList; 46 | typedef boost::container::list MyShmListV1; 47 | 48 | //Alias vector types 49 | typedef boost::container::vector MyShmVector; 50 | typedef boost::container::vector MyShmVectorV1; 51 | 52 | int main () 53 | { 54 | if(test::list_test()) 55 | return 1; 56 | if(test::list_test()) 57 | return 1; 58 | if(test::vector_test()) 59 | return 1; 60 | if(test::vector_test()) 61 | return 1; 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /test/node_pool_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2007-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #include "node_pool_test.hpp" 11 | #include 12 | 13 | using namespace boost::interprocess; 14 | 15 | typedef managed_shared_memory::segment_manager segment_manager_t; 16 | 17 | int main () 18 | { 19 | typedef ipcdetail::private_node_pool 20 | node_pool_t; 21 | 22 | if(!test::test_all_node_pool()) 23 | return 1; 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /test/null_index_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "get_process_id_name.hpp" 18 | 19 | using namespace boost::interprocess; 20 | typedef basic_managed_shared_memory 21 | , null_index> 22 | my_shared_objects_t; 23 | 24 | int main () 25 | { 26 | //Create shared memory 27 | shared_memory_object::remove(test::get_process_id_name()); 28 | { 29 | my_shared_objects_t segment 30 | (create_only, 31 | test::get_process_id_name(), //segment name 32 | 65536); //segment size in bytes 33 | 34 | //Allocate a portion of the segment 35 | void * shptr = segment.allocate(1024/*bytes to allocate*/); 36 | my_shared_objects_t::handle_t handle = segment.get_handle_from_address(shptr); 37 | if(!segment.belongs_to_segment(shptr)){ 38 | return 1; 39 | } 40 | if(shptr != segment.get_address_from_handle(handle)){ 41 | return 1; 42 | } 43 | 44 | segment.deallocate(shptr); 45 | } 46 | shared_memory_object::remove(test::get_process_id_name()); 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /test/print_container.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef BOOST_INTERPROCESS_TEST_PRINTCONTAINER_HPP 12 | #define BOOST_INTERPROCESS_TEST_PRINTCONTAINER_HPP 13 | 14 | #include 15 | #include 16 | 17 | namespace boost{ 18 | namespace interprocess{ 19 | namespace test{ 20 | 21 | template 22 | void PrintContents(const Container &cont, const char *contName) 23 | { 24 | std::cout<< "Printing contents of " << contName << std::endl; 25 | typename Container::iterator b(cont.begin()), e(cont.end()); 26 | for(; b != e; ++b){ 27 | std::cout << *b << " "; 28 | } 29 | std::cout<< std::endl << std::endl; 30 | } 31 | 32 | //Function to dump data 33 | template 34 | void PrintContainers(MyShmCont *shmcont, MyStdCont *stdcont) 35 | { 36 | typename MyShmCont::iterator itshm = shmcont->begin(), itshmend = shmcont->end(); 37 | typename MyStdCont::iterator itstd = stdcont->begin(), itstdend = stdcont->end(); 38 | 39 | std::cout << "MyShmCont" << std::endl; 40 | for(; itshm != itshmend; ++itshm){ 41 | std::cout << *itshm << std::endl; 42 | } 43 | std::cout << "MyStdCont" << std::endl; 44 | 45 | for(; itstd != itstdend; ++itstd){ 46 | std::cout << *itstd << std::endl; 47 | } 48 | } 49 | 50 | } //namespace test{ 51 | } //namespace interprocess{ 52 | } //namespace boost{ 53 | 54 | #include 55 | 56 | #endif //#ifndef BOOST_INTERPROCESS_TEST_PRINTCONTAINER_HPP 57 | -------------------------------------------------------------------------------- /test/private_adaptive_pool_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "print_container.hpp" 16 | #include "dummy_test_allocator.hpp" 17 | #include "movable_int.hpp" 18 | #include "list_test.hpp" 19 | #include "vector_test.hpp" 20 | 21 | using namespace boost::interprocess; 22 | 23 | //We will work with wide characters for shared memory objects 24 | //Alias a private adaptive pool that allocates ints 25 | typedef private_adaptive_pool 26 | priv_node_allocator_t; 27 | typedef ipcdetail::private_adaptive_pool_v1 28 | priv_node_allocator_v1_t; 29 | 30 | namespace boost { 31 | namespace interprocess { 32 | 33 | //Explicit instantiations to catch compilation errors 34 | template class private_adaptive_pool; 35 | template class private_adaptive_pool; 36 | 37 | namespace ipcdetail { 38 | 39 | template class ipcdetail::private_adaptive_pool_v1; 40 | template class ipcdetail::private_adaptive_pool_v1; 41 | 42 | }}} 43 | 44 | //Alias list types 45 | typedef boost::container::list MyShmList; 46 | typedef boost::container::list MyShmListV1; 47 | 48 | //Alias vector types 49 | typedef boost::container::vector MyShmVector; 50 | typedef boost::container::vector MyShmVectorV1; 51 | 52 | int main () 53 | { 54 | if(test::list_test(false)) 55 | return 1; 56 | if(test::list_test(false)) 57 | return 1; 58 | if(test::vector_test()) 59 | return 1; 60 | if(test::vector_test()) 61 | return 1; 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /test/private_node_allocator_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "print_container.hpp" 16 | #include "dummy_test_allocator.hpp" 17 | #include "movable_int.hpp" 18 | #include "list_test.hpp" 19 | #include "vector_test.hpp" 20 | 21 | using namespace boost::interprocess; 22 | 23 | //We will work with wide characters for shared memory objects 24 | //Alias an integer node allocator type 25 | typedef private_node_allocator 26 | priv_node_allocator_t; 27 | typedef ipcdetail::private_node_allocator_v1 28 | priv_node_allocator_v1_t; 29 | 30 | namespace boost { 31 | namespace interprocess { 32 | 33 | //Explicit instantiations to catch compilation errors 34 | template class private_node_allocator; 35 | template class private_node_allocator; 36 | 37 | namespace ipcdetail { 38 | 39 | template class ipcdetail::private_node_allocator_v1; 40 | template class ipcdetail::private_node_allocator_v1; 41 | 42 | }}} 43 | 44 | //Alias list types 45 | typedef boost::container::list MyShmList; 46 | typedef boost::container::list MyShmListV1; 47 | 48 | //Alias vector types 49 | typedef boost::container::vector MyShmVector; 50 | typedef boost::container::vector MyShmVectorV1; 51 | 52 | int main () 53 | { 54 | if(test::list_test(false)) 55 | return 1; 56 | if(test::list_test(false)) 57 | return 1; 58 | if(test::vector_test()) 59 | return 1; 60 | if(test::vector_test()) 61 | return 1; 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /test/recursive_mutex_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include 13 | #include 14 | #include "mutex_test_template.hpp" 15 | 16 | int main () 17 | { 18 | using namespace boost::interprocess; 19 | test::test_all_lock(); 20 | test::test_all_mutex(); 21 | test::test_all_recursive_lock(); 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /test/robust_emulation_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2010-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #include "robust_mutex_test.hpp" 11 | #include 12 | #include 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | using namespace boost::interprocess; 17 | return test::robust_mutex_test 18 | < ipcdetail::robust_spin_mutex >(argc, argv); 19 | } 20 | -------------------------------------------------------------------------------- /test/robust_recursive_emulation_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2010-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #include "robust_mutex_test.hpp" 11 | #include 12 | #include 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | using namespace boost::interprocess; 17 | 18 | return test::robust_mutex_test 19 | < ipcdetail::robust_spin_mutex >(argc, argv); 20 | } 21 | -------------------------------------------------------------------------------- /test/segment_manager_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2019. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #define BOOST_INTERPROCESS_SEGMENT_MANAGER_ABI 2 12 | #include "segment_manager_test.hpp" 13 | -------------------------------------------------------------------------------- /test/segment_manager_v1_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2019. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #define BOOST_INTERPROCESS_SEGMENT_MANAGER_ABI 1 12 | #include "segment_manager_test.hpp" 13 | -------------------------------------------------------------------------------- /test/semaphore_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include "semaphore_test_template.hpp" 13 | 14 | int main() 15 | { 16 | using namespace boost::interprocess; 17 | return test::test_all_semaphore(); 18 | } 19 | -------------------------------------------------------------------------------- /test/sharable_mutex_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include "mutex_test_template.hpp" 12 | #include "sharable_mutex_test_template.hpp" 13 | #include 14 | #include 15 | #include 16 | #include "util.hpp" 17 | 18 | int main () 19 | { 20 | using namespace boost::interprocess; 21 | 22 | test::test_all_lock(); 23 | test::test_all_mutex(); 24 | test::test_all_sharable_mutex(); 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /test/shm_named_condition_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include "named_condition_test_helpers.hpp" 12 | #include 13 | #include 14 | 15 | using namespace boost::interprocess; 16 | 17 | int main() 18 | { 19 | return test::test_named_condition(); 20 | } 21 | -------------------------------------------------------------------------------- /test/shm_named_mutex_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include "named_mutex_test_helpers.hpp" 12 | #include 13 | 14 | using namespace boost::interprocess; 15 | 16 | int main() 17 | { 18 | return test::test_named_mutex(); 19 | } 20 | -------------------------------------------------------------------------------- /test/shm_named_recursive_mutex_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include "named_mutex_test_helpers.hpp" 12 | #include 13 | 14 | using namespace boost::interprocess; 15 | 16 | int main() 17 | { 18 | return test::test_named_recursive_mutex(); 19 | } 20 | -------------------------------------------------------------------------------- /test/shm_named_semaphore_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include "named_semaphore_test_helpers.hpp" 13 | 14 | using namespace boost::interprocess; 15 | 16 | int main() 17 | { 18 | return test::test_named_semaphore(); 19 | } 20 | -------------------------------------------------------------------------------- /test/slist_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "dummy_test_allocator.hpp" 15 | #include "list_test.hpp" 16 | #include "movable_int.hpp" 17 | #include "emplace_test.hpp" 18 | 19 | using namespace boost::interprocess; 20 | 21 | typedef allocator ShmemAllocator; 22 | typedef boost::container::slist MyList; 23 | 24 | 25 | 26 | typedef allocator ShmemMoveAllocator; 27 | typedef boost::container::slist MyMoveList; 28 | 29 | typedef allocator ShmemCopyMoveAllocator; 30 | typedef boost::container::slist MyCopyMoveList; 31 | 32 | typedef allocator ShmemCopyAllocator; 33 | typedef boost::container::slist MyCopyList; 34 | 35 | int main () 36 | { 37 | if(test::list_test()) 38 | return 1; 39 | 40 | if(test::list_test()) 41 | return 1; 42 | 43 | if(test::list_test()) 44 | return 1; 45 | 46 | if(test::list_test()) 47 | return 1; 48 | 49 | const test::EmplaceOptions Options = (test::EmplaceOptions) 50 | (test::EMPLACE_FRONT | test::EMPLACE_AFTER | test::EMPLACE_BEFORE | test::EMPLACE_AFTER); 51 | 52 | if(!boost::interprocess::test::test_emplace 53 | < boost::container::slist, Options>()) 54 | return 1; 55 | return 0; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /test/spin_condition_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include "condition_test_template.hpp" 13 | 14 | #include 15 | #include 16 | 17 | using namespace boost::interprocess; 18 | 19 | int main () 20 | { 21 | if(!test::do_test_condition()) 22 | return 1; 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /test/spin_mutex_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include "mutex_test_template.hpp" 13 | 14 | #include 15 | 16 | int main () 17 | { 18 | using namespace boost::interprocess; 19 | 20 | test::test_all_lock(); 21 | test::test_all_mutex(); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /test/spin_recursive_mutex_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include 13 | #include 14 | #include "mutex_test_template.hpp" 15 | 16 | int main () 17 | { 18 | using namespace boost::interprocess; 19 | // 20 | test::test_all_lock(); 21 | test::test_all_mutex(); 22 | test::test_all_recursive_lock(); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /test/spin_semaphore_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include "semaphore_test_template.hpp" 13 | 14 | int main () 15 | { 16 | using namespace boost::interprocess; 17 | return test::test_all_semaphore(); 18 | } 19 | -------------------------------------------------------------------------------- /test/winapi_condition_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #include "condition_test_template.hpp" 13 | 14 | #if defined(BOOST_INTERPROCESS_WINDOWS) 15 | #include 16 | #include 17 | 18 | using namespace boost::interprocess; 19 | 20 | int main () 21 | { 22 | if(!test::do_test_condition()) 23 | return 1; 24 | return 0; 25 | } 26 | 27 | #else 28 | int main() 29 | { 30 | return 0; 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /test/winapi_mutex_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | 13 | #if defined(BOOST_INTERPROCESS_WINDOWS) 14 | #include 15 | #include "mutex_test_template.hpp" 16 | 17 | int main () 18 | { 19 | using namespace boost::interprocess; 20 | 21 | test::test_all_lock(); 22 | test::test_all_mutex(); 23 | return 0; 24 | } 25 | #else //BOOST_INTERPROCESS_WINDOWS 26 | 27 | int main() 28 | { 29 | return 0; 30 | } 31 | 32 | #endif //BOOST_INTERPROCESS_WINDOWS 33 | -------------------------------------------------------------------------------- /test/winapi_named_condition_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | 13 | #ifdef BOOST_INTERPROCESS_WINDOWS 14 | #include "named_condition_test_helpers.hpp" 15 | 16 | #include 17 | #include 18 | 19 | using namespace boost::interprocess; 20 | 21 | int main() 22 | { 23 | return test::test_named_condition(); 24 | } 25 | 26 | #else 27 | 28 | int main() 29 | { 30 | return 0; 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /test/winapi_named_mutex_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | 13 | #ifdef BOOST_INTERPROCESS_WINDOWS 14 | 15 | #include "named_mutex_test_helpers.hpp" 16 | #include 17 | 18 | using namespace boost::interprocess; 19 | 20 | int main() 21 | { 22 | return test::test_named_mutex(); 23 | } 24 | 25 | #else 26 | 27 | int main() 28 | { 29 | return 0; 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /test/winapi_named_recursive_mutex_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | 13 | #ifdef BOOST_INTERPROCESS_WINDOWS 14 | 15 | #include "named_mutex_test_helpers.hpp" 16 | #include 17 | 18 | using namespace boost::interprocess; 19 | 20 | int main() 21 | { 22 | return test::test_named_recursive_mutex(); 23 | } 24 | 25 | #else 26 | 27 | int main() 28 | { 29 | return 0; 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /test/winapi_named_semaphore_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | 13 | #ifdef BOOST_INTERPROCESS_WINDOWS 14 | #include 15 | #include "named_semaphore_test_helpers.hpp" 16 | 17 | using namespace boost::interprocess; 18 | 19 | int main() 20 | { 21 | return test::test_named_semaphore(); 22 | } 23 | 24 | #else 25 | 26 | int main() 27 | { 28 | return 0; 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /test/winapi_recursive_mutex_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #if defined(BOOST_INTERPROCESS_WINDOWS) 13 | #include 14 | #include "mutex_test_template.hpp" 15 | 16 | int main () 17 | { 18 | using namespace boost::interprocess; 19 | // 20 | test::test_all_lock(); 21 | test::test_all_mutex(); 22 | test::test_all_recursive_lock(); 23 | 24 | return 0; 25 | } 26 | #else 27 | 28 | int main() 29 | { 30 | return 0; 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /test/winapi_semaphore_test.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org/libs/interprocess for documentation. 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #include 12 | #ifdef BOOST_INTERPROCESS_WINDOWS 13 | #include 14 | #include "semaphore_test_template.hpp" 15 | 16 | int main() 17 | { 18 | using namespace boost::interprocess; 19 | return test::test_all_semaphore(); 20 | } 21 | #else 22 | 23 | int main() 24 | { 25 | return 0; 26 | } 27 | 28 | #endif 29 | --------------------------------------------------------------------------------