diff options
Diffstat (limited to 'libs/interprocess/example')
33 files changed, 99 insertions, 99 deletions
diff --git a/libs/interprocess/example/Jamfile.v2 b/libs/interprocess/example/Jamfile.v2 index 622ce6aeca..b2d7194264 100644 --- a/libs/interprocess/example/Jamfile.v2 +++ b/libs/interprocess/example/Jamfile.v2 @@ -1,14 +1,14 @@ # Boost Interprocess Library Example Jamfile # (C) Copyright Ion Gaztanaga 2006. -# Use, modification and distribution are subject to the -# Boost Software License, Version 1.0. (See accompanying file +# Use, modification and distribution are subject to the +# Boost Software License, Version 1.0. (See accompanying file # LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) # Adapted from John Maddock's TR1 Jamfile.v2 # Copyright John Maddock 2005. -# Use, modification and distribution are subject to the -# Boost Software License, Version 1.0. (See accompanying file +# Use, modification and distribution are subject to the +# Boost Software License, Version 1.0. (See accompanying file # LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) # this rule enumerates through all the sources and invokes @@ -25,7 +25,7 @@ rule test_all : # additional args <toolset>acc:<linkflags>-lrt <toolset>acc-pa_risc:<linkflags>-lrt - <toolset>gcc-mingw:<linkflags>"-lole32 -loleaut32 -lpsapi -ladvapi32" + <toolset>gcc-mingw:<linkflags>"-lole32 -loleaut32 -lpsapi -ladvapi32" <host-os>hpux,<toolset>gcc:<linkflags>"-Wl,+as,mpas" : # test-files : # requirements @@ -40,7 +40,7 @@ rule test_all : # requirements <toolset>acc:<linkflags>-lrt <toolset>acc-pa_risc:<linkflags>-lrt - <toolset>gcc-mingw:<linkflags>"-lole32 -loleaut32 -lpsapi -ladvapi32" + <toolset>gcc-mingw:<linkflags>"-lole32 -loleaut32 -lpsapi -ladvapi32" <host-os>hpux,<toolset>gcc:<linkflags>"-Wl,+as,mpas" ] ; } @@ -48,4 +48,4 @@ rule test_all return $(all_rules) ; } -test-suite interprocess_example : [ test_all r ] : <threading>multi ;
\ No newline at end of file +test-suite interprocess_example : [ test_all r ] : <threading>multi ; diff --git a/libs/interprocess/example/doc_adaptive_pool.cpp b/libs/interprocess/example/doc_adaptive_pool.cpp index 539b1a6534..2a1feb3c76 100644 --- a/libs/interprocess/example/doc_adaptive_pool.cpp +++ b/libs/interprocess/example/doc_adaptive_pool.cpp @@ -46,7 +46,7 @@ int main () managed_shared_memory segment(create_only,test::get_process_id_name(), 65536); #else //-> - managed_shared_memory segment(create_only, + managed_shared_memory segment(create_only, "MySharedMemory", //segment name 65536); //<- diff --git a/libs/interprocess/example/doc_allocator.cpp b/libs/interprocess/example/doc_allocator.cpp index 40809f31d4..febff5e570 100644 --- a/libs/interprocess/example/doc_allocator.cpp +++ b/libs/interprocess/example/doc_allocator.cpp @@ -46,7 +46,7 @@ int main () managed_shared_memory segment(create_only,test::get_process_id_name(), 65536); #else //-> - managed_shared_memory segment(create_only, + managed_shared_memory segment(create_only, "MySharedMemory", //segment name 65536); //<- diff --git a/libs/interprocess/example/doc_anonymous_shared_memory.cpp b/libs/interprocess/example/doc_anonymous_shared_memory.cpp index a8da7469d7..2285f5e4f3 100644 --- a/libs/interprocess/example/doc_anonymous_shared_memory.cpp +++ b/libs/interprocess/example/doc_anonymous_shared_memory.cpp @@ -23,7 +23,7 @@ int main () //Write all the memory to 1 std::memset(region.get_address(), 1, region.get_size()); - + //The segment is unmapped when "region" goes out of scope } catch(interprocess_exception &ex){ diff --git a/libs/interprocess/example/doc_bufferstream.cpp b/libs/interprocess/example/doc_bufferstream.cpp index 2d4e9c0bdd..310a842001 100644 --- a/libs/interprocess/example/doc_bufferstream.cpp +++ b/libs/interprocess/example/doc_bufferstream.cpp @@ -48,7 +48,7 @@ int main () managed_shared_memory segment(create_only,test::get_process_id_name(), 65536); #else //-> - managed_shared_memory segment(create_only, + managed_shared_memory segment(create_only, "MySharedMemory", //segment name 65536); //<- @@ -64,7 +64,7 @@ int main () const std::size_t BufferSize = 100*5; //Allocate a buffer in shared memory to write data - char *my_cstring = + char *my_cstring = segment.construct<char>("MyCString")[BufferSize](0); bufferstream mybufstream(my_cstring, BufferSize); @@ -82,7 +82,7 @@ int main () std::istream_iterator<int> it(mybufstream), itend; std::copy(it, itend, std::back_inserter(data2)); - //This extraction should have ended will fail error since + //This extraction should have ended will fail error since //the numbers formatted in the buffer end before the end //of the buffer. (Otherwise it would trigger eofbit) assert(mybufstream.fail()); @@ -93,7 +93,7 @@ int main () //Clear errors and rewind mybufstream.clear(); mybufstream.seekp(0, std::ios::beg); - + //Now write again the data trying to do a buffer overflow for(int i = 0, m = data.size()*5; i < m; ++i){ mybufstream << data[i%5] << std::endl; diff --git a/libs/interprocess/example/doc_cached_adaptive_pool.cpp b/libs/interprocess/example/doc_cached_adaptive_pool.cpp index 67344141ed..421b16153f 100644 --- a/libs/interprocess/example/doc_cached_adaptive_pool.cpp +++ b/libs/interprocess/example/doc_cached_adaptive_pool.cpp @@ -46,7 +46,7 @@ int main () managed_shared_memory segment(create_only,test::get_process_id_name(), 65536); #else //-> - managed_shared_memory segment(create_only, + managed_shared_memory segment(create_only, "MySharedMemory", //segment name 65536); //<- diff --git a/libs/interprocess/example/doc_cached_node_allocator.cpp b/libs/interprocess/example/doc_cached_node_allocator.cpp index da17090f54..b89df48738 100644 --- a/libs/interprocess/example/doc_cached_node_allocator.cpp +++ b/libs/interprocess/example/doc_cached_node_allocator.cpp @@ -46,7 +46,7 @@ int main () managed_shared_memory segment(create_only, test::get_process_id_name(), 65536); #else //-> - managed_shared_memory segment(create_only, + managed_shared_memory segment(create_only, "MySharedMemory", //segment name 65536); //<- diff --git a/libs/interprocess/example/doc_cont.cpp b/libs/interprocess/example/doc_cont.cpp index e419923150..f6099228fe 100644 --- a/libs/interprocess/example/doc_cont.cpp +++ b/libs/interprocess/example/doc_cont.cpp @@ -54,7 +54,7 @@ int main () //-> //Alias an STL-like allocator of ints that allocates ints from the segment - typedef allocator<int, managed_shared_memory::segment_manager> + typedef allocator<int, managed_shared_memory::segment_manager> ShmemAllocator; //Alias a vector that uses the previous STL-like allocator @@ -67,14 +67,14 @@ int main () //Initialize the STL-like allocator const ShmemAllocator alloc_inst (segment.get_segment_manager()); - //Construct the vector in the shared memory segment with the STL-like allocator + //Construct the vector in the shared memory segment with the STL-like allocator //from a range of iterators - MyVector *myvector = + MyVector *myvector = segment.construct<MyVector> ("MyVector")/*object name*/ (begVal /*first ctor parameter*/, - endVal /*second ctor parameter*/, - alloc_inst /*third ctor parameter*/); + endVal /*second ctor parameter*/, + alloc_inst /*third ctor parameter*/); //Use vector as your want std::sort(myvector->rbegin(), myvector->rend()); diff --git a/libs/interprocess/example/doc_file_mapping.cpp b/libs/interprocess/example/doc_file_mapping.cpp index a00b8e3c79..a3fa06f668 100644 --- a/libs/interprocess/example/doc_file_mapping.cpp +++ b/libs/interprocess/example/doc_file_mapping.cpp @@ -44,15 +44,15 @@ int main(int argc, char *argv[]) { //Create a file file_mapping::remove(FileName); std::filebuf fbuf; - fbuf.open(FileName, std::ios_base::in | std::ios_base::out - | std::ios_base::trunc | std::ios_base::binary); + fbuf.open(FileName, std::ios_base::in | std::ios_base::out + | std::ios_base::trunc | std::ios_base::binary); //Set the size fbuf.pubseekoff(FileSize-1, std::ios_base::beg); fbuf.sputc(0); } //Remove on exit - struct file_remove + struct file_remove { file_remove(const char *FileName) : FileName_(FileName) {} @@ -109,10 +109,10 @@ int main(int argc, char *argv[]) std::filebuf fbuf; //<- #if 1 - fbuf.open(argv[2], std::ios_base::in | std::ios_base::binary); + fbuf.open(argv[2], std::ios_base::in | std::ios_base::binary); #else //-> - fbuf.open(FileName, std::ios_base::in | std::ios_base::binary); + fbuf.open(FileName, std::ios_base::in | std::ios_base::binary); //<- #endif //-> diff --git a/libs/interprocess/example/doc_intrusive.cpp b/libs/interprocess/example/doc_intrusive.cpp index a383f96e2f..7f50e156b1 100644 --- a/libs/interprocess/example/doc_intrusive.cpp +++ b/libs/interprocess/example/doc_intrusive.cpp @@ -62,13 +62,13 @@ class reference_counted_class //A class that has an intrusive pointer to reference_counted_class class intrusive_ptr_owner { - typedef intrusive_ptr<N::reference_counted_class, + typedef intrusive_ptr<N::reference_counted_class, offset_ptr<void> > intrusive_ptr_t; intrusive_ptr_t m_intrusive_ptr; public: //Takes a pointer to the reference counted class - intrusive_ptr_owner(N::reference_counted_class *ptr) + intrusive_ptr_owner(N::reference_counted_class *ptr) : m_intrusive_ptr(ptr){} }; @@ -105,12 +105,12 @@ int main() //-> //Create the unique reference counted object in shared memory - N::reference_counted_class *ref_counted = + N::reference_counted_class *ref_counted = shmem.construct<N::reference_counted_class> ("ref_counted")(shmem.get_segment_manager()); //Create an array of ten intrusive pointer owners in shared memory - intrusive_ptr_owner *intrusive_owner_array = + intrusive_ptr_owner *intrusive_owner_array = shmem.construct<intrusive_ptr_owner> (anonymous_instance)[10](ref_counted); diff --git a/libs/interprocess/example/doc_ipc_message.cpp b/libs/interprocess/example/doc_ipc_message.cpp index 5ff3f741ac..ecc6d14942 100644 --- a/libs/interprocess/example/doc_ipc_message.cpp +++ b/libs/interprocess/example/doc_ipc_message.cpp @@ -22,7 +22,7 @@ int main (int argc, char *argv[]) using namespace boost::interprocess; if(argc == 1){ //Parent process //Remove shared memory on construction and destruction - struct shm_remove + struct shm_remove { //<- #if 1 @@ -59,7 +59,7 @@ int main (int argc, char *argv[]) if(free_memory <= segment.get_free_memory()) return 1; - //An handle from the base address can identify any byte of the shared + //An handle from the base address can identify any byte of the shared //memory segment even if it is mapped in different base addresses managed_shared_memory::handle_t handle = segment.get_handle_from_address(shptr); std::stringstream s; @@ -87,7 +87,7 @@ int main (int argc, char *argv[]) #endif //-> - //An handle from the base address can identify any byte of the shared + //An handle from the base address can identify any byte of the shared //memory segment even if it is mapped in different base addresses managed_shared_memory::handle_t handle = 0; diff --git a/libs/interprocess/example/doc_managed_aligned_allocation.cpp b/libs/interprocess/example/doc_managed_aligned_allocation.cpp index b3c0be85fa..e15c569c7e 100644 --- a/libs/interprocess/example/doc_managed_aligned_allocation.cpp +++ b/libs/interprocess/example/doc_managed_aligned_allocation.cpp @@ -111,7 +111,7 @@ int main() m_segment.deallocate(ptrs.back()); ptrs.pop_back(); ptrs.push_back(m_segment.allocate_aligned(128, 128)); - } + } return 0; } */ diff --git a/libs/interprocess/example/doc_managed_copy_on_write.cpp b/libs/interprocess/example/doc_managed_copy_on_write.cpp index 26d5d41b46..1d7d8baa79 100644 --- a/libs/interprocess/example/doc_managed_copy_on_write.cpp +++ b/libs/interprocess/example/doc_managed_copy_on_write.cpp @@ -81,7 +81,7 @@ int main() { //Now create a read-only version managed_mapped_file managed_file_ro(open_read_only, ManagedFile); - + //Check the original is intact if(!managed_file_ro.find<int>("MyInt").first && managed_file_ro.find<int>("MyInt2").first) throw int(0); diff --git a/libs/interprocess/example/doc_managed_external_buffer.cpp b/libs/interprocess/example/doc_managed_external_buffer.cpp index cc7c41ded7..2847df8771 100644 --- a/libs/interprocess/example/doc_managed_external_buffer.cpp +++ b/libs/interprocess/example/doc_managed_external_buffer.cpp @@ -54,9 +54,9 @@ int main() //from the first one and duplicate all the data. static boost::aligned_storage<memsize>::type static_buffer2; std::memcpy(&static_buffer2, &static_buffer, memsize); - + //Now open the duplicated managed memory passing the memory as argument - wmanaged_external_buffer objects_in_static_memory2 + wmanaged_external_buffer objects_in_static_memory2 (open_only, &static_buffer2, memsize); //Check that "MyList" has been duplicated in the second buffer diff --git a/libs/interprocess/example/doc_managed_heap_memory.cpp b/libs/interprocess/example/doc_managed_heap_memory.cpp index 91ccab4750..1d72ce5a4f 100644 --- a/libs/interprocess/example/doc_managed_heap_memory.cpp +++ b/libs/interprocess/example/doc_managed_heap_memory.cpp @@ -16,7 +16,7 @@ #include <cstddef> using namespace boost::interprocess; -typedef list<int, allocator<int, managed_heap_memory::segment_manager> > +typedef list<int, allocator<int, managed_heap_memory::segment_manager> > MyList; int main () @@ -50,7 +50,7 @@ int main () //use previously obtained handle to find the new pointer. mylist = static_cast<MyList *> (heap_memory.get_address_from_handle(list_handle)); - + //Fill list until there is no more memory in the buffer try{ while(1) { @@ -61,7 +61,7 @@ int main () //memory is full } - //Let's obtain the new size of the list + //Let's obtain the new size of the list MyList::size_type new_size = mylist->size(); assert(new_size > old_size); diff --git a/libs/interprocess/example/doc_managed_mapped_file.cpp b/libs/interprocess/example/doc_managed_mapped_file.cpp index a19d389b42..7b4fac3542 100644 --- a/libs/interprocess/example/doc_managed_mapped_file.cpp +++ b/libs/interprocess/example/doc_managed_mapped_file.cpp @@ -21,11 +21,11 @@ //-> using namespace boost::interprocess; -typedef list<int, allocator<int, managed_mapped_file::segment_manager> > +typedef list<int, allocator<int, managed_mapped_file::segment_manager> > MyList; int main () -{ +{ //Define file names //<- #if 1 @@ -77,7 +77,7 @@ int main () //so use previously obtained handle to find the new pointer. MyList *mylist = static_cast<MyList *> (mfile_memory.get_address_from_handle(list_handle)); - + //Fill list until there is no more room in the file try{ while(1) { @@ -88,7 +88,7 @@ int main () //mapped file is full } - //Let's obtain the new size of the list + //Let's obtain the new size of the list MyList::size_type new_size = mylist->size(); assert(new_size > old_size); diff --git a/libs/interprocess/example/doc_map.cpp b/libs/interprocess/example/doc_map.cpp index 5abbf2c551..897047adc6 100644 --- a/libs/interprocess/example/doc_map.cpp +++ b/libs/interprocess/example/doc_map.cpp @@ -51,7 +51,7 @@ int main () #else //-> managed_shared_memory segment - (create_only + (create_only ,"MySharedMemory" //segment name ,65536); //segment size in bytes //<- @@ -67,7 +67,7 @@ int main () //Alias an STL compatible allocator of for the map. //This allocator will allow to place containers //in managed shared memory segments - typedef allocator<ValueType, managed_shared_memory::segment_manager> + typedef allocator<ValueType, managed_shared_memory::segment_manager> ShmemAllocator; //Alias a map of ints that uses the previous STL-like allocator. @@ -82,7 +82,7 @@ int main () //Note that the first parameter is the comparison function, //and the second one the allocator. //This the same signature as std::map's constructor taking an allocator - MyMap *mymap = + MyMap *mymap = segment.construct<MyMap>("MyMap") //object name (std::less<int>() //first ctor parameter ,alloc_inst); //second ctor parameter diff --git a/libs/interprocess/example/doc_move_containers.cpp b/libs/interprocess/example/doc_move_containers.cpp index b66d329681..8158fb6480 100644 --- a/libs/interprocess/example/doc_move_containers.cpp +++ b/libs/interprocess/example/doc_move_containers.cpp @@ -28,7 +28,7 @@ int main () typedef allocator<char, SegmentManager> CharAllocator; typedef basic_string<char, std::char_traits<char> ,CharAllocator> MyShmString; - typedef allocator<MyShmString, SegmentManager> StringAllocator; + typedef allocator<MyShmString, SegmentManager> StringAllocator; typedef vector<MyShmString, StringAllocator> MyShmStringVector; //Remove shared memory on construction and destruction @@ -38,7 +38,7 @@ int main () #if 1 shm_remove() { shared_memory_object::remove(test::get_process_id_name()); } ~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); } - #else + #else //-> shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } @@ -65,7 +65,7 @@ int main () StringAllocator stringallocator(shm.get_segment_manager()); //Create a vector of strings in shared memory. - MyShmStringVector *myshmvector = + MyShmStringVector *myshmvector = shm.construct<MyShmStringVector>("myshmvector")(stringallocator); //Insert 50 strings in shared memory. The strings will be allocated @@ -73,7 +73,7 @@ int main () //strings, leading to a great performance. MyShmString string_to_compare(charallocator); string_to_compare = "this is a long, long, long, long, long, long, string..."; - + myshmvector->reserve(50); for(int i = 0; i < 50; ++i){ MyShmString move_me(string_to_compare); @@ -94,7 +94,7 @@ int main () //...And insert one in the first position. //No string copy-constructor or assignments will be called, but - //move constructors and move-assignments. No memory allocation + //move constructors and move-assignments. No memory allocation //function will be called in this operations!! myshmvector->insert(myshmvector->begin(), boost::move(string_to_compare)); diff --git a/libs/interprocess/example/doc_named_alloc.cpp b/libs/interprocess/example/doc_named_alloc.cpp index 2868ce7943..780b50a634 100644 --- a/libs/interprocess/example/doc_named_alloc.cpp +++ b/libs/interprocess/example/doc_named_alloc.cpp @@ -26,7 +26,7 @@ int main(int argc, char *argv[]) if(argc == 1){ //Parent process //Remove shared memory on construction and destruction - struct shm_remove + struct shm_remove { //<- #if 1 @@ -112,12 +112,12 @@ int main(int argc, char *argv[]) std::pair<MyType*, managed_shared_memory::size_type> res; //Find the array - res = segment.find<MyType> ("MyType array"); + res = segment.find<MyType> ("MyType array"); //Length should be 10 if(res.second != 10) return 1; //Find the object - res = segment.find<MyType> ("MyType instance"); + res = segment.find<MyType> ("MyType instance"); //Length should be 1 if(res.second != 1) return 1; diff --git a/libs/interprocess/example/doc_named_mutex.cpp b/libs/interprocess/example/doc_named_mutex.cpp index 3181860018..5093b2d711 100644 --- a/libs/interprocess/example/doc_named_mutex.cpp +++ b/libs/interprocess/example/doc_named_mutex.cpp @@ -77,7 +77,7 @@ int main () //-> for(int i = 0; i < 10; ++i){ - + //Do some operations... //Write to file atomically diff --git a/libs/interprocess/example/doc_node_allocator.cpp b/libs/interprocess/example/doc_node_allocator.cpp index 25e60837c8..a5578d78f6 100644 --- a/libs/interprocess/example/doc_node_allocator.cpp +++ b/libs/interprocess/example/doc_node_allocator.cpp @@ -43,12 +43,12 @@ int main () //Create shared memory //<- #if 1 - managed_shared_memory segment(create_only, + managed_shared_memory segment(create_only, test::get_process_id_name(), //segment name 65536); #else //-> - managed_shared_memory segment(create_only, + managed_shared_memory segment(create_only, "MySharedMemory", //segment name 65536); //<- diff --git a/libs/interprocess/example/doc_offset_ptr.cpp b/libs/interprocess/example/doc_offset_ptr.cpp index 75e481a44a..955b41bf30 100644 --- a/libs/interprocess/example/doc_offset_ptr.cpp +++ b/libs/interprocess/example/doc_offset_ptr.cpp @@ -49,12 +49,12 @@ int main () //Create shared memory //<- #if 1 - managed_shared_memory segment(create_only, + managed_shared_memory segment(create_only, test::get_process_id_name(), //segment name 65536); #else //-> - managed_shared_memory segment(create_only, + managed_shared_memory segment(create_only, "MySharedMemory", //segment name 65536); //<- diff --git a/libs/interprocess/example/doc_private_adaptive_pool.cpp b/libs/interprocess/example/doc_private_adaptive_pool.cpp index bc560f5725..7447bf227f 100644 --- a/libs/interprocess/example/doc_private_adaptive_pool.cpp +++ b/libs/interprocess/example/doc_private_adaptive_pool.cpp @@ -43,12 +43,12 @@ int main () //Create shared memory //<- #if 1 - managed_shared_memory segment(create_only, + managed_shared_memory segment(create_only, test::get_process_id_name(), //segment name 65536); #else //-> - managed_shared_memory segment(create_only, + managed_shared_memory segment(create_only, "MySharedMemory", //segment name 65536); //<- @@ -68,7 +68,7 @@ int main () //is the same, this private_adaptive_pool will have its own pool so //"allocator_instance2" CAN'T deallocate nodes allocated by "allocator_instance". //"allocator_instance2" is NOT equal to "allocator_instance" - assert(allocator_instance != allocator_instance2); + assert(allocator_instance != allocator_instance2); //Create another adaptive_pool using copy-constructor. private_adaptive_pool_t allocator_instance3(allocator_instance2); diff --git a/libs/interprocess/example/doc_private_node_allocator.cpp b/libs/interprocess/example/doc_private_node_allocator.cpp index 989b6515b7..4ef0a45fca 100644 --- a/libs/interprocess/example/doc_private_node_allocator.cpp +++ b/libs/interprocess/example/doc_private_node_allocator.cpp @@ -43,12 +43,12 @@ int main () //Create shared memory //<- #if 1 - managed_shared_memory segment(create_only, + managed_shared_memory segment(create_only, test::get_process_id_name(), //segment name 65536); #else //-> - managed_shared_memory segment(create_only, + managed_shared_memory segment(create_only, "MySharedMemory", //segment name 65536); //<- @@ -68,7 +68,7 @@ int main () //is the same, this private_node_allocator will have its own pool so //"allocator_instance2" CAN'T deallocate nodes allocated by "allocator_instance". //"allocator_instance2" is NOT equal to "allocator_instance" - assert(allocator_instance != allocator_instance2); + assert(allocator_instance != allocator_instance2); //Create another node_allocator using copy-constructor. private_node_allocator_t allocator_instance3(allocator_instance2); diff --git a/libs/interprocess/example/doc_scoped_ptr.cpp b/libs/interprocess/example/doc_scoped_ptr.cpp index 73c1eadc33..1f20af7acb 100644 --- a/libs/interprocess/example/doc_scoped_ptr.cpp +++ b/libs/interprocess/example/doc_scoped_ptr.cpp @@ -86,7 +86,7 @@ int main () my_class * my_object = shmem.construct<my_class>("my_object")(); my_class * my_object2 = shmem.construct<my_class>(anonymous_instance)(); shmem.destroy_ptr(my_object2); - + //Since the next shared memory allocation can throw //assign it to a scoped_ptr so that if an exception occurs //we destroy the object automatically diff --git a/libs/interprocess/example/doc_shared_memory.cpp b/libs/interprocess/example/doc_shared_memory.cpp index 3689343d9b..24261e53f1 100644 --- a/libs/interprocess/example/doc_shared_memory.cpp +++ b/libs/interprocess/example/doc_shared_memory.cpp @@ -24,7 +24,7 @@ int main(int argc, char *argv[]) if(argc == 1){ //Parent process //Remove shared memory on construction and destruction - struct shm_remove + struct shm_remove { //<- #if 1 diff --git a/libs/interprocess/example/doc_shared_ptr.cpp b/libs/interprocess/example/doc_shared_ptr.cpp index a1f7c2513c..e44eb05b9e 100644 --- a/libs/interprocess/example/doc_shared_ptr.cpp +++ b/libs/interprocess/example/doc_shared_ptr.cpp @@ -62,7 +62,7 @@ int main () //-> //Destroy any previous file with the name to be used. - struct file_remove + struct file_remove { file_remove(const char *MappedFile) : MappedFile_(MappedFile) { file_mapping::remove(MappedFile_); } @@ -128,11 +128,11 @@ int main () //Now destroy the remaining owner. "object to share" will be destroyed file.destroy_ptr(owner2); assert(file.find<type_to_share>("object to share").first == 0); - + //Test observer assert(local_observer1.expired()); assert(local_observer1.use_count() == 0); - + //The reference count will be deallocated when all weak pointers //disappear. After that, the file is unmapped. } diff --git a/libs/interprocess/example/doc_shared_ptr_explicit.cpp b/libs/interprocess/example/doc_shared_ptr_explicit.cpp index 9071719548..06a253df58 100644 --- a/libs/interprocess/example/doc_shared_ptr_explicit.cpp +++ b/libs/interprocess/example/doc_shared_ptr_explicit.cpp @@ -62,7 +62,7 @@ int main () //<- #endif //-> - + //Create a shared pointer in shared memory //pointing to a newly created object in the segment my_shared_ptr &shared_ptr_instance = diff --git a/libs/interprocess/example/doc_spawn_vector.cpp b/libs/interprocess/example/doc_spawn_vector.cpp index b84108382a..86e60d08c9 100644 --- a/libs/interprocess/example/doc_spawn_vector.cpp +++ b/libs/interprocess/example/doc_spawn_vector.cpp @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) { if(argc == 1){ //Parent process //Remove shared memory on construction and destruction - struct shm_remove + struct shm_remove { //<- #if 1 @@ -91,7 +91,7 @@ int main(int argc, char *argv[]) managed_shared_memory segment(open_only, argv[2]); #else //-> - managed_shared_memory segment(open_only, "MySharedMemory"); + managed_shared_memory segment(open_only, "MySharedMemory"); //<- #endif //-> diff --git a/libs/interprocess/example/doc_unique_ptr.cpp b/libs/interprocess/example/doc_unique_ptr.cpp index bbba867166..d9f99f391c 100644 --- a/libs/interprocess/example/doc_unique_ptr.cpp +++ b/libs/interprocess/example/doc_unique_ptr.cpp @@ -40,13 +40,13 @@ typedef managed_unique_ptr<MyType, managed_mapped_file>::type unique_ptr_type; //Define containers of unique pointer. Unique pointer simplifies object management typedef vector < unique_ptr_type - , allocator<unique_ptr_type, managed_mapped_file::segment_manager> - > unique_ptr_vector_t; + , allocator<unique_ptr_type, managed_mapped_file::segment_manager> + > unique_ptr_vector_t; typedef list < unique_ptr_type - , allocator<unique_ptr_type, managed_mapped_file::segment_manager> - > unique_ptr_list_t; + , allocator<unique_ptr_type, managed_mapped_file::segment_manager> + > unique_ptr_list_t; int main () { @@ -64,7 +64,7 @@ int main () //-> //Destroy any previous file with the name to be used. - struct file_remove + struct file_remove { file_remove(const char *MappedFile) : MappedFile_(MappedFile) { file_mapping::remove(MappedFile_); } @@ -97,11 +97,11 @@ int main () unique_vector->push_back(boost::move(p)); assert(unique_vector->back()->number_ == i); } - + //Now create a list of unique pointers unique_ptr_list_t *unique_list = file.construct<unique_ptr_list_t>("unique list")(file.get_segment_manager()); - + //Pass ownership of all values to the list for(int i = 99; !unique_vector->empty(); --i){ unique_list->push_front(boost::move(unique_vector->back())); @@ -131,7 +131,7 @@ int main () for(int i = 0; i < 100; ++i, ++list_it){ assert((*list_it)->number_ == i); } - + //Now destroy the list. All elements will be automatically deallocated. file.destroy_ptr(unique_list); } diff --git a/libs/interprocess/example/doc_vectorstream.cpp b/libs/interprocess/example/doc_vectorstream.cpp index 9eefcde627..2d612195ca 100644 --- a/libs/interprocess/example/doc_vectorstream.cpp +++ b/libs/interprocess/example/doc_vectorstream.cpp @@ -22,9 +22,9 @@ using namespace boost::interprocess; -typedef allocator<int, managed_shared_memory::segment_manager> +typedef allocator<int, managed_shared_memory::segment_manager> IntAllocator; -typedef allocator<char, managed_shared_memory::segment_manager> +typedef allocator<char, managed_shared_memory::segment_manager> CharAllocator; typedef vector<int, IntAllocator> MyVector; typedef basic_string @@ -55,13 +55,13 @@ int main () //<- #if 1 managed_shared_memory segment( - create_only, + create_only, test::get_process_id_name(), //segment name 65536); //segment size in bytes #else //-> managed_shared_memory segment( - create_only, + create_only, "MySharedMemory", //segment name 65536); //segment size in bytes //<- @@ -69,7 +69,7 @@ int main () //-> //Construct shared memory vector - MyVector *myvector = + MyVector *myvector = segment.construct<MyVector>("MyVector") (IntAllocator(segment.get_segment_manager())); @@ -102,7 +102,7 @@ int main () //Avoid reallocations myvector2->reserve(100); - //Extract all values from the internal + //Extract all values from the internal //string directly to a shared memory vector. std::istream_iterator<int> it(myvectorstream), itend; std::copy(it, itend, std::back_inserter(*myvector2)); @@ -114,7 +114,7 @@ int main () MyString stringcopy (myvectorstream.vector()); //Now we create a new empty shared memory string... - MyString *mystring = + MyString *mystring = segment.construct<MyString>("MyString") (CharAllocator(segment.get_segment_manager())); diff --git a/libs/interprocess/example/doc_where_allocate.cpp b/libs/interprocess/example/doc_where_allocate.cpp index c9192af149..0c57a3ee04 100644 --- a/libs/interprocess/example/doc_where_allocate.cpp +++ b/libs/interprocess/example/doc_where_allocate.cpp @@ -22,12 +22,12 @@ int main () { using namespace boost::interprocess; //Typedefs - typedef allocator<char, managed_shared_memory::segment_manager> + typedef allocator<char, managed_shared_memory::segment_manager> CharAllocator; typedef basic_string<char, std::char_traits<char>, CharAllocator> MyShmString; typedef allocator<MyShmString, managed_shared_memory::segment_manager> - StringAllocator; + StringAllocator; typedef vector<MyShmString, StringAllocator> MyShmStringVector; @@ -66,17 +66,17 @@ int main () StringAllocator stringallocator(shm.get_segment_manager()); //This string is in only in this process (the pointer pointing to the - //buffer that will hold the text is not in shared memory). - //But the buffer that will hold "this is my text" is allocated from + //buffer that will hold the text is not in shared memory). + //But the buffer that will hold "this is my text" is allocated from //shared memory MyShmString mystring(charallocator); mystring = "this is my text"; //This vector is only in this process (the pointer pointing to the - //buffer that will hold the MyShmString-s is not in shared memory). - //But the buffer that will hold 10 MyShmString-s is allocated from - //shared memory using StringAllocator. Since strings use a shared - //memory allocator (CharAllocator) the 10 buffers that hold + //buffer that will hold the MyShmString-s is not in shared memory). + //But the buffer that will hold 10 MyShmString-s is allocated from + //shared memory using StringAllocator. Since strings use a shared + //memory allocator (CharAllocator) the 10 buffers that hold //"this is my text" text are also in shared memory. MyShmStringVector myvector(stringallocator); myvector.insert(myvector.begin(), 10, mystring); @@ -84,7 +84,7 @@ int main () //This vector is fully constructed in shared memory. All pointers //buffers are constructed in the same shared memory segment //This vector can be safely accessed from other processes. - MyShmStringVector *myshmvector = + MyShmStringVector *myshmvector = shm.construct<MyShmStringVector>("myshmvector")(stringallocator); myshmvector->insert(myshmvector->begin(), 10, mystring); diff --git a/libs/interprocess/example/doc_xsi_shared_memory.cpp b/libs/interprocess/example/doc_xsi_shared_memory.cpp index fabcea181a..3d645c5259 100644 --- a/libs/interprocess/example/doc_xsi_shared_memory.cpp +++ b/libs/interprocess/example/doc_xsi_shared_memory.cpp @@ -45,7 +45,7 @@ int main(int argc, char *argv[]) xsi_shared_memory shm (create_only, key, 1000); //Remove shared memory on destruction - struct shm_remove + struct shm_remove { int shmid_; shm_remove(int shmid) : shmid_(shmid){} |