Inter Process
Inter Process
Interprocess
Ion Gaztanaga
Copyright 2005-2011 Ion Gaztanaga Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Table of Contents
Introduction .......................................................................................................................................................... 2 Quick Guide for the Impatient .................................................................................................................................. 3 Some basic explanations ........................................................................................................................................ 10 Sharing memory between processes ......................................................................................................................... 13 Mapping Address Independent Pointer: offset_ptr ....................................................................................................... 29 Synchronization mechanisms .................................................................................................................................. 31 Managed Memory Segments .................................................................................................................................. 66 Allocators, containers and memory allocation algorithms ............................................................................................. 96 Memory allocation algorithms ............................................................................................................................... 122 Direct iostream formatting: vectorstream and bufferstream ......................................................................................... 124 Ownership smart pointers ..................................................................................................................................... 131 Architecture and internals ..................................................................................................................................... 142 Customizing Boost.Interprocess ............................................................................................................................ 148 Acknowledgements, notes and links ....................................................................................................................... 154 Indexes ............................................................................................................................................................. 162 Boost.Interprocess Reference ................................................................................................................................ 283
Boost.Interprocess
Introduction
Boost.Interprocess simplies the use of common interprocess communication and synchronization mechanisms and offers a wide range of them: Shared memory. Memory-mapped les. Semaphores, mutexes, condition variables and upgradable mutex types to place them in shared memory and memory mapped les. Named versions of those synchronization objects, similar to UNIX/Windows sem_open/CreateSemaphore API. File locking. Relative pointers. Message queues. Boost.Interprocess also offers higher-level interprocess mechanisms to allocate dynamically portions of a shared memory or a memory mapped le (in general, to allocate portions of a xed size memory segment). Using these mechanisms, Boost.Interprocess offers useful tools to construct C++ objects, including STL-like containers, in shared memory and memory mapped les: Dynamic creation of anonymous and named objects in a shared memory or memory mapped le. STL-like containers compatible with shared memory/memory-mapped les. STL-like allocators ready for shared memory/memory-mapped les implementing several memory allocation patterns (like pooling).
Building Boost.Interprocess
There is no need to compile Boost.Interprocess, since it's a header only library. Just include your Boost header directory in your compiler include path. Boost.Interprocess depends on Boost.DateTime, which needs separate compilation. However, the subset used by Boost.Interprocess does not need any separate compilation so the user can dene BOOST_DATE_TIME_NO_LIB to avoid Boost from trying to automatically link the Boost.DateTime. In POSIX systems, Boost.Interprocess uses pthread system calls to implement classes like mutexes, condition variables, etc... In some operating systems, these POSIX calls are implemented in separate libraries that are not automatically linked by the compiler. For example, in some Linux systems POSIX pthread functions are implemented in librt.a library, so you might need to add that library when linking an executable or shared library that uses Boost.Interprocess. If you obtain linking errors related to those pthread functions, please revise your system's documentation to know which library implements them.
Tested compilers
Boost.Interprocess has been tested in the following compilers/platforms: Visual >= 7.1 GCC >= 4.1 Intel 11
Boost.Interprocess
Boost.Interprocess
int main(int argc, char *argv[]) { using namespace boost::interprocess; typedef std::pair<double, int> MyType; if(argc == 1){ //Parent process //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Construct managed shared memory managed_shared_memory segment(create_only, "MySharedMemory", 65536); //Create an object of MyType initialized to {0.0, 0} MyType *instance = segment.construct<MyType> ("MyType instance") //name of the object (0.0, 0); //ctor first argument //Create an array of 10 elements of MyType initialized to {0.0, 0} MyType *array = segment.construct<MyType> ("MyType array") //name of the object [10] //number of elements (0.0, 0); //Same two ctor arguments for all objects //Create an array of 3 elements of MyType initializing each one //to a different value {0.0, 0}, {1.0, 1}, {2.0, 2}... float float_initializer[3] = { 0.0, 1.0, 2.0 }; int int_initializer[3] = { 0, 1, 2 }; MyType *array_it = segment.construct_it<MyType> ("MyType array from it") //name of the object [3] //number of elements ( &float_initializer[0] //Iterator for the 1st ctor argument , &int_initializer[0]); //Iterator for the 2nd ctor argument //Launch child process std::string s(argv[0]); s += " child "; if(0 != std::system(s.c_str())) return 1;
Boost.Interprocess
} else{ //Open managed shared memory managed_shared_memory segment(open_only, "MySharedMemory"); std::pair<MyType*, managed_shared_memory::size_type> res; //Find the 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"); //Length should be 1 if(res.second != 1) return 1; //Find the array constructed from iterators res = segment.find<MyType> ("MyType array from it"); //Length should be 3 if(res.second != 3) return 1; //We're done, delete all the objects segment.destroy<MyType>("MyType array"); segment.destroy<MyType>("MyType instance"); segment.destroy<MyType>("MyType array from it"); } return 0; }
Boost.Interprocess
#include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/offset_ptr.hpp> using namespace boost::interprocess; //Shared memory linked list node struct list_node { offset_ptr<list_node> next; int value; }; int main () { //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create shared memory managed_shared_memory segment(create_only, "MySharedMemory", 65536);
//segment name
//Create linked list with 10 nodes in shared memory offset_ptr<list_node> prev = 0, current, first; int i; for(i = 0; i < 10; ++i, prev = current){ current = static_cast<list_node*>(segment.allocate(sizeof(list_node))); current->value = i; current->next = 0; if(!prev) first = current; else prev->next = current; } //Communicate list to other processes //. . . //When done, destroy list for(current = first; current; /**/){ prev = current; current = current->next; segment.deallocate(prev.get()); } return 0; }
To help with basic data structures, Boost.Interprocess offers containers like vector, list, map, so you can avoid these manual data structures just like with standard containers.
Boost.Interprocess
The class that allows this complex structures in shared memory is called boost::interprocess::managed_shared_memory and it's easy to use. Just execute this example without arguments:
#include #include #include #include #include <boost/interprocess/managed_shared_memory.hpp> <boost/interprocess/containers/vector.hpp> <boost/interprocess/allocators/allocator.hpp> <string> <cstdlib> //std::system
using namespace boost::interprocess; //Define an STL compatible allocator of ints that allocates from the managed_shared_memory. //This allocator will allow placing containers in the segment typedef allocator<int, managed_shared_memory::segment_manager> ShmemAllocator; //Alias a vector that uses the previous STL-like allocator so that allocates //its values from the segment typedef vector<int, ShmemAllocator> MyVector; //Main function. For parent process argc == 1, for child process argc == 2 int main(int argc, char *argv[]) { if(argc == 1){ //Parent process //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create a new segment with given name and size managed_shared_memory segment(create_only, "MySharedMemory", 65536); //Initialize shared memory STL-compatible allocator const ShmemAllocator alloc_inst (segment.get_segment_manager()); //Construct a vector named "MyVector" in shared memory with argument alloc_inst MyVector *myvector = segment.construct<MyVector>("MyVector")(alloc_inst); for(int i = 0; i < 100; ++i) myvector->push_back(i); //Insert data in the vector
//Launch child process std::string s(argv[0]); s += " child "; if(0 != std::system(s.c_str())) return 1; //Check child has destroyed the vector if(segment.find<MyVector>("MyVector").first) return 1; } else{ //Child process //Open the managed segment managed_shared_memory segment(open_only, "MySharedMemory"); //Find the vector using the c-string name MyVector *myvector = segment.find<MyVector>("MyVector").first; //Use vector in reverse order std::sort(myvector->rbegin(), myvector->rend());
Boost.Interprocess
//When done, destroy the vector from the segment segment.destroy<MyVector>("MyVector"); } return 0; };
The parent process will create an special shared memory class that allows easy construction of many complex data structures associated with a name. The parent process executes the same program with an additional argument so the child process opens the shared memory and uses the vector and erases it.
int main () { using namespace boost::interprocess; //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Shared memory front-end that is able to construct objects //associated with a c-string. Erase previous shared memory with the name //to be used and create the memory segment at the specified address and initialize resources managed_shared_memory segment (create_only ,"MySharedMemory" //segment name ,65536); //segment size in bytes //Note that map<Key, MappedType>'s value_type is std::pair<const Key, MappedType>, //so the allocator must allocate that pair. typedef int KeyType; typedef float MappedType; typedef std::pair<const int, float> ValueType; //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> ShmemAllocator; //Alias a map of ints that uses the previous STL-like allocator. //Note that the third parameter argument is the ordering function //of the map, just like with std::map, used to compare the keys. typedef map<KeyType, MappedType, std::less<KeyType>, ShmemAllocator> MyMap; //Initialize the shared memory STL-compatible allocator ShmemAllocator alloc_inst (segment.get_segment_manager());
Boost.Interprocess
//Construct a shared memory map. //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 = segment.construct<MyMap>("MyMap") //object name (std::less<int>() //first ctor parameter ,alloc_inst); //second ctor parameter //Insert data in the map for(int i = 0; i < 100; ++i){ mymap->insert(std::pair<const int, float>(i, (float)i)); } return 0; }
For a more advanced example including containers of containers, see the section Containers of containers.
Boost.Interprocess
10
Boost.Interprocess
As you can see, Boost.Interprocess denes some mechanisms with "Kernel or Filesystem" persistence. This is because POSIX allows this possibility to native interprocess communication implementations. One could, for example, implement shared memory using memory mapped les and obtain lesystem persistence (for example, there is no proper known way to emulate kernel persistence with a user library for Windows shared memory using native shared memory, or process persistence for POSIX shared memory, so the only portable way is to dene "Kernel or Filesystem" persistence).
11
Boost.Interprocess
Now the correspondence between POSIX and Boost.Interprocess regarding shared memory and named semaphores:
The most important property is that destructors of named resources don't remove the resource from the system, they only liberate resources allocated by the system for use by the process for the named resource. To remove the resource from the system the programmer must use remove.
Permissions
Named resources offered by Boost.Interprocess must cope with platform-dependant permission issues also present when creating les. If a programmer wants to shared shared memory, memory mapped les or named synchronization mechanisms (mutexes, semaphores, etc...) between users, it's necessary to specify those permissions. Sadly, traditional UNIX and Windows permissions are very different and Boost.Interprocess does not try to standardize permissions, but does not ignore them. All named resource creation functions take an optional permissions object that can be congured with platform-dependant permissions. Since each mechanism can be emulated through diferent mechanisms (a semaphore might be implement using mapped les or native semaphores) permissions types could vary when the implementation of a named resource changes (eg.: in Windows mutexes require synchronize permissions, but that's not the case of les). To avoid this, Boost.Interprocess relies on le-like permissions, requiring le read-write-delete permissions to open named synchronization mechanisms (mutex, semaphores, etc.) and appropiate read or read-write-delete permissions for shared memory. This approach has two advantages: it's similar to the UNIX philosophy and the programmer does not need to know how the named resource is implemented.
12
Boost.Interprocess
Header
To manage shared memory, you just need to include the following header:
#include <boost/interprocess/shared_memory_object.hpp>
13
Boost.Interprocess
When a shared memory object is created, its size is 0. To set the size of the shared memory, the user must use the truncate function call, in a shared memory that has been opened with read-write attributes:
shm_obj.truncate(10000);
As shared memory has kernel or lesystem persistence, the user must explicitly destroy it. The remove operation might fail returning false if the shared memory does not exist, the le is open or the le is still memory mapped by other processes:
using boost::interprocess; shared_memory_object::remove("shared_memory");
For more details regarding shared_memory_object see the boost::interprocess::shared_memory_object class reference.
14
Boost.Interprocess
using boost::interprocess; std::size_t ShmSize = ... //Map the second half of the memory mapped_region region ( shm //Memory-mappable object , read_write //Access mode , ShmSize/2 //Offset from the beginning of shm , ShmSize-ShmSize/2 //Length of the region ); //Get the address of the region region.get_address(); //Get the size of the region region.get_size();
The user can specify the offset from the mappable object where the mapped region should start and the size of the mapped region. If no offset or size is specied, the whole mappable object (in this case, shared memory) is mapped. If the offset is specied, but not the size, the mapped region covers from the offset until the end of the mappable object. For more details regarding mapped_region see the boost::interprocess::mapped_region class reference.
A Simple Example
Let's see a simple example of shared memory use. A server process creates a shared memory object, maps it and initializes all the bytes to a value. After that, a client process opens the shared memory, maps it, and checks that the data is correctly initialized:
15
Boost.Interprocess
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 { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create a shared memory object. shared_memory_object shm (create_only, "MySharedMemory", read_write); //Set size shm.truncate(1000); //Map the whole shared memory in this process mapped_region region(shm, read_write); //Write all the memory to 1 std::memset(region.get_address(), 1, region.get_size()); //Launch child process std::string s(argv[0]); s += " child "; if(0 != std::system(s.c_str())) return 1; } else{ //Open already created shared memory object. shared_memory_object shm (open_only, "MySharedMemory", read_only); //Map the whole shared memory in this process mapped_region region(shm, read_only); //Check that memory was initialized to 1 char *mem = static_cast<char*>(region.get_address()); for(std::size_t i = 0; i < region.get_size(); ++i) if(*mem++ != 1) return 1; //Error checking memory } return 0; }
16
Boost.Interprocess
In those platforms, shared memory is emulated with mapped les created in a "boost_interprocess" folder created in a temporary les directory. In Windows platforms, if "Common AppData" key is present in the registry, "boost_interprocess" folder is created in that directory (in XP usually "C:\Documents and Settings\All Users\Application Data" and in Vista "C:\ProgramData"). For Windows platforms without that registry key and Unix systems, shared memory is created in the system temporary les directory ("/tmp" or similar). Because of this emulation, shared memory has lesystem lifetime in some of those systems.
This function can fail if the shared memory objects does not exist or it's opened by another process. Note that this function is similar to the standard C int remove(const char *path) function. In UNIX systems, shared_memory_object::remove calls shm_unlink: The function will remove the name of the shared memory object named by the string pointed to by name. If one or more references to the shared memory object exist when is unlinked, the name will be removed before the function returns, but the removal of the memory object contents will be postponed until all open and map references to the shared memory object have been removed. Even if the object continues to exist after the last function call, reuse of the name will subsequently cause the creation of a boost::interprocess::shared_memory_object instance to behave as if no shared memory object of this name exists (that is, trying to open an object with that name will fail and an object of the same name can be created again). In Windows operating systems, current version supports an usually acceptable emulation of the UNIX unlink behaviour: the le is renamed with a random name and marked as to be deleted when the last open handle is closed.
17
Boost.Interprocess
int main () { using namespace boost::interprocess; try{ //Create an anonymous shared memory segment with size 1000 mapped_region region(anonymous_shared_memory(1000)); //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){ std::cout << ex.what() << std::endl; return 1; } return 0; }
Once the segment is created, a fork() call can be used so that region is used to communicate two related processes.
18
Boost.Interprocess
int main(int argc, char *argv[]) { using namespace boost::interprocess; if(argc == 1){ //Parent process //Create a native windows shared memory object. windows_shared_memory shm (create_only, "MySharedMemory", read_write, 1000); //Map the whole shared memory in this process mapped_region region(shm, read_write); //Write all the memory to 1 std::memset(region.get_address(), 1, region.get_size()); //Launch child process std::string s(argv[0]); s += " child "; if(0 != std::system(s.c_str())) return 1; //windows_shared_memory is destroyed when the last attached process dies... } else{ //Open already created shared memory object. windows_shared_memory shm (open_only, "MySharedMemory", read_only); //Map the whole shared memory in this process mapped_region region(shm, read_only); //Check that memory was initialized to 1 char *mem = static_cast<char*>(region.get_address()); for(std::size_t i = 0; i < region.get_size(); ++i) if(*mem++ != 1) return 1; //Error checking memory return 0; } return 0; }
As we can see, native windows shared memory needs synchronization to make sure that the shared memory won't be destroyed before the client is launched.
19
Boost.Interprocess
Let's repeat the same example presented for the portable shared memory object: A server process creates a shared memory object, maps it and initializes all the bytes to a value. After that, a client process opens the shared memory, maps it, and checks that the data is correctly initialized. This is the server process:
#include #include #include #include #include <boost/interprocess/xsi_shared_memory.hpp> <boost/interprocess/mapped_region.hpp> <cstring> <cstdlib> <string>
using namespace boost::interprocess; void remove_old_shared_memory(const xsi_key &key) { try{ xsi_shared_memory xsi(open_only, key); xsi_shared_memory::remove(xsi.get_shmid()); } catch(interprocess_exception &e){ if(e.get_error_code() != not_found_error) throw; } } int main(int argc, char *argv[]) { if(argc == 1){ //Parent process //Build XSI key (ftok based) xsi_key key(argv[0], 1); remove_old_shared_memory(key); //Create a shared memory object. xsi_shared_memory shm (create_only, key, 1000); //Remove shared memory on destruction struct shm_remove { int shmid_; shm_remove(int shmid) : shmid_(shmid){} ~shm_remove(){ xsi_shared_memory::remove(shmid_); } } remover(shm.get_shmid()); //Map the whole shared memory in this process mapped_region region(shm, read_write); //Write all the memory to 1 std::memset(region.get_address(), 1, region.get_size()); //Launch child process std::string s(argv[0]); s += " child "; if(0 != std::system(s.c_str())) return 1; } else{ //Build XSI key (ftok based) xsi_key key(argv[0], 1); //Create a shared memory object. xsi_shared_memory shm (open_only, key);
20
Boost.Interprocess
//Map the whole shared memory in this process mapped_region region(shm, read_only); //Check that memory was initialized to 1 char *mem = static_cast<char*>(region.get_address()); for(std::size_t i = 0; i < region.get_size(); ++i) if(*mem++ != 1) return 1; //Error checking memory } return 0; }
21
Boost.Interprocess
Once the two steps have been successfully completed, the process can start writing to and reading from the address space to send to and receive data from other processes and synchronize the le's contents with the changes made to the mapped region. Now, let's see how can we do this using Boost.Interprocess:
Header
To manage mapped les, you just need to include the following header:
#include <boost/interprocess/file_mapping.hpp>
Now we can use the newly created object to create mapped regions. For more details regarding this class see the boost::interprocess::file_mapping class reference.
The user can specify the offset from the le where the mapped region should start and the size of the mapped region. If no offset or size is specied, the whole le is mapped. If the offset is specied, but not the size, the mapped region covers from the offset until the end of the le. If several processes map the same le, and a process modies a memory range from a mapped region that is also mapped by other process, the changes are inmedially visible to other processes. However, the le contents on disk are not updated immediately, since that would hurt performance (writing to disk is several times slower than writing to memory). If the user wants to make sure that le's contents have been updated, it can ush a range from the view to disk. When the function returns, the ushing process has startd but there is not guarantee that all data has been written to disk:
22
Boost.Interprocess
//Flush the whole region region.flush(); //Flush from an offset until the end of the region region.flush(offset); //Flush a memory range starting on an offset region.flush(offset, size);
Remember that the offset is not an offset on the le, but an offset in the mapped region. If a region covers the second half of a le and ushes the whole region, only the half of the le is guaranteed to have been ushed. For more details regarding mapped_region see the boost::interprocess::mapped_region class reference.
A Simple Example
Let's reproduce the same example described in the shared memory section, using memory mapped les. A server process creates a shared memory segment, maps it and initializes all the bytes to a value. After that, a client process opens the shared memory, maps it, and checks that the data is correctly initialized::
#include #include #include #include #include #include #include #include #include <boost/interprocess/file_mapping.hpp> <boost/interprocess/mapped_region.hpp> <iostream> <fstream> <string> <vector> <cstring> <cstddef> <cstdlib>
int main(int argc, char *argv[]) { using namespace boost::interprocess; //Define file names const char *FileName = "file.bin"; const std::size_t FileSize = 10000; if(argc == 1){ //Parent process executes this { //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); //Set the size fbuf.pubseekoff(FileSize-1, std::ios_base::beg); fbuf.sputc(0); } //Remove on exit struct file_remove { file_remove(const char *FileName) : FileName_(FileName) {} ~file_remove(){ file_mapping::remove(FileName_); } const char *FileName_; } remover(FileName); //Create a file mapping file_mapping m_file(FileName, read_write);
23
Boost.Interprocess
//Map the whole file with read-write permissions in this process mapped_region region(m_file, read_write); //Get the address of the mapped region void * addr = region.get_address(); std::size_t size = region.get_size(); //Write all the memory to 1 std::memset(addr, 1, size); //Launch child process std::string s(argv[0]); s += " child "; if(0 != std::system(s.c_str())) return 1; } else{ //Child process executes this { //Open the file mapping and map it as read-only file_mapping m_file(FileName, read_only); mapped_region region(m_file, read_only); //Get the address of the mapped region void * addr = region.get_address(); std::size_t size = region.get_size(); //Check that memory was initialized to 1 const char *mem = static_cast<char*>(addr); for(std::size_t i = 0; i < size; ++i) if(*mem++ != 1) return 1; //Error checking memory } { //Now test it reading the file std::filebuf fbuf; fbuf.open(FileName, std::ios_base::in | std::ios_base::binary); //Read it to memory std::vector<char> vect(FileSize, 0); fbuf.sgetn(&vect[0], std::streamsize(vect.size())); //Check that memory was initialized to 1 const char *mem = static_cast<char*>(&vect[0]); for(std::size_t i = 0; i < FileSize; ++i) if(*mem++ != 1) return 1; //Error checking memory } } return 0; }
24
Boost.Interprocess
However, the user can't map the region in any address, even if the address is not being used. The offset parameter that marks the start of the mapping region is also limited. These limitations are explained in the next section.
25
Boost.Interprocess
//These might fail because the offset is not a multiple of the page size //and we are using fixed address mapping mapped_region region1( shm //Map shared memory , read_write //Map it as read-write , 1 //Map from offset 1 , 1 //Map 1 byte , (void*)0x3F000000 //Aligned mapping address ); //These might fail because the address is not a multiple of the page size mapped_region region2( shm //Map shared memory , read_write //Map it as read-write , 0 //Map from offset 0 , 1 //Map 1 byte , (void*)0x3F000001 //Not aligned mapping address );
Since the operating system performs mapping operations over whole pages, specifying a mapping size or offset that are not multiple of the page size will waste more resources than necessary. If the user species the following 1 byte mapping:
//Map one byte of the shared memory object. //A whole memory page will be used for this. mapped_region region ( shm , read_write , 0 , 1 );
The operating system will reserve a whole page that will not be reused by any other mapping so we are going to waste (page size 1) bytes. If we want to use efciently operating system resources, we should create regions whose size is a multiple of page size bytes. If the user species the following two mapped regions for a le with which has 2*page_size bytes:
//Map the first quarter of the file //This will use a whole page mapped_region region1( shm , read_write , 0 , page_size/2 ); //Map the rest of the file //This will use a 2 pages mapped_region region2( shm , read_write , page_size/2 , 3*page_size/2 );
shared memory it as read-write from offset 0 the rest of the shared memory
In this example, a half of the page is wasted in the rst mapping and another half is wasted in the second because the offset is not a multiple of the page size. The mapping with the minimum resource usage would be to map whole pages:
26
Boost.Interprocess
//Map the whole first half: uses 1 page mapped_region region1( shm , read_write , 0 , page_size ); //Map the second half: uses 1 page mapped_region region2( shm , read_write , page_size , page_size );
How can we obtain the page size? The mapped_region class has a static function that returns that value:
//Obtain the page size of the system std::size_t page_size = mapped_region::get_page_size();
The operating system might also limit the number of mapped memory regions per process or per system.
References forbidden
References suffer from the same problem as pointers (mainly because they are implemented as pointers). However, it is not possible to create a fully workable smart reference currently in C++ (for example, operator .() can't be overloaded). Because of this, if the user wants to put an object in shared memory, the object can't have any (smart or not) reference as a member. References will only work if the mapped region is mapped in the same base address in all processes sharing a memory segment. Like pointers, a reference placed in a mapped region should only point to an object of that mapped region.
Virtuality forbidden
The virtual table pointer and the virtual table are in the address space of the process that constructs the object, so if we place a class with a virtual function or virtual base class, the virtual pointer placed in shared memory will be invalid for other processes and they will crash. This problem is very difcult to solve, since each process needs a different virtual table pointer and the object that contains that pointer is shared across many processes. Even if we map the mapped region in the same address in every process, the virtual table
27
Boost.Interprocess
can be in a different address in every process. To enable virtual functions for objects shared between processes, deep compiler changes are needed and virtual functions would suffer a performance hit. That's why Boost.Interprocess does not have any plan to support virtual function and virtual inheritance in mapped regions shared between processes.
28
Boost.Interprocess
This makes the creation of complex objects in mapped regions difcult: a C++ class instance placed in a mapped region might have a pointer pointing to another object also placed in the mapped region. Since the pointer stores an absolute address, that address is only valid for the process that placed the object there unless all processes map the mapped region in the same address. To be able to simulate pointers in mapped regions, users must use offsets (distance between objects) instead of absolute addresses. The offset between two objects in a mapped region is the same for any process that maps the mapped region, even if that region is placed in different base addresses. To facilitate the use of offsets, Boost.Interprocess offers offset_ptr.
offset_ptr wraps all the background operations needed to offer a pointer-like interface. The class interface is inspired in Boost Smart Pointers and this smart pointer stores the offset (distance in bytes) between the pointee's address and it's own this pointer.
//The compiler places this at offset 0 in the structure //The compiler places this at offset 4 in the structure //The compiler places this at offset 8 in the structure
29
Boost.Interprocess
One of the big problems of offset_ptr is the representation of the null pointer. The null pointer can't be safely represented like an offset, since the absolute address 0 is always outside of the mapped region. Due to the fact that the segment can be mapped in a different base address in each process the distance between the address 0 and offset_ptr is different for every process. Some implementations choose the offset 0 (that is, an offset_ptr pointing to itself) as the null pointer pointer representation but this is not valid for many use cases since many times structures like linked lists or nodes from STL containers point to themselves (the end node in an empty container, for example) and 0 offset value is needed. An alternative is to store, in addition to the offset, a boolean to indicate if the pointer is null. However, this increments the size of the pointer and hurts performance. In consequence, offset_ptr denes offset 1 as the null pointer, meaning that this class can't point to the byte after its own this pointer:
using namespace boost::interprocess; offset_ptr<char> ptr; //Pointing to the next byte of it's own address //marks the smart pointer as null. ptr = (char*)&ptr + 1; //ptr is equal to null assert(!ptr); //This is the same as assigning the null value... ptr = 0; //ptr is also equal to null assert(!ptr);
In practice, this limitation is not important, since a user almost never wants to point to this address.
offset_ptr offers all pointer-like operations and random_access_iterator typedefs, so it can be used in STL algorithms requiring random access iterators and detected via traits. For more information about the members and operations of the class, see offset_ptr reference.
30
Boost.Interprocess
Synchronization mechanisms
Synchronization mechanisms overview
As mentioned before, the ability to shared memory between processes through memory mapped les or shared memory objects is not very useful if the access to that memory can't be effectively synchronized. This is the same problem that happens with threadsynchronization mechanisms, where heap memory and global variables are shared between threads, but the access to these resources needs to be synchronized typically through mutex and condition variables. Boost.Threads implements these synchronization utilities between threads inside the same process. Boost.Interprocess implements similar mechanisms to synchronize threads from different processes.
On the other hand the anonymous synchronization utility can only be created and the processes must synchronize using other mechanisms who creates the utility:
31
Boost.Interprocess
Mutexes
What's A Mutex?
Mutex stands for mutual exclusion and it's the most basic form of synchronization between processes. Mutexes guarantee that only one thread can lock a given mutex. If a code section is surrounded by a mutex locking and unlocking, it's guaranteed that only a thread at a time executes that section of code. When that thread unlocks the mutex, other threads can enter to that code region:
//The mutex has been previously constructed lock_the_mutex(); //This code will be executed only by one thread //at a time. unlock_the_mutex();
A mutex can also be recursive or non-recursive: Recursive mutexes can be locked several times by the same thread. To fully unlock the mutex, the thread has to unlock the mutex the same times it has locked it. Non-recursive mutexes can't be locked several times by the same thread. If a mutex is locked twice by a thread, the result is undened, it might throw an error or the thread could be blocked forever.
Mutex Operations
All the mutex types from Boost.Interprocess implement the following operations: void lock() Effects: The calling thread tries to obtain ownership of the mutex, and if another thread has ownership of the mutex, it waits until it can obtain the ownership. If a thread takes ownership of the mutex the mutex must be unlocked by the same thread. If the mutex supports recursive locking, the mutex must be unlocked the same number of times it is locked. Throws: interprocess_exception on error.
32
Boost.Interprocess
bool try_lock() Effects: The calling thread tries to obtain ownership of the mutex, and if another thread has ownership of the mutex returns immediately. If the mutex supports recursive locking, the mutex must be unlocked the same number of times it is locked. Returns: If the thread acquires ownership of the mutex, returns true, if the another thread has ownership of the mutex, returns false. Throws: interprocess_exception on error. bool timed_lock(const boost::posix_time::ptime &abs_time) Effects: The calling thread will try to obtain exclusive ownership of the mutex if it can do so in until the specied time is reached. If the mutex supports recursive locking, the mutex must be unlocked the same number of times it is locked. Returns: If the thread acquires ownership of the mutex, returns true, if the timeout expires returns false. Throws: interprocess_exception on error. void unlock() Precondition: The thread must have exclusive ownership of the mutex. Effects: The calling thread releases the exclusive ownership of the mutex. If the mutex supports recursive locking, the mutex must be unlocked the same number of times it is locked. Throws: An exception derived from interprocess_exception on error.
Important
boost::posix_time::ptime absolute time points used by Boost.Interprocess synchronization mechanisms are
interprocess_mutex: A non-recursive, anonymous mutex that can be placed in shared memory or memory mapped les.
#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
interprocess_recursive_mutex: A recursive, anonymous mutex that can be placed in shared memory or memory mapped les.
#include <boost/interprocess/sync/named_mutex.hpp>
33
Boost.Interprocess
Scoped lock
It's very important to unlock a mutex after the process has read or written the data. This can be difcult when dealing with exceptions, so usually mutexes are used with a scoped lock, a class that can guarantee that a mutex will always be unlocked even when an exception occurs. To use a scoped lock just include:
#include <boost/interprocess/sync/scoped_lock.hpp>
Basically, a scoped lock calls unlock() in its destructor, and a mutex is always unlocked when an exception occurs. Scoped lock has many constructors to lock, try_lock, timed_lock a mutex or not to lock it at all.
using namespace boost::interprocess; //Let's create any mutex type: MutexType mutex; { //This will lock the mutex scoped_lock<MutexType> lock(mutex); //Some code //The mutex will be unlocked here } { //This will try_lock the mutex scoped_lock<MutexType> lock(mutex, try_to_lock); //Check if the mutex has been successfully locked if(lock){ //Some code } //If the mutex was locked it will be unlocked } { boost::posix_time::ptime abs_time = ... //This will timed_lock the mutex scoped_lock<MutexType> lock(mutex, abs_time); //Check if the mutex has been successfully locked if(lock){ //Some code } //If the mutex was locked it will be unlocked }
Important
boost::posix_time::ptime absolute time points used by Boost.Interprocess synchronization mechanisms are
34
Boost.Interprocess
This is the process main process. Creates the shared memory, constructs the cyclic buffer and start writing traces:
35
Boost.Interprocess
using namespace boost::interprocess; int main () { try{ //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create a shared memory object. shared_memory_object shm (create_only //only create ,"MySharedMemory" //name ,read_write //read-write mode ); //Set size shm.truncate(sizeof(shared_memory_log)); //Map the whole shared memory in this process mapped_region region (shm //What to map ,read_write //Map it as read-write ); //Get the address of the mapped region void * addr = region.get_address(); //Construct the shared structure in memory shared_memory_log * data = new (addr) shared_memory_log; //Write some logs for(int i = 0; i < shared_memory_log::NumItems; ++i){ //Lock the mutex scoped_lock<interprocess_mutex> lock(data->mutex); std::sprintf(data->items[(data->current_line++) % shared_memory_log::NumItems] ,"%s_%d", "process_a", i); if(i == (shared_memory_log::NumItems-1)) data->end_a = true; //Mutex is released here } //Wait until the other process ends while(1){ scoped_lock<interprocess_mutex> lock(data->mutex); if(data->end_b) break; } }
36
Boost.Interprocess
The second process opens the shared memory, obtains access to the cyclic buffer and starts writing traces:
#include #include #include #include #include #include <boost/interprocess/shared_memory_object.hpp> <boost/interprocess/mapped_region.hpp> <boost/interprocess/sync/scoped_lock.hpp> "doc_anonymous_mutex_shared_data.hpp" <iostream> <cstdio>
using namespace boost::interprocess; int main () { //Remove shared memory on destruction struct shm_remove { ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Open the shared memory object. shared_memory_object shm (open_only //only create ,"MySharedMemory" //name ,read_write //read-write mode ); //Map the whole shared memory in this process mapped_region region (shm //What to map ,read_write //Map it as read-write ); //Get the address of the mapped region void * addr = region.get_address(); //Construct the shared structure in memory shared_memory_log * data = static_cast<shared_memory_log*>(addr); //Write some logs for(int i = 0; i < 100; ++i){ //Lock the mutex scoped_lock<interprocess_mutex> lock(data->mutex); std::sprintf(data->items[(data->current_line++) % shared_memory_log::NumItems] ,"%s_%d", "process_a", i); if(i == (shared_memory_log::NumItems-1)) data->end_b = true; //Mutex is released here } //Wait until the other process ends while(1){
37
Boost.Interprocess
As we can see, a mutex is useful to protect data but not to notify an event to another process. For this, we need a condition variable, as we will see in the next section.
int main () { using namespace boost::interprocess; try{ struct file_remove { file_remove() { std::remove("file_name"); } ~file_remove(){ std::remove("file_name"); } } file_remover; struct mutex_remove { mutex_remove() { named_mutex::remove("fstream_named_mutex"); } ~mutex_remove(){ named_mutex::remove("fstream_named_mutex"); } } remover; //Open or create the named mutex named_mutex mutex(open_or_create, "fstream_named_mutex"); std::ofstream file("file_name"); for(int i = 0; i < 10; ++i){ //Do some operations... //Write to file atomically scoped_lock<named_mutex> lock(mutex); file << "Process name, "; file << "This is iteration #" << i; file << std::endl; } } catch(interprocess_exception &ex){ std::cout << ex.what() << std::endl; return 1; } return 0; }
38
Boost.Interprocess
Conditions
What's A Condition Variable?
In the previous example, a mutex is used to lock but we can't use it to wait efciently until the condition to continue is met. A condition variable can do two things: wait: The thread is blocked until some other thread noties that it can continue because the condition that lead to waiting has disappeared. notify: The thread sends a signal to one blocked thread or to all blocked threads to tell them that they the condition that provoked their wait has disappeared. Waiting in a condition variable is always associated with a mutex. The mutex must be locked prior to waiting on the condition. When waiting on the condition variable, the thread unlocks the mutex and waits atomically. When the thread returns from a wait function (because of a signal or a timeout, for example) the mutex object is again locked.
interprocess_condition: An anonymous condition variable that can be placed in shared memory or memory mapped les to be used with boost::interprocess::interprocess_mutex.
#include <boost/interprocess/sync/interprocess_condition_any.hpp>
interprocess_condition_any: An anonymous condition variable that can be placed in shared memory or memory mapped les to be used with any lock type.
#include <boost/interprocess/sync/named_condition.hpp>
named_condition: A named condition variable to be used with any lock type. Named conditions are similar to anonymous conditions, but they are used in combination with named mutexes. Several times, we don't want to store synchronization objects with the synchronized data: We want to change the synchronization method (from interprocess to intra-process, or without any synchronization) using the same data. Storing the process-shared anonymous synchronization with the synchronized data would forbid this. We want to send the synchronized data through the network or any other communication method. Sending the process-shared synchronization objects wouldn't have any sense.
39
Boost.Interprocess
mutex;
cond_empty;
cond_full;
This is the process main process. Creates the shared memory, places there the buffer and starts writing messages one by one until it writes "last message" to indicate that there are no more messages to print:
40
Boost.Interprocess
using namespace boost::interprocess; int main () { //Erase previous shared memory and schedule erasure on exit struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create a shared memory object. shared_memory_object shm (create_only //only create ,"MySharedMemory" //name ,read_write //read-write mode ); try{ //Set size shm.truncate(sizeof(trace_queue)); //Map the whole shared memory in this process mapped_region region (shm //What to map ,read_write //Map it as read-write ); //Get the address of the mapped region void * addr = region.get_address(); //Construct the shared structure in memory trace_queue * data = new (addr) trace_queue; const int NumMsg = 100; for(int i = 0; i < NumMsg; ++i){ scoped_lock<interprocess_mutex> lock(data->mutex); if(data->message_in){ data->cond_full.wait(lock); } if(i == (NumMsg-1)) std::sprintf(data->items, "%s", "last message"); else std::sprintf(data->items, "%s_%d", "my_trace", i); //Notify to the other process that there is a message data->cond_empty.notify_one(); //Mark message buffer as full data->message_in = true; } } catch(interprocess_exception &ex){
41
Boost.Interprocess
The second process opens the shared memory and prints each message until the "last message" message is received:
#include #include #include #include #include #include <boost/interprocess/shared_memory_object.hpp> <boost/interprocess/mapped_region.hpp> <boost/interprocess/sync/scoped_lock.hpp> <iostream> <cstring> "doc_anonymous_condition_shared_data.hpp"
using namespace boost::interprocess; int main () { //Create a shared memory object. shared_memory_object shm (open_only //only create ,"MySharedMemory" //name ,read_write //read-write mode ); try{ //Map the whole shared memory in this process mapped_region region (shm //What to map ,read_write //Map it as read-write ); //Get the address of the mapped region void * addr = region.get_address(); //Obtain a pointer to the shared structure trace_queue * data = static_cast<trace_queue*>(addr); //Print messages until the other process marks the end bool end_loop = false; do{ scoped_lock<interprocess_mutex> lock(data->mutex); if(!data->message_in){ data->cond_empty.wait(lock); } if(std::strcmp(data->items, "last message") == 0){ end_loop = true; } else{ //Print the message std::cout << data->items << std::endl; //Notify the other process that the buffer is empty data->message_in = false; data->cond_full.notify_one(); } } while(!end_loop); } catch(interprocess_exception &ex){
42
Boost.Interprocess
With condition variables, a process can block if it can't continue the work, and when the conditions to continue are met another process can wake it.
Semaphores
What's A Semaphore?
A semaphore is a synchronization mechanism between processes based in an internal count that offers two basic operations: Wait: Tests the value of the semaphore count, and waits if the value is less than or equal than 0. Otherwise, decrements the semaphore count. Post: Increments the semaphore count. If any process is blocked, one of those processes is awoken. If the initial semaphore count is initialized to 1, a Wait operation is equivalent to a mutex locking and Post is equivalent to a mutex unlocking. This type of semaphore is known as a binary semaphore. Although semaphores can be used like mutexes, they have a unique feature: unlike mutexes, a Post operation need not be executed by the same thread/process that executed the Wait operation.
interprocess_semaphore: An anonymous semaphore that can be placed in shared memory or memory mapped les.
#include <boost/interprocess/sync/named_semaphore.hpp>
43
Boost.Interprocess
#include <boost/interprocess/sync/interprocess_semaphore.hpp> struct shared_memory_buffer { enum { NumItems = 10 }; shared_memory_buffer() : mutex(1), nempty(NumItems), nstored(0) {} //Semaphores to protect and synchronize access boost::interprocess::interprocess_semaphore mutex, nempty, nstored; //Items to fill int items[NumItems]; };
This is the process main process. Creates the shared memory, places there the integer array and starts integers one by one, blocking if the array is full:
#include #include #include #include <boost/interprocess/shared_memory_object.hpp> <boost/interprocess/mapped_region.hpp> <iostream> "doc_anonymous_semaphore_shared_data.hpp"
using namespace boost::interprocess; int main () { //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create a shared memory object. shared_memory_object shm (create_only //only create ,"MySharedMemory" //name ,read_write //read-write mode ); //Set size shm.truncate(sizeof(shared_memory_buffer)); //Map the whole shared memory in this process mapped_region region (shm //What to map ,read_write //Map it as read-write ); //Get the address of the mapped region void * addr = region.get_address(); //Construct the shared structure in memory shared_memory_buffer * data = new (addr) shared_memory_buffer; const int NumMsg = 100; //Insert data in the array
44
Boost.Interprocess
for(int i = 0; i < NumMsg; ++i){ data->nempty.wait(); data->mutex.wait(); data->items[i % shared_memory_buffer::NumItems] = i; data->mutex.post(); data->nstored.post(); } return 0; }
The second process opens the shared memory and copies the received integers to it's own buffer:
#include #include #include #include <boost/interprocess/shared_memory_object.hpp> <boost/interprocess/mapped_region.hpp> <iostream> "doc_anonymous_semaphore_shared_data.hpp"
using namespace boost::interprocess; int main () { //Remove shared memory on destruction struct shm_remove { ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create a shared memory object. shared_memory_object shm (open_only //only create ,"MySharedMemory" //name ,read_write //read-write mode ); //Map the whole shared memory in this process mapped_region region (shm //What to map ,read_write //Map it as read-write ); //Get the address of the mapped region void * addr = region.get_address(); //Obtain the shared structure shared_memory_buffer * data = static_cast<shared_memory_buffer*>(addr); const int NumMsg = 100; int extracted_data [NumMsg]; //Extract the data for(int i = 0; i < NumMsg; ++i){ data->nstored.wait(); data->mutex.wait(); extracted_data[i] = data->items[i % shared_memory_buffer::NumItems]; data->mutex.post(); data->nempty.post(); } return 0; }
45
Boost.Interprocess
The same interprocess communication can be achieved with a condition variables and mutexes, but for several synchronization patterns, a semaphore is more efcient than a mutex/condition combination.
46
Boost.Interprocess
Sharable lock
As we can see, an upgradable mutex is a powerful synchronization utility that can improve the concurrency. However, if most of the time we have to modify the data, or the synchronized code section is very short, it's more efcient to use a plain mutex, since it has less overhead. Upgradable lock shines when the synchronized code section is bigger and there are more readers than modiers.
47
Boost.Interprocess
Effects: The calling thread tries to acquire exclusive ownership of the mutex waiting if necessary until no other thread has any ownership of the mutex (exclusive or other) or abs_time is reached. Returns: If acquires exclusive ownership, returns true. Otherwise returns false. Throws: interprocess_exception on error. void unlock() Precondition: The thread must have exclusive ownership of the mutex. Effects: The calling thread releases the exclusive ownership of the mutex. Throws: An exception derived from interprocess_exception on error.
48
Boost.Interprocess
Effects: The calling thread tries to obtain upgradable ownership of the mutex, and if another thread has exclusive or upgradable ownership of the mutex, waits until it can obtain the ownership. Throws: interprocess_exception on error. bool try_lock_upgradable() Effects: The calling thread tries to acquire upgradable ownership of the mutex without waiting. If no other thread has exclusive or upgradable ownership of the mutex this succeeds. Returns: If it can acquire upgradable ownership immediately returns true. If it has to wait, returns false. Throws: interprocess_exception on error. bool timed_lock_upgradable(const boost::posix_time::ptime &abs_time) Effects: The calling thread tries to acquire upgradable ownership of the mutex waiting if necessary until no other thread has exclusive ownership of the mutex or abs_time is reached. Returns: If acquires upgradable ownership, returns true. Otherwise returns false. Throws: interprocess_exception on error. void unlock_upgradable() Precondition: The thread must have upgradable ownership of the mutex. Effects: The calling thread releases the upgradable ownership of the mutex. Throws: An exception derived from interprocess_exception on error.
49
Boost.Interprocess
50
Boost.Interprocess
Important
boost::posix_time::ptime absolute time points used by Boost.Interprocess synchronization mechanisms are
interprocess_sharable_mutex: A non-recursive, anonymous sharable mutex that can be placed in shared memory or memory mapped les.
#include <boost/interprocess/sync/named_sharable_mutex.hpp>
named_sharable_mutex: A non-recursive, named sharable mutex. Boost.Interprocess offers the following upgradable mutex types:
#include <boost/interprocess/sync/interprocess_upgradable_mutex.hpp>
interprocess_upgradable_mutex: A non-recursive, anonymous upgradable mutex that can be placed in shared memory or memory mapped les.
#include <boost/interprocess/sync/named_upgradable_mutex.hpp>
#include <boost/interprocess/sync/upgradable_lock.hpp> sharable_lock calls unlock_sharable() in its destructor, and upgradable_lock calls unlock_upgradable() in its destructor,
51
Boost.Interprocess
using namespace boost::interprocess; SharableOrUpgradableMutex sh_or_up_mutex; { //This will call lock_sharable() sharable_lock<SharableOrUpgradableMutex> lock(sh_or_up_mutex); //Some code //The mutex will be unlocked here } { //This won't lock the mutex() sharable_lock<SharableOrUpgradableMutex> lock(sh_or_up_mutex, defer_lock); //Lock it on demand. This will call lock_sharable() lock.lock(); //Some code //The mutex will be unlocked here } { //This will call try_lock_sharable() sharable_lock<SharableOrUpgradableMutex> lock(sh_or_up_mutex, try_to_lock); //Check if the mutex has been successfully locked if(lock){ //Some code } //If the mutex was locked it will be unlocked } { boost::posix_time::ptime abs_time = ... //This will call timed_lock_sharable() scoped_lock<SharableOrUpgradableMutex> lock(sh_or_up_mutex, abs_time); //Check if the mutex has been successfully locked if(lock){ //Some code } //If the mutex was locked it will be unlocked } UpgradableMutex up_mutex; { //This will call lock_upgradable() upgradable_lock<UpgradableMutex> lock(up_mutex); //Some code //The mutex will be unlocked here } { //This won't lock the mutex() upgradable_lock<UpgradableMutex> lock(up_mutex, defer_lock);
52
Boost.Interprocess
//Lock it on demand. This will call lock_upgradable() lock.lock(); //Some code //The mutex will be unlocked here } { //This will call try_lock_upgradable() upgradable_lock<UpgradableMutex> lock(up_mutex, try_to_lock); //Check if the mutex has been successfully locked if(lock){ //Some code } //If the mutex was locked it will be unlocked } { boost::posix_time::ptime abs_time = ... //This will call timed_lock_upgradable() scoped_lock<UpgradableMutex> lock(up_mutex, abs_time); //Check if the mutex has been successfully locked if(lock){ //Some code } //If the mutex was locked it will be unlocked } upgradable_lock and sharable_lock offer more features and operations, see their reference for more informations
Important
boost::posix_time::ptime absolute time points used by Boost.Interprocess synchronization mechanisms are
53
Boost.Interprocess
using boost::interprocess; interprocess_upgradable_mutex mutex; //Acquire exclusive lock mutex.lock(); //Modify data //Atomically release exclusive lock and acquire sharable lock. //More threads can acquire the sharable lock and read the data. mutex.unlock_and_lock_sharable(); //Read data //Explicit unlocking mutex.unlock_sharable();
This can be simple, but in the presence of exceptions, it's complicated to know what type of lock the mutex had when the exception was thrown and what function we should call to unlock it:
try{ //Mutex operations } catch(...){ //What should we call? "unlock()" or "unlock_sharable()" //Is the mutex locked? }
As we can see, even if an exception is thrown at any moment, the mutex will be automatically unlocked calling the appropriate unlock() or unlock_sharable() method.
54
Boost.Interprocess
Guaranteed to succeed if using an innite waiting: Any transition that will succeed but needs to wait until all Sharable locks are released: Upgradable -> Scoped. Since this is a blocking operation, we can also choose not to wait innitely and just try or wait until a timeout is reached.
Important
boost::posix_time::ptime absolute time points used by Boost.Interprocess synchronization mechanisms are
55
Boost.Interprocess
but it's possible to execute the transfer with an unlocked source, due to explicit unlocking, a try, timed or a defer_lock constructor:
//These operations can leave the mutex unlocked! { //Try might fail scoped_lock<Mutex> sharable_lock<Mutex> } { //Timed operation might fail scoped_lock<Mutex> e_lock(mut, time); sharable_lock<Mutex> s_lock(move(e_lock)); } { //Avoid mutex locking scoped_lock<Mutex> sharable_lock<Mutex> } { //Explicitly call unlock scoped_lock<Mutex> e_lock(mut); e_lock.unlock(); //Mutex was explicitly unlocked sharable_lock<Mutex> s_lock(move(e_lock)); } e_lock(mut, defer_lock); s_lock(move(e_lock)); e_lock(mut, try_to_lock); s_lock(move(e_lock));
If the source mutex was not locked: The target lock does not execute the atomic unlock_xxx_and_lock_xxx operation.
56
Boost.Interprocess
The target lock is also unlocked. The source lock is released() and the ownership of the mutex is transferred to the target.
{ scoped_lock<Mutex> sharable_lock<Mutex> e_lock(mut, defer_lock); s_lock(move(e_lock));
Transfer Failures
When executing a lock transfer, the operation can fail: The executed atomic mutex unlock plus lock function might throw. The executed atomic function might be a "try" or "timed" function that can fail. In the rst case, the mutex ownership is not transferred and the source lock's destructor will unlock the mutex:
{ scoped_lock<Mutex> e_lock(mut, defer_lock);
//This operations throws because //"unlock_and_lock_sharable()" throws!!! sharable_lock<Mutex> s_lock(move(e_lock)); //Some code ... //e_lock's destructor will call "unlock()" }
In the second case, if an internal "try" or "timed" operation fails (returns "false") then the mutex ownership is not transferred, the source lock is unchanged and the target lock's state will the same as a default construction:
{ sharable_lock<Mutex> s_lock(mut);
//Internal "try_unlock_sharable_and_lock_upgradable()" returns false upgradable_lock<Mutex> u_lock(move(s_lock, try_to_lock)); assert(s_lock.mutex() assert(s_lock.owns() assert(u_lock.mutex() assert(u_lock.owns() == == == == &mut); true); 0); false);
57
Boost.Interprocess
File Locks
What's A File Lock?
A le lock is an interprocess synchronization mechanism to protect concurrent writes and reads to les using a mutex embedded in the le. This embedded mutex has sharable and exclusive locking capabilities. With a le lock, an existing le can be used as a mutex without the need of creating additional synchronization objects to control concurrent le reads or writes. Generally speaking, we can have two le locking capabilities: Advisory locking: The operating system kernel maintains a list of les that have been locked. But does not prevent writing to those les even if a process has acquired a sharable lock or does not prevent reading from the le when a process has acquired the exclusive lock. Any process can ignore an advisory lock. This means that advisory locks are for cooperating processes, processes that can trust each other. This is similar to a mutex protecting data in a shared memory segment: any process connected to that memory can overwrite the data but cooperative processes use mutexes to protect the data rst acquiring the mutex lock. Mandatory locking: The OS kernel checks every read and write request to verify that the operation can be performed according to the acquired lock. Reads and writes block until the lock is released. Boost.Interprocess implements advisory blocking because of portability reasons. This means that every process accessing to a le concurrently, must cooperate using le locks to synchronize the access. In some systems le locking can be even further rened, leading to record locking, where a user can specify a byte range within the le where the lock is applied. This allows concurrent write access by several processes if they need to access a different byte range in the le. Boost.Interprocess does not offer record locking for the moment, but might offer it in the future. To use a le lock just include:
#include <boost/interprocess/sync/file_lock.hpp>
A le locking is a class that has process lifetime. This means that if a process holding a le lock ends or crashes, the operating system will automatically unlock it. This feature is very useful in some situations where we want to assure automatic unlocking even when the process crashes and avoid leaving blocked resources in the system. A le lock is constructed using the name of the le as an argument:
#include <boost/interprocess/sync/file_lock.hpp> int main() { //This throws if the file does not exist or it can't //open it with read-write access! boost::interprocess::file_lock flock("my_file"); return 0; }
58
Boost.Interprocess
Throws: interprocess_exception on error. bool try_lock() Effects: The calling thread tries to acquire exclusive ownership of the le lock without waiting. If no other thread has exclusive or sharable ownership of the le lock, this succeeds. Returns: If it can acquire exclusive ownership immediately returns true. If it has to wait, returns false. Throws: interprocess_exception on error. bool timed_lock(const boost::posix_time::ptime &abs_time) Effects: The calling thread tries to acquire exclusive ownership of the le lock waiting if necessary until no other thread has exclusive or sharable ownership of the le lock or abs_time is reached. Returns: If acquires exclusive ownership, returns true. Otherwise returns false. Throws: interprocess_exception on error. void unlock() Precondition: The thread must have exclusive ownership of the le lock. Effects: The calling thread releases the exclusive ownership of the le lock. Throws: An exception derived from interprocess_exception on error. void lock_sharable() Effects: The calling thread tries to obtain sharable ownership of the le lock, and if another thread has exclusive ownership of the le lock, waits until it can obtain the ownership. Throws: interprocess_exception on error. bool try_lock_sharable() Effects: The calling thread tries to acquire sharable ownership of the le lock without waiting. If no other thread has exclusive ownership of the le lock, this succeeds. Returns: If it can acquire sharable ownership immediately returns true. If it has to wait, returns false. Throws: interprocess_exception on error. bool timed_lock_sharable(const boost::posix_time::ptime &abs_time) Effects: The calling thread tries to acquire sharable ownership of the le lock waiting if necessary until no other thread has exclusive ownership of the le lock or abs_time is reached. Returns: If acquires sharable ownership, returns true. Otherwise returns false. Throws: interprocess_exception on error.
59
Boost.Interprocess
void unlock_sharable() Precondition: The thread must have sharable ownership of the le lock. Effects: The calling thread releases the sharable ownership of the le lock. Throws: An exception derived from interprocess_exception on error. For more le locking methods, please file_lock reference.
Important
boost::posix_time::ptime absolute time points used by Boost.Interprocess synchronization mechanisms are
60
Boost.Interprocess
#include <boost/interprocess/sync/file_lock.hpp> #include <boost/interprocess/sync/scoped_lock.hpp> //... using namespace boost::interprocess; //This process writes the file // ... //Open the file lock file_lock f_lock("my_file"); { //Construct a sharable lock with the filel lock. //This will call "f_lock.lock()". scoped_lock<file_lock> e_lock(f_lock); //Now write the file... //The exclusive lock is automatically released by //e_lock's destructor }
However, lock transfers are only allowed between same type of locks, that is, from a sharable lock to another sharable lock or from a scoped lock to another scoped lock. A transfer from a scoped lock to a sharable lock is not allowed, because file_lock has no lock promotion or demotion functions like unlock_and_lock_sharable(). This will produce a compilation error:
//Open the file lock file_lock f_lock("my_file"); scoped_lock<file_lock> e_lock(f_lock); //Compilation error, f_lock has no "unlock_and_lock_sharable()" member! sharable_lock<file_lock> e_lock(move(f_lock));
61
Boost.Interprocess
Message Queue
What's A Message Queue?
A message queue is similar to a list of messages. Threads can put messages in the queue and they can also remove messages from the queue. Each message can have also a priority so that higher priority messages are read before lower priority messages. Each message has some attributes: A priority. The length of the message. The data (if length is bigger than 0). A thread can send a message to or receive a message from the message queue using 3 methods: Blocking: If the message queue is full when sending or the message queue is empty when receiving, the thread is blocked until there is room for a new message or there is a new message. Try: If the message queue is full when sending or the message queue is empty when receiving, the thread returns immediately with an error. Timed: If the message queue is full when sending or the message queue is empty when receiving, the thread retries the operation until succeeds (returning successful state) or a timeout is reached (returning a failure). A message queue just copies raw bytes between processes and does not send objects. This means that if we want to send an object using a message queue the object must be binary serializable. For example, we can send integers between processes but not a std::string. You should use Boost.Serialization or use advanced Boost.Interprocess mechanisms to send complex data between processes.
62
Boost.Interprocess
The Boost.Interprocess message queue is a named interprocess communication: the message queue is created with a name and it's opened with a name, just like a le. When creating a message queue, the user must specify the maximum message size and the maximum message number that the message queue can store. These parameters will dene the resources (for example the size of the shared memory used to implement the message queue if shared memory is used).
using boost::interprocess; //Create a message_queue. If the queue //exists throws an exception message_queue mq (create_only //only create ,"message_queue" //name ,100 //max message number ,100 //max message size );
using boost::interprocess; //Creates or opens a message_queue. If the queue //does not exist creates it, otherwise opens it. //Message number and size are ignored if the queue //is opened message_queue mq (open_or_create //open or create ,"message_queue" //name ,100 //max message number ,100 //max message size );
using boost::interprocess; //Opens a message_queue. If the queue //does not exist throws an exception. message_queue mq (open_only //only open ,"message_queue" //name );
The message queue is explicitly removed calling the static remove function:
using boost::interprocess; message_queue::remove("message_queue");
The function can fail if the message queue is still being used by any process.
In the following example, the rst process creates the message queue, and writes an array of integers on it. The other process just reads the array and checks that the sequence number is correct. This is the rst process:
63
Boost.Interprocess
#include <boost/interprocess/ipc/message_queue.hpp> #include <iostream> #include <vector> using namespace boost::interprocess; int main () { try{ //Erase previous message queue message_queue::remove("message_queue"); //Create a message_queue. message_queue mq (create_only ,"message_queue" ,100 ,sizeof(int) ); //Send 100 numbers for(int i = 0; i < 100; ++i){ mq.send(&i, sizeof(i), 0); } } catch(interprocess_exception &ex){ std::cout << ex.what() << std::endl; return 1; } return 0; }
64
Boost.Interprocess
#include <boost/interprocess/ipc/message_queue.hpp> #include <iostream> #include <vector> using namespace boost::interprocess; int main () { try{ //Open a message queue. message_queue mq (open_only //only create ,"message_queue" //name ); unsigned int priority; message_queue::size_type recvd_size; //Receive 100 numbers for(int i = 0; i < 100; ++i){ int number; mq.receive(&number, sizeof(number), recvd_size, priority); if(number != i || recvd_size != sizeof(number)) return 1; } } catch(interprocess_exception &ex){ message_queue::remove("message_queue"); std::cout << ex.what() << std::endl; return 1; } message_queue::remove("message_queue"); return 0; }
To know more about this class and all its operations, please see the message_queue class reference.
65
Boost.Interprocess
These classes can be customized with the following template parameters: CharType is the type of the character that will be used to identify the created named objects (for example, char or wchar_t)
66
Boost.Interprocess
MemoryAlgorithm is the memory algorithm used to allocate portions of the segment (for example, rbtree_best_t ). The internal typedefs of the memory algorithm also dene: The synchronization type (MemoryAlgorithm::mutex_family) to be used in all allocation operations. This allows the use of user-dened mutexes or avoiding internal locking (maybe code will be externally synchronized by the user). The Pointer type (MemoryAlgorithm::void_pointer) to be used by the memory allocation algorithm or additional helper structures (like a map to maintain object/name associations). All STL compatible allocators and containers to be used with this managed memory segment will use this pointer type. The pointer type will dene if the managed memory segment can be mapped between several processes. For example, if void_pointer is offset_ptr<void> we will be able to map the managed segment in different base addresses in each process. If void_pointer is void* only xed address mapping could be used. See Writing a new memory allocation algorithm for more details about memory algorithms. IndexType is the type of index that will be used to store the name-object association (for example, a map, a hash-map, or an ordered vector). This way, we can use char or wchar_t strings to identify created C++ objects in the memory segment, we can plug new shared memory allocation algorithms, and use the index type that is best suited to our needs.
they can be used to map the shared memory at different base addresses in different processes. If the user wants to map the shared memory in the same address in all processes and want to use raw pointers internally instead of offset pointers, Boost.Interprocess denes the following types:
67
Boost.Interprocess
//!Defines a managed shared memory with c-strings as keys for named objects, //!the default memory algorithm (with process-shared mutexes, //!and offset_ptr as internal pointers) as memory allocation algorithm //!and the default index type as the index. //!This class allows the shared memory to be mapped in different base //!in different processes*/ typedef basic_managed_shared_memory <char ,/*Default memory algorithm defining void * as void_pointer*/ ,/*Default index type*/> fixed_managed_shared_memory; //!Defines a managed shared memory with wide strings as keys for named objects, //!the default memory algorithm (with process-shared mutexes, //!and offset_ptr as internal pointers) as memory allocation algorithm //!and the default index type as the index. //!This class allows the shared memory to be mapped in different base //!in different processes typedef basic_managed_shared_memory <wchar_t ,/*Default memory algorithm defining void * as void_pointer*/ ,/*Default index type*/> wfixed_managed_shared_memory;
//1. Creates a new shared memory object // called "MySharedMemory". //2. Maps the whole object to this // process' address space. //3. Constructs some objects in shared memory // to implement managed features. //!! If anything fails, throws interprocess_exception // managed_shared_memory segment ( create_only , "MySharedMemory" //Shared memory object name , 65536); //Shared memory object size in bytes
68
Boost.Interprocess
//1. Opens a shared memory object // called "MySharedMemory". //2. Maps the whole object to this // process' address space. //3. Obtains pointers to constructed internal objects // to implement managed features. //!! If anything fails, throws interprocess_exception // managed_shared_memory segment (open_only, "MySharedMemory");//Shared memory object name
//1. If the segment was previously created // equivalent to "open_only" (size is ignored). //2. Otherwise, equivalent to "create_only" //!! If anything fails, throws interprocess_exception // managed_shared_memory segment ( open_or_create , "MySharedMemory" //Shared memory object name , 65536); //Shared memory object size in bytes
When the managed_shared_memory object is destroyed, the shared memory object is automatically unmapped, and all the resources are freed. To remove the shared memory object from the system you must use the shared_memory_object::remove function. Shared memory object removing might fail if any process still has the shared memory object mapped. The user can also map the managed shared memory in a xed address. This option is essential when using using fixed_managed_shared_memory. To do this, just add the mapping address as an extra parameter:
fixed_managed_shared_memory segment (open_only memory object name ,(void*)0x30000000 //Mapping address ,"MyFixedAddressSharedMemory" //Shared
This class has the same interface as basic_managed_shared_memory but uses native windows shared memory. Note that this managed class has the same lifetime issues as the windows shared memory: when the last process attached to the windows shared memory is detached from the memory (or ends/crashes) the memory is destroyed. So there is no persistence support for windows shared memory. To communicate between system services and user applications using managed_windows_shared_memory, please read the explanations given in chapter Native windows shared memory.
This class has nearly the same interface as basic_managed_shared_memory but uses XSI shared memory as backend. For more information about managed XSI shared memory capabilities, see basic_managed_xsi_shared_memory class reference.
69
Boost.Interprocess
70
Boost.Interprocess
//1. Creates a new file // called "MyMappedFile". //2. Maps the whole file to this // process' address space. //3. Constructs some objects in the memory mapped // file to implement managed features. //!! If anything fails, throws interprocess_exception // managed_mapped_file mfile (create_only, "MyMappedFile", 65536); //Mapped file size
//1. Opens a file // called "MyMappedFile". //2. Maps the whole file to this // process' address space. //3. Obtains pointers to constructed internal objects // to implement managed features. //!! If anything fails, throws interprocess_exception // managed_mapped_file mfile (open_only, "MyMappedFile");
//1. If the file was previously created // equivalent to "open_only". //2. Otherwise, equivalent to "open_only" (size is ignored) // //!! If anything fails, throws interprocess_exception // managed_mapped_file mfile (open_or_create, "MyMappedFile", 65536); //Mapped file size
When the managed_mapped_file object is destroyed, the le is automatically unmapped, and all the resources are freed. To remove the le from the lesystem you could use standard C std::remove or Boost.Filesystem's remove() functions, but le removing might fail if any process still has the le mapped in memory or the le is open by any process. To obtain a more portable behaviour, use file_mapping::remove(const char *) operation, which will remove the le even if it's being mapped. However, removal will fail in some OS systems if the le (eg. by C++ le streams) and no delete share permission was granted to the le. But in most common cases file_mapping::remove is portable enough. For more information about managed mapped le capabilities, see basic_managed_mapped_file class reference.
71
Boost.Interprocess
#include <boost/interprocess/managed_shared_memory.hpp> int main() { using namespace boost::interprocess; //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Managed memory segment that allocates portions of a shared memory //segment with the default management algorithm managed_shared_memory managed_shm(create_only,"MySharedMemory", 65536); //Allocate 100 bytes of memory from segment, throwing version void *ptr = managed_shm.allocate(100); //Deallocate it managed_shm.deallocate(ptr); //Non throwing version ptr = managed_shm.allocate(100, std::nothrow); //Deallocate it managed_shm.deallocate(ptr); return 0; }
72
Boost.Interprocess
//!Allocates and constructs an object of type MyType (throwing version) MyType *ptr = managed_memory_segment.construct<MyType>("Name") (par1, par2...); //!Allocates and constructs an array of objects of type MyType (throwing version) //!Each object receives the same parameters (par1, par2, ...) MyType *ptr = managed_memory_segment.construct<MyType>("Name")[count](par1, par2...); //!Tries to find a previously created object. If not present, allocates //!and constructs an object of type MyType (throwing version) MyType *ptr = managed_memory_segment.find_or_construct<MyType>("Name") (par1, par2...); //!Tries to find a previously created object. If not present, allocates and //!constructs an array of objects of type MyType (throwing version). Each object //!receives the same parameters (par1, par2, ...) MyType *ptr = managed_memory_segment.find_or_construct<MyType>("Name")[count](par1, par2...); //!Allocates and constructs an array of objects of type MyType (throwing version) //!Each object receives parameters returned with the expression (*it1++, *it2++,... ) MyType *ptr = managed_memory_segment.construct_it<MyType>("Name")[count](it1, it2...); //!Tries to find a previously created object. If not present, allocates and constructs //!an array of objects of type MyType (throwing version). Each object receives //!parameters returned with the expression (*it1++, *it2++,... ) MyType *ptr = managed_memory_segment.find_or_construct_it<MyType>("Name")[count](it1, it2...); //!Tries to find a previously created object. Returns a pointer to the object and the //!count (if it is not an array, returns 1). If not present, the returned pointer is 0 std::pair<MyType *,std::size_t> ret = managed_memory_segment.find<MyType>("Name"); //!Destroys the created object, returns false if not present bool destroyed = managed_memory_segment.destroy<MyType>("Name"); //!Destroys the created object via pointer managed_memory_segment.destroy_ptr(ptr);
All these functions have a non-throwing version, that is invoked with an additional parameter std::nothrow. For example, for simple object construction:
//!Allocates and constructs an object of type MyType (no throwing version) MyType *ptr = managed_memory_segment.construct<MyType>("Name", std::nothrow) (par1, par2...);
Find functions have no sense here, since anonymous objects have no name. We can only destroy the anonymous object via pointer.
73
Boost.Interprocess
// We can also destroy the unique object via pointer MyType *ptr = managed_memory_segment.construct<MyType>(unique_instance) (par1, par2...); managed_shared_memory.destroy_ptr(ptr);
The nd function obtains a pointer to the only object of type T that can be created using this "unique instance" mechanism.
Synchronization guarantees
One of the features of named/unique allocations/searches/destructions is that they are atomic. Named allocations use the recursive synchronization scheme dened by the internal mutex_family typedef dened of the memory allocation algorithm template parameter (MemoryAlgorithm). That is, the mutex type used to synchronize named/unique allocations is dened by the MemoryAlgorithm::mutex_family::recursive_mutex_type type. For shared memory, and memory mapped le based managed segments this recursive mutex is dened as interprocess_recursive_mutex. If two processes can call:
MyType *ptr = managed_shared_memory.find_or_construct<MyType>("Name")[count](par1, par2...);
at the same time, but only one process will create the object and the other will obtain a pointer to the created object. Raw allocation using allocate() can be called also safely while executing named/anonymous/unique allocations, just like when programming a multithreaded application inserting an object in a mutex-protected map does not block other threads from calling new[] while the map thread is searching the place where it has to insert the new object. The synchronization does happen once the map nds the correct place and it has to allocate raw memory to construct the new value. This means that if we are creating or searching for a lot of named objects, we only block creation/searches from other processes but we don't block another process if that process is inserting elements in a shared memory vector.
74
Boost.Interprocess
Each index has its own characteristics, like search-time, insertion time, deletion time, memory use, and memory allocation patterns. Boost.Interprocess offers 3 index types right now: boost::interprocess::at_map_index at_map_index: Based on boost::interprocess::at_map, an ordered vector similar to Loki library's AssocVector class, offers great search time and minimum memory use. But the vector must be reallocated when is full, so all data must be copied to the new buffer. Ideal when insertions are mainly in initialization time and in run-time we just need searches. boost::interprocess::map_index map_index: Based on boost::interprocess::map, a managed memory ready version of std::map. Since it's a node based container, it has no reallocations, the tree must be just rebalanced sometimes. Offers equilibrated insertion/deletion/search times with more overhead per node comparing to boost::interprocess::at_map_index. Ideal when searches/insertions/deletions are in random order. boost::interprocess::null_index null_index: This index is for people using a managed memory segment just for raw memory buffer allocations and they don't make use of named/unique allocations. This class is just empty and saves some space and compilation time. If you try to use named object creation with a managed memory segment using this index, you will get a compilation error. As an example, if we want to dene new managed shared memory class using boost::interprocess::map as the index type we just must specify [boost::interprocess::map_index map_index] as a template parameter:
//This managed memory segment can allocate objects with: // -> a wchar_t string as key // -> boost::interprocess::rbtree_best_fit with process-shared mutexes // as memory allocation algorithm. // -> boost::interprocess::map<...> as the index to store name/object mappings // typedef boost::interprocess::basic_managed_shared_memory < wchar_t , boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, off set_ptr<void> > , boost::interprocess::map_index > my_managed_shared_memory;
Boost.Interprocess plans to offer an unordered_map based index as soon as this container is included in Boost. If these indexes are not enough for you, you can dene your own index type. To know how to do this, go to Building custom indexes section.
Segment Manager
All Boost.Interprocess managed memory segment classes construct in their respective memory segments (shared memory, memory mapped les, heap memory...) some structures to implement the memory management algorithm, named allocations, synchronization objects... All these objects are encapsulated in a single object called segment manager. A managed memory mapped le and a managed shared memory use the same segment manager to implement all managed memory segment features, due to the fact that a segment manager is a class that manages a xed size memory buffer. Since both shared memory or memory mapped les are accessed though a mapped region, and a mapped region is a xed size memory buffer, a single segment manager class can manage several managed memory segment types. Some Boost.Interprocess classes require a pointer to the segment manager in their constructors, and the segment manager can be obtained from any managed memory segment using get_segment_manager member:
managed_shared_memory::segment_manager *seg_manager = managed_shm.get_segment_manager();
75
Boost.Interprocess
Name of the object: If it's a named instance, the name used in the construction function is returned, otherwise 0 is returned. Length of the object: Returns the number of elements of the object (1 if it's a single value, >=1 if it's an array). The type of construction: Whether the object was constructed using a named, unique or anonymous construction. Here is an example showing this functionality:
#include <boost/interprocess/managed_shared_memory.hpp> #include <cassert> #include <cstring> class my_class { //... }; int main() { using namespace boost::interprocess; //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; managed_shared_memory managed_shm(create_only, "MySharedMemory", 10000*sizeof(std::size_t)); //Construct objects my_class *named_object = managed_shm.construct<my_class>("Object name")[1](); my_class *unique_object = managed_shm.construct<my_class>(unique_instance)[2](); my_class *anon_object = managed_shm.construct<my_class>(anonymous_instance)[3](); //Now test "get_instance_name" function. assert(0 == std::strcmp(managed_shared_memory::get_instance_name(named_object), "Object name")); assert(0 == managed_shared_memory::get_instance_name(unique_object)); assert(0 == managed_shared_memory::get_instance_name(anon_object)); //Now test "get_instance_type" function. assert(named_type == managed_shared_memory::get_instance_type(named_object)); assert(unique_type == managed_shared_memory::get_instance_type(unique_object)); assert(anonymous_type == managed_shared_memory::get_instance_type(anon_object)); //Now test "get_instance_length" function. assert(1 == managed_shared_memory::get_instance_length(named_object)); assert(2 == managed_shared_memory::get_instance_length(unique_object)); assert(3 == managed_shared_memory::get_instance_length(anon_object)); managed_shm.destroy_ptr(named_object); managed_shm.destroy_ptr(unique_object); managed_shm.destroy_ptr(anon_object); return 0; }
76
Boost.Interprocess
To achieve this, the programmer can use the atomic_func() function offered by managed classes:
//This object function will create several named objects create_several_objects_func func(/**/); //While executing the function, no other process will be //able to create or destroy objects managed_memory.atomic_func(func);
Note that atomic_func does not prevent other processes from allocating raw memory or executing member functions for already constructed objects (e.g.: another process might be pushing elements into a vector placed in the segment). The atomic function only blocks named, unique and anonymous creation, search and destruction (concurrent calls to construct<>, find<>, find_or_construct<>, destroy<>...) from other processes.
Test internal structures of the managed segment. Returns true if no errors are detected:
managed_shm.check_sanity();
Obtain the number of named and unique objects allocated in the segment:
managed_shm.get_num_named_objects(); managed_shm.get_num_unique_objects();
77
Boost.Interprocess
should be modifying the le/shared memory while the growing/shrinking process is performed. Otherwise, the managed segment will be corrupted.
78
Boost.Interprocess
managed_shm.reserve_named_objects(1000); managed_shm.reserve_unique_objects(1000);
Managed memory segments also offer the possibility to iterate through constructed named and unique objects for debugging purposes. Caution: this iteration is not thread-safe so the user should make sure that no other thread is manipulating named or unique indexes (creating, erasing, reserving...) in the segment. Other operations not involving indexes can be concurrently executed (raw memory allocation/deallocations, for example). The following functions return constant iterators to the range of named and unique objects stored in the managed segment. Depending on the index type, iterators might be invalidated after a named or unique creation/erasure/reserve operation:
typedef managed_shared_memory::const_named_iterator const_named_it; const_named_it named_beg = managed_shm.named_begin(); const_named_it named_end = managed_shm.named_end(); typedef managed_shared_memory::const_unique_iterator const_unique_it; const_unique_it unique_beg = managed_shm.unique_begin(); const_unique_it unique_end = managed_shm.unique_end(); for(; named_beg != named_end; ++named_beg){ //A pointer to the name of the named object const managed_shared_memory::char_type *name = named_beg->name(); //The length of the name std::size_t name_len = named_beg->name_length(); //A constant void pointer to the named object const void *value = named_beg->value(); } for(; unique_beg != unique_end; ++unique_beg){ //The typeid(T).name() of the unique object const char *typeid_name = unique_beg->name(); //The length of the name std::size_t name_len = unique_beg->name_length(); //A constant void pointer to the unique object const void *value = unique_beg->value(); }
79
Boost.Interprocess
This allocation is similar to the previously shown raw memory allocation but it takes an additional parameter specifying the alignment. There is a restriction for the alignment: the alignment must be power of two. If a user wants to allocate many aligned blocks (for example aligned to 128 bytes), the size that minimizes the memory waste is a value that's is nearly a multiple of that alignment (for example 2*128 - some bytes). The reason for this is that every memory allocation usually needs some additional metadata in the rst bytes of the allocated buffer. If the user can know the value of "some bytes" and if the rst bytes of a free block of memory are used to fulll the aligned allocation, the rest of the block can be left also aligned and ready for the next aligned allocation. Note that requesting a size multiple of the alignment is not optimal because lefts the next block of memory unaligned due to the needed metadata. Once the programmer knows the size of the payload of every memory allocation, he can request a size that will be optimal to allocate aligned chunks of memory maximizing both the size of the request and the possibilities of future aligned allocations. This information is stored in the PayloadPerAllocation constant of managed memory segments. Here is a small example showing how aligned allocation is used:
#include <boost/interprocess/managed_shared_memory.hpp> #include <cassert> int main() { using namespace boost::interprocess; //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Managed memory segment that allocates portions of a shared memory //segment with the default management algorithm managed_shared_memory managed_shm(create_only, "MySharedMemory", 65536); const std::size_t Alignment = 128; //Allocate 100 bytes aligned to Alignment from segment, throwing version void *ptr = managed_shm.allocate_aligned(100, Alignment); //Check alignment assert((static_cast<char*>(ptr)-static_cast<char*>(0)) % Alignment == 0); //Deallocate it managed_shm.deallocate(ptr); //Non throwing version ptr = managed_shm.allocate_aligned(100, Alignment, std::nothrow); //Check alignment assert((static_cast<char*>(ptr)-static_cast<char*>(0)) % Alignment == 0); //Deallocate it managed_shm.deallocate(ptr); //If we want to efficiently allocate aligned blocks of memory //use managed_shared_memory::PayloadPerAllocation value assert(Alignment > managed_shared_memory::PayloadPerAllocation); //This allocation will maximize the size of the aligned memory //and will increase the possibility of finding more aligned memory ptr = managed_shm.allocate_aligned (3*Alignment - managed_shared_memory::PayloadPerAllocation, Alignment);
80
Boost.Interprocess
All functions return a multiallocation iterator that can be used to obtain pointers to memory the user can overwrite. A multiallocation_iterator: Becomes invalidated if the memory is pointing to is deallocated or the next iterators (which previously were reachable with operator++) become invalid. Returned from allocate_many can be checked in a boolean expression to know if the allocation has been successful. A default constructed multiallocation iterator indicates both an invalid iterator and the "end" iterator. Dereferencing an iterator (operator *()) returns a char & referencing the rst byte user can overwrite in the memory buffer. The iterator category depends on the memory allocation algorithm, but it's at least a forward iterator. Here is a small example showing all this functionality:
81
Boost.Interprocess
int main() { using namespace boost::interprocess; typedef managed_shared_memory::multiallocation_chain multiallocation_chain; //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; managed_shared_memory managed_shm(create_only,"MySharedMemory", 65536); //Allocate 16 elements of 100 bytes in a single call. Non-throwing version. multiallocation_chain chain(managed_shm.allocate_many(100, 16, std::nothrow)); //Check if the memory allocation was successful if(chain.empty()) return 1; //Allocated buffers std::vector<void*> allocated_buffers; //Initialize our data while(!chain.empty()){ void *buf = chain.pop_front(); allocated_buffers.push_back(buf); //The iterator must be incremented before overwriting memory //because otherwise, the iterator is invalidated. std::memset(buf, 0, 100); } //Now deallocate while(!allocated_buffers.empty()){ managed_shm.deallocate(allocated_buffers.back()); allocated_buffers.pop_back(); } //Allocate 10 buffers of different sizes in a single call. Throwing version managed_shared_memory::size_type sizes[10]; for(std::size_t i = 0; i < 10; ++i) sizes[i] = i*3; chain = managed_shm.allocate_many(sizes, 10); managed_shm.deallocate_many(boost::move(chain)); return 0; }
Allocating N buffers of the same size improves the performance of pools and node containers (for example STL-like lists): when inserting a range of forward iterators in a STL-like list, the insertion function can detect the number of needed elements and allocate in a single call. The nodes still can be deallocated. Allocating N buffers of different sizes can be used to speed up allocation in cases where several objects must always be allocated at the same time but deallocated at different times. For example, a class might perform several initial allocations (some header data for a network packet, for example) in its constructor but also allocations of buffers that might be reallocated in the future (the data to
82
Boost.Interprocess
be sent through the network). Instead of allocating all the data independently, the constructor might use allocate_many() to speed up the initialization, but it still can deallocate and expand the memory of the variable size element. In general, allocate_many is useful with large values of N. Overuse of allocate_many can increase the effective memory usage, because it can't reuse existing non-contiguous memory fragments that might be available for some of the elements.
= = = = =
boost::interprocess::allocation_type command std::size_t limit_size std::size_t preferred_size std::size_t &received_size T *reuse_ptr = 0);
Preconditions for the function: If the parameter command contains the value boost::interprocess::shrink_in_place it can't contain any of these values: boost::interprocess::expand_fwd, boost::interprocess::expand_bwd. If the parameter command contains boost::interprocess::expand_fwd or boost::interprocess::expand_bwd, the parameter reuse_ptr must be non-null and returned by a previous allocation function. If the parameter command contains the value boost::interprocess::shrink_in_place, the parameter limit_size must be equal or greater than the parameter preferred_size. If the parameter command contains any of these values: boost::interprocess::expand_fwd or boost::interprocess::expand_bwd, the parameter limit_size must be equal or less than the parameter preferred_size.
83
Boost.Interprocess
Which are the effects of this function: If the parameter command contains the value boost::interprocess::shrink_in_place, the function will try to reduce the size of the memory block referenced by pointer reuse_ptr to the value preferred_size moving only the end of the block. If it's not possible, it will try to reduce the size of the memory block as much as possible as long as this results in size(p) <= limit_size. Success is reported only if this results in preferred_size <= size(p) and size(p) <= limit_size. If the parameter command only contains the value boost::interprocess::expand_fwd (with optional additional boost::interprocess::nothrow_allocation), the allocator will try to increase the size of the memory block referenced by pointer reuse moving only the end of the block to the value preferred_size. If it's not possible, it will try to increase the size of the memory block as much as possible as long as this results in size(p) >= limit_size. Success is reported only if this results in limit_size <= size(p). If the parameter command only contains the value boost::interprocess::expand_bwd (with optional additional boost::interprocess::nothrow_allocation), the allocator will try to increase the size of the memory block referenced by pointer reuse_ptr only moving the start of the block to a returned new position new_ptr. If it's not possible, it will try to move the start of the block as much as possible as long as this results in size(new_ptr) >= limit_size. Success is reported only if this results in limit_size <= size(new_ptr). If the parameter command only contains the value boost::interprocess::allocate_new (with optional additional boost::interprocess::nothrow_allocation), the allocator will try to allocate memory for preferred_size objects. If it's not possible it will try to allocate memory for at least limit_size objects. If the parameter command only contains a combination of boost::interprocess::expand_fwd and boost::interprocess::allocate_new, (with optional additional boost::interprocess::nothrow_allocation) the allocator will try rst the forward expansion. If this fails, it would try a new allocation. If the parameter command only contains a combination of boost::interprocess::expand_bwd and boost::interprocess::allocate_new (with optional additional boost::interprocess::nothrow_allocation), the allocator will try rst to obtain preferred_size objects using both methods if necessary. If this fails, it will try to obtain limit_size objects using both methods if necessary. If the parameter command only contains a combination of boost::interprocess::expand_fwd and boost::interprocess::expand_bwd (with optional additional boost::interprocess::nothrow_allocation), the allocator will try rst forward expansion. If this fails it will try to obtain preferred_size objects using backwards expansion or a combination of forward and backwards expansion. If this fails, it will try to obtain limit_size objects using both methods if necessary. If the parameter command only contains a combination of allocation_new, boost::interprocess::expand_fwd and boost::interprocess::expand_bwd, (with optional additional boost::interprocess::nothrow_allocation) the allocator will try rst forward expansion. If this fails it will try to obtain preferred_size objects using new allocation, backwards expansion or a combination of forward and backwards expansion. If this fails, it will try to obtain limit_size objects using the same methods. The allocator always writes the size or the expanded/allocated/shrunk memory block in received_size. On failure the allocator writes in received_size a possibly successful limit_size parameter for a new call. Throws an exception if two conditions are met: The allocator is unable to allocate/expand/shrink the memory or there is an error in preconditions The parameter command does not contain boost::interprocess::nothrow_allocation. This function returns: The address of the allocated memory or the new address of the expanded memory as the rst member of the pair. If the parameter command contains boost::interprocess::nothrow_allocation the rst member will be 0 if the allocation/expansion fails or there is an error in preconditions. The second member of the pair will be false if the memory has been allocated, true if the memory has been expanded. If the rst member is 0, the second member has an undened value.
84
Boost.Interprocess
Notes: If the user chooses char as template argument the returned buffer will be suitably aligned to hold any type. If the user chooses char as template argument and a backwards expansion is performed, although properly aligned, the returned buffer might not be suitable because the distance between the new beginning and the old beginning might not multiple of the type the user wants to construct, since due to internal restrictions the expansion can be slightly bigger than the requested bytes. When performing backwards expansion, if you have already constructed objects in the old buffer, make sure to specify correctly the type. Here is a small example that shows the use of allocation_command:
#include <boost/interprocess/managed_shared_memory.hpp> #include <cassert> int main() { using namespace boost::interprocess; //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Managed memory segment that allocates portions of a shared memory //segment with the default management algorithm managed_shared_memory managed_shm(create_only, "MySharedMemory", 10000*sizeof(std::size_t)); //Allocate at least 100 bytes, 1000 bytes if possible managed_shared_memory::size_type min_size = 100, preferred_size = 1000; managed_shared_memory::size_type received_size; std::size_t *ptr = managed_shm.allocation_command<std::size_t> (boost::interprocess::allocate_new, min_size, preferred_size, received_size).first; //Received size must be bigger than min_size assert(received_size >= min_size); //Get free memory managed_shared_memory::size_type free_memory_after_allocation = managed_shm.get_free_memory(); //Now write the data for(std::size_t i = 0; i < received_size; ++i) ptr[i] = i; //Now try to triplicate the buffer. We won't admit an expansion //lower to the double of the original buffer. //This "should" be successful since no other class is allocating //memory from the segment managed_shared_memory::size_type expanded_size; std::pair<std::size_t *, bool> ret = managed_shm.allocation_command (boost::interprocess::expand_fwd, received_size*2, received_size*3, expanded_size, ptr); //Check invariants assert(ret.second == true); assert(ret.first == ptr); assert(expanded_size >= received_size*2); //Get free memory and compare managed_shared_memory::size_type free_memory_after_expansion = managed_shm.get_free_memory(); assert(free_memory_after_expansion < free_memory_after_allocation);
85
Boost.Interprocess
ptr[i] = i;
//Try to shrink approximately to min_size, but the new size //should be smaller than min_size*2. //This "should" be successful since no other class is allocating //memory from the segment managed_shared_memory::size_type shrunk_size; ret = managed_shm.allocation_command (boost::interprocess::shrink_in_place, min_size*2, min_size, shrunk_size, ptr); //Check invariants assert(ret.second == true); assert(ret.first == ptr); assert(shrunk_size <= min_size*2); assert(shrunk_size >= min_size); //Get free memory and compare managed_shared_memory::size_type free_memory_after_shrinking = managed_shm.get_free_memory(); assert(free_memory_after_shrinking > free_memory_after_expansion); //Deallocate the buffer managed_shm.deallocate(ptr); return 0; } allocation_command is a very powerful function that can lead to important performance gains. It's specially useful when program-
ming vector-like data structures where the programmer can minimize both the number of allocation requests and the memory waste.
Opening managed shared memory and mapped files with Copy On Write or Read Only modes
When mapping a memory segment based on shared memory or les, there is an option to open them using open_copy_on_write option. This option is similar to open_only but every change the programmer does with this managed segment is kept private to this process and is not translated to the underlying device (shared memory or le). The underlying shared memory or le is opened as read-only so several processes can share an initial managed segment and make private changes to it. If many processes open a managed segment in copy on write mode and not modied pages from the managed segment will be shared between all those processes, with considerable memory savings. Opening managed shared memory and mapped les with open_read_only maps the underlying device in memory with read-only attributes. This means that any attempt to write that memory, either creating objects or locking any mutex might result in an pagefault error (and thus, program termination) from the OS. Read-only mode opens the underlying device (shared memory, le...) in read-only mode and can result in considerable memory savings if several processes just want to process a managed memory segment without modifying it. Read-only mode operations are limited: Read-only mode must be used only from managed classes. If the programmer obtains the segment manager and tries to use it directly it might result in an access violation. The reason for this is that the segment manager is placed in the underlying device and does not nothing about the mode it's been mapped in memory. Only const member functions from managed segments should be used. Additionally, the find<> member function avoids using internal locks and can be used to look for named and unique objects. Here is an example that shows the use of these two open modes:
86
Boost.Interprocess
int main() { using namespace boost::interprocess; //Define file names const char *ManagedFile = "MyManagedFile"; const char *ManagedFile2 = "MyManagedFile2"; //Try to erase any previous managed segment with the same name file_mapping::remove(ManagedFile); file_mapping::remove(ManagedFile2); remove_file_on_destroy destroyer1(ManagedFile); remove_file_on_destroy destroyer2(ManagedFile2); { //Create an named integer in a managed mapped file managed_mapped_file managed_file(create_only, ManagedFile, 65536); managed_file.construct<int>("MyInt")(0u); //Now create a copy on write version managed_mapped_file managed_file_cow(open_copy_on_write, ManagedFile); //Erase the int and create a new one if(!managed_file_cow.destroy<int>("MyInt")) throw int(0); managed_file_cow.construct<int>("MyInt2"); //Check changes if(managed_file_cow.find<int>("MyInt").first && !managed_file_cow.find<int>("MyInt2").first) throw int(0); //Check the original is intact if(!managed_file.find<int>("MyInt").first && managed_file.find<int>("MyInt2").first) throw int(0); //Dump the modified copy on write segment to a file std::fstream file(ManagedFile2, std::ios_base::out | std::ios_base::binary); if(!file) throw int(0); file.write(static_cast<const char *>(managed_file_cow.get_address()), (std::streamsize)man aged_file_cow.get_size()); } //Now open the modified file and test changes managed_mapped_file managed_file_cow2(open_only, ManagedFile2); if(managed_file_cow2.find<int>("MyInt").first && !managed_file_cow2.find<int>("My Int2").first) throw int(0); } { //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); //Check the number of named objects using the iterators {
87
Boost.Interprocess
Managed External Buffer: Constructing all Boost.Interprocess objects in a user provided buffer
Sometimes, the user wants to create simple objects, STL compatible containers, STL compatible strings and more, all in a single buffer. This buffer could be a big static buffer, a memory-mapped auxiliary device or any other user buffer. This would allow an easy serialization and we-ll just need to copy the buffer to duplicate all the objects created in the original buffer, including complex objects like maps, lists.... Boost.Interprocess offers managed memory segment classes to handle user provided buffers that allow the same functionality as shared memory classes:
88
Boost.Interprocess
//Named object creation managed memory segment //All objects are constructed in a user provided buffer template < class CharType, class MemoryAlgorithm, template<class IndexConfig> class IndexType > class basic_managed_external_buffer; //Named object creation managed memory segment //All objects are constructed in a user provided buffer // Names are c-strings, // Default memory management algorithm // (rbtree_best_fit with no mutexes and relative pointers) // Name-object mappings are stored in the default index type (flat_map) typedef basic_managed_external_buffer < char, rbtree_best_fit<null_mutex_family, offset_ptr<void> >, flat_map_index > managed_external_buffer; //Named object creation managed memory segment //All objects are constructed in a user provided buffer // Names are wide-strings, // Default memory management algorithm // (rbtree_best_fit with no mutexes and relative pointers) // Name-object mappings are stored in the default index type (flat_map) typedef basic_managed_external_buffer< wchar_t, rbtree_best_fit<null_mutex_family, offset_ptr<void> >, flat_map_index > wmanaged_external_buffer;
To use a managed external buffer, you must include the following header:
#include <boost/interprocess/managed_external_buffer.hpp>
89
Boost.Interprocess
int main() { using namespace boost::interprocess; //Create the static memory who will store all objects const int memsize = 65536; static boost::aligned_storage<memsize>::type static_buffer; //This managed memory will construct objects associated with //a wide string in the static buffer wmanaged_external_buffer objects_in_static_memory (create_only, &static_buffer, memsize); //We optimize resources to create 100 named objects in the static buffer objects_in_static_memory.reserve_named_objects(100); //Alias an integer node allocator type //This allocator will allocate memory inside the static buffer typedef allocator<int, wmanaged_external_buffer::segment_manager> allocator_t; //Alias a STL compatible list to be constructed in the static buffer typedef list<int, allocator_t> MyBufferList; //The list must be initialized with the allocator //All objects created with objects_in_static_memory will //be stored in the static_buffer! MyBufferList *list = objects_in_static_memory.construct<MyBufferList>(L"MyList") (objects_in_static_memory.get_segment_manager()); //Since the allocation algorithm from wmanaged_external_buffer uses relative //pointers and all the pointers constructed int the static memory point //to objects in the same segment, we can create another static buffer //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 (open_only, &static_buffer2, memsize); //Check that "MyList" has been duplicated in the second buffer if(!objects_in_static_memory2.find<MyBufferList>(L"MyList").first) return 1; //Destroy the lists from the static buffers objects_in_static_memory.destroy<MyBufferList>(L"MyList"); objects_in_static_memory2.destroy<MyBufferList>(L"MyList"); return 0; }
Boost.Interprocess STL compatible allocators can also be used to place STL compatible containers in the user segment.
basic_managed_external_buffer can be also useful to build small databases for embedded systems limiting the size of the
used memory to a predened memory chunk, instead of letting the database fragment the heap memory.
90
Boost.Interprocess
To use a managed heap memory, you must include the following header:
#include <boost/interprocess/managed_heap_memory.hpp>
The use is exactly the same as basic_managed_external_buffer, except that memory is created by the managed memory segment itself using dynamic (new/delete) memory. basic_managed_heap_memory also offers a grow(std::size_t extra_bytes) function that tries to resize internal heap memory so that we have room for more objects. But be careful, if memory is reallocated, the old buffer will be copied into the new one so all the objects will be binary-copied to the new buffer. To be able to use this function, all pointers constructed in the heap buffer that point to objects in the heap buffer must be relative pointers (for example offset_ptr). Otherwise, the result is undened. Here is an example:
91
Boost.Interprocess
using namespace boost::interprocess; typedef list<int, allocator<int, managed_heap_memory::segment_manager> > MyList; int main () { //We will create a buffer of 1000 bytes to store a list managed_heap_memory heap_memory(1000); MyList * mylist = heap_memory.construct<MyList>("MyList") (heap_memory.get_segment_manager()); //Obtain handle, that identifies the list in the buffer managed_heap_memory::handle_t list_handle = heap_memory.get_handle_from_address(mylist); //Fill list until there is no more memory in the buffer try{ while(1) { mylist->insert(mylist->begin(), 0); } } catch(const bad_alloc &){ //memory is full } //Let's obtain the size of the list MyList::size_type old_size = mylist->size(); //To make the list bigger, let's increase the heap buffer //in 1000 bytes more. heap_memory.grow(1000); //If memory has been reallocated, the old pointer is invalid, so //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) { mylist->insert(mylist->begin(), 0); } } catch(const bad_alloc &){ //memory is full } //Let's obtain the new size of the list MyList::size_type new_size = mylist->size(); assert(new_size > old_size); //Destroy list heap_memory.destroy_ptr(mylist); return 0; }
92
Boost.Interprocess
= 65536; = 100;
//Allocate a memory buffer to hold the destiny database using vector<char> std::vector<char> buffer_destiny(BufferSize, 0); message_queue::remove(test::get_process_id_name()); { //Create the message-queues message_queue mq1(create_only, test::get_process_id_name(), 1, MaxMsgSize); //Open previously created message-queue simulating other process message_queue mq2(open_only, test::get_process_id_name()); //A managed heap memory to create the origin database managed_heap_memory db_origin(buffer_destiny.size()); //Construct the map in the first buffer MyMap *map1 = db_origin.construct<MyMap>("MyMap") (MyLess(), db_origin.get_segment_manager()); if(!map1) return false;
93
Boost.Interprocess
//Fill map1 until is full try{ std::size_t i = 0; while(1){ (*map1)[i] = i; ++i; } } catch(boost::interprocess::bad_alloc &){} //Data control data sending through the message queue std::size_t sent = 0; message_queue::size_type recvd = 0; message_queue::size_type total_recvd = 0; unsigned int priority; //Send whole first buffer through the mq1, read it //through mq2 to the second buffer while(1){ //Send a fragment of buffer1 through mq1 std::size_t bytes_to_send = MaxMsgSize < (db_origin.get_size() - sent) ? MaxMsgSize : (db_origin.get_size() - sent); mq1.send( &static_cast<char*>(db_origin.get_address())[sent] , bytes_to_send , 0); sent += bytes_to_send; //Receive the fragment through mq2 to buffer_destiny mq2.receive( &buffer_destiny[total_recvd] , BufferSize - recvd , recvd , priority); total_recvd += recvd; //Check if we have received all the buffer if(total_recvd == BufferSize){ break; } } //The buffer will contain a copy of the original database //so let's interpret the buffer with managed_external_buffer managed_external_buffer db_destiny(open_only, &buffer_destiny[0], BufferSize); //Let's find the map std::pair<MyMap *, managed_external_buffer::size_type> ret = db_destiny.find<MyMap>("MyMap"); MyMap *map2 = ret.first; //Check if we have found it if(!map2){ return false; } //Check if it is a single variable (not an array) if(ret.second != 1){ return false; } //Now let's compare size if(map1->size() != map2->size()){ return false; }
94
Boost.Interprocess
//Now let's compare all db values MyMap::size_type num_elements = map1->size(); for(std::size_t i = 0; i < num_elements; ++i){ if((*map1)[i] != (*map2)[i]){ return false; } } //Destroy maps from db-s db_origin.destroy_ptr(map1); db_destiny.destroy_ptr(map2); } message_queue::remove(test::get_process_id_name()); return true; }
95
Boost.Interprocess
Boost.Interprocess allocators also have a get_segment_manager() function that returns the underlying segment manager that they have received in the constructor:
Allocator::segment_manager s = alloc_instance.get_segment_manager(); AnotherType *a = s->construct<AnotherType>(anonymous_instance)(/*Parameters*/);
96
Boost.Interprocess
Unfortunately, this approach is not valid with shared memory. Using heap allocators, if Group1 of node allocators share a common segregated storage, and Group2 share another common segregated storage, a simple pointer swapping is needed to swap an allocator of Group1 and another allocator of Group2. But when the user wants to swap two shared memory allocators, each one placed in a different shared memory segment, this is not possible. As generally shared memory is mapped in different addresses in each process, a pointer placed in one segment can't point to any object placed in other shared memory segment, since in each process, the distance between the segments is different. However, if both shared memory allocators are in the same segment, a non-throwing swap is possible, just like heap allocators. Until a nal resolution is achieved. Boost.Interprocess allocators implement a non-throwing swap function that swaps internal pointers. If an allocator placed in a shared memory segment is swapped with other placed in a different shared memory segment, the result is undened. But a crash is quite sure.
The allocator just provides the needed typedefs and forwards all allocation and deallocation requests to the segment manager passed in the constructor, just like std::allocator forwards the requests to operator new[]. Using allocator is straightforward:
97
Boost.Interprocess
#include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/allocators/allocator.hpp> #include <cassert> using namespace boost::interprocess; int main () { //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create shared memory managed_shared_memory segment(create_only, "MySharedMemory", 65536);
//segment name
//Create an allocator that allocates ints from the managed segment allocator<int, managed_shared_memory::segment_manager> allocator_instance(segment.get_segment_manager()); //Copy constructed allocator is equal allocator<int, managed_shared_memory::segment_manager> allocator_instance2(allocator_instance); assert(allocator_instance2 == allocator_instance); //Allocate and deallocate memory for 100 ints allocator_instance2.deallocate(allocator_instance.allocate(100), 100); return 0; }
the functions explained in the Properties of Boost.Interprocess allocators. All these allocators are templatized by 3 parameters: class T: The type to be allocated.
98
Boost.Interprocess
class SegmentManager: The type of the segment manager that will be passed in the constructor. std::size_t NodesPerChunk: The number of nodes that a memory chunk will contain. This value will dene the size of the memory the pool will request to the segment manager when the pool runs out of nodes. This parameter has a default value. These allocators also offer the deallocate_free_chunks() function. This function will traverse all the memory chunks of the pool and will return to the managed memory segment the free chunks of memory. If this function is not used, deallocating the free chunks does not happen until the pool is destroyed so the only way to return memory allocated by the pool to the segment before destructing the pool is calling manually this function. This function is quite time-consuming because it has quadratic complexity (O(N^2)).
99
Boost.Interprocess
#include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/allocators/node_allocator.hpp> #include <cassert> using namespace boost::interprocess; int main () { //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create shared memory managed_shared_memory segment(create_only, "MySharedMemory", 65536);
//segment name
//Create a node_allocator that allocates ints from the managed segment //The number of chunks per segment is the default value typedef node_allocator<int, managed_shared_memory::segment_manager> node_allocator_t; node_allocator_t allocator_instance(segment.get_segment_manager()); //Create another node_allocator. Since the segment manager address //is the same, this node_allocator will be //attached to the same pool so "allocator_instance2" can deallocate //nodes allocated by "allocator_instance" node_allocator_t allocator_instance2(segment.get_segment_manager()); //Create another node_allocator using copy-constructor. This //node_allocator will also be attached to the same pool node_allocator_t allocator_instance3(allocator_instance2); //All allocators are equal assert(allocator_instance == allocator_instance2); assert(allocator_instance2 == allocator_instance3); //So memory allocated with one can be deallocated with another allocator_instance2.deallocate(allocator_instance.allocate(1), 1); allocator_instance3.deallocate(allocator_instance2.allocate(1), 1); //The common pool will be destroyed here, since no allocator is //attached to the pool return 0; }
100
Boost.Interprocess
Equality: Two private_node_allocator instances never compare equal. Memory allocated with one allocator can't be deallocated with another one. Allocation thread-safety: Allocation and deallocation are not thread-safe. To use private_node_allocator, you must include the following header:
#include <boost/interprocess/allocators/private_node_allocator.hpp> private_node_allocator has the following declaration: namespace boost { namespace interprocess { template<class T, class SegmentManager, std::size_t NodesPerChunk = ...> class private_node_allocator; } } //namespace interprocess { //namespace boost {
101
Boost.Interprocess
#include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/allocators/private_node_allocator.hpp> #include <cassert> using namespace boost::interprocess; int main () { //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create shared memory managed_shared_memory segment(create_only, "MySharedMemory", 65536);
//segment name
//Create a private_node_allocator that allocates ints from the managed segment //The number of chunks per segment is the default value typedef private_node_allocator<int, managed_shared_memory::segment_manager> private_node_allocator_t; private_node_allocator_t allocator_instance(segment.get_segment_manager()); //Create another private_node_allocator. private_node_allocator_t allocator_instance2(segment.get_segment_manager()); //Although the segment manager address //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); //Create another node_allocator using copy-constructor. private_node_allocator_t allocator_instance3(allocator_instance2); //This allocator is also unequal to allocator_instance2 assert(allocator_instance2 != allocator_instance3); //Pools are destroyed with the allocators return 0; }
102
Boost.Interprocess
#include <boost/interprocess/allocators/cached_node_allocator.hpp> cached_node_allocator has the following declaration: namespace boost { namespace interprocess { template<class T, class SegmentManager, std::size_t NodesPerChunk = ...> class cached_node_allocator; } } //namespace interprocess { //namespace boost {
A cached_node_allocator instance and a node_allocator instance share the same pool if both instances receive the same template parameters. This means that nodes returned to the shared pool by one of them can be reused by the other. Please note that this does not mean that both allocators compare equal, this is just information for programmers that want to maximize the use of the pool.
cached_node_allocator, offers additional functions to control the cache (the cache can be controlled per instance):
void set_max_cached_nodes(std::size_t n): Sets the maximum cached nodes limit. If cached nodes reach the limit, some are returned to the shared pool. std::size_t get_max_cached_nodes() const: Returns the maximum cached nodes limit. void deallocate_cache(): Returns the cached nodes to the shared pool. An example using cached_node_allocator:
103
Boost.Interprocess
#include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/allocators/cached_node_allocator.hpp> #include <cassert> using namespace boost::interprocess; int main () { //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create shared memory managed_shared_memory segment(create_only, "MySharedMemory", 65536);
//segment name
//Create a cached_node_allocator that allocates ints from the managed segment //The number of chunks per segment is the default value typedef cached_node_allocator<int, managed_shared_memory::segment_manager> cached_node_allocator_t; cached_node_allocator_t allocator_instance(segment.get_segment_manager()); //The max cached nodes are configurable per instance allocator_instance.set_max_cached_nodes(3); //Create another cached_node_allocator. Since the segment manager address //is the same, this cached_node_allocator will be //attached to the same pool so "allocator_instance2" can deallocate //nodes allocated by "allocator_instance" cached_node_allocator_t allocator_instance2(segment.get_segment_manager()); //The max cached nodes are configurable per instance allocator_instance2.set_max_cached_nodes(5); //Create another cached_node_allocator using copy-constructor. This //cached_node_allocator will also be attached to the same pool cached_node_allocator_t allocator_instance3(allocator_instance2); //We can clear the cache allocator_instance3.deallocate_cache(); //All allocators are equal assert(allocator_instance == allocator_instance2); assert(allocator_instance2 == allocator_instance3); //So memory allocated with one can be deallocated with another allocator_instance2.deallocate(allocator_instance.allocate(1), 1); allocator_instance3.deallocate(allocator_instance2.allocate(1), 1); //The common pool will be destroyed here, since no allocator is //attached to the pool return 0; }
104
Boost.Interprocess
is deallocated, it's stored in a free list of nodes but memory is not returned to the segment manager so a deallocated node can be only reused by other containers using the same node pool. This behaviour can be problematic if several containers use boost::interprocess::node_allocator to temporarily allocate a lot of objects but they end storing a few of them: the node pool will be full of nodes that won't be reused wasting memory from the segment. Adaptive pool based allocators trade some space (the overhead can be as low as 1%) and performance (acceptable for many applications) with the ability to return free chunks of nodes to the memory segment, so that they can be used by any other container or managed object construction. To know the details of the implementation of of "adaptive pools" see the Implementation of Boost.Intrusive adaptive pools section. Like with segregated storage based node allocators, Boost.Interprocess offers 3 new allocators: adaptive_pool, private_adaptive_pool, cached_adaptive_pool.
functions explained in the Properties of Boost.Interprocess allocators. All these allocators are templatized by 4 parameters: class T: The type to be allocated. class SegmentManager: The type of the segment manager that will be passed in the constructor. std::size_t NodesPerChunk: The number of nodes that a memory chunk will contain. This value will dene the size of the memory the pool will request to the segment manager when the pool runs out of nodes. This parameter has a default value. std::size_t MaxFreeChunks: The maximum number of free chunks that the pool will hold. If this limit is reached the pool returns the chunks to the segment manager. This parameter has a default value. These allocators also offer the deallocate_free_chunks() function. This function will traverse all the memory chunks of the pool and will return to the managed memory segment the free chunks of memory. This function is much faster than for segregated storage allocators, because the adaptive pool algorithm offers constant-time access to free chunks.
105
Boost.Interprocess
namespace boost { namespace interprocess { template<class T, class SegmentManager, std::size_t NodesPerChunk = ..., std::size_t Max FreeChunks = ...> class adaptive_pool; } } //namespace interprocess { //namespace boost {
//segment name
//Create a adaptive_pool that allocates ints from the managed segment //The number of chunks per segment is the default value typedef adaptive_pool<int, managed_shared_memory::segment_manager> adaptive_pool_t; adaptive_pool_t allocator_instance(segment.get_segment_manager()); //Create another adaptive_pool. Since the segment manager address //is the same, this adaptive_pool will be //attached to the same pool so "allocator_instance2" can deallocate //nodes allocated by "allocator_instance" adaptive_pool_t allocator_instance2(segment.get_segment_manager()); //Create another adaptive_pool using copy-constructor. This //adaptive_pool will also be attached to the same pool adaptive_pool_t allocator_instance3(allocator_instance2); //All allocators are equal assert(allocator_instance == allocator_instance2); assert(allocator_instance2 == allocator_instance3); //So memory allocated with one can be deallocated with another allocator_instance2.deallocate(allocator_instance.allocate(1), 1); allocator_instance3.deallocate(allocator_instance2.allocate(1), 1); //The common pool will be destroyed here, since no allocator is //attached to the pool return 0; }
106
Boost.Interprocess
107
Boost.Interprocess
#include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/allocators/private_adaptive_pool.hpp> #include <cassert> using namespace boost::interprocess; int main () { //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create shared memory managed_shared_memory segment(create_only, "MySharedMemory", 65536);
//segment name
//Create a private_adaptive_pool that allocates ints from the managed segment //The number of chunks per segment is the default value typedef private_adaptive_pool<int, managed_shared_memory::segment_manager> private_adaptive_pool_t; private_adaptive_pool_t allocator_instance(segment.get_segment_manager()); //Create another private_adaptive_pool. private_adaptive_pool_t allocator_instance2(segment.get_segment_manager()); //Although the segment manager address //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); //Create another adaptive_pool using copy-constructor. private_adaptive_pool_t allocator_instance3(allocator_instance2); //This allocator is also unequal to allocator_instance2 assert(allocator_instance2 != allocator_instance3); //Pools are destroyed with the allocators return 0; }
108
Boost.Interprocess
cached_adaptive_pool has the following declaration: namespace boost { namespace interprocess { template<class T, class SegmentManager, std::size_t NodesPerChunk = ..., std::size_t MaxFreeN odes = ...> class cached_adaptive_pool; } } //namespace interprocess { //namespace boost {
A cached_adaptive_pool instance and an adaptive_pool instance share the same pool if both instances receive the same template parameters. This means that nodes returned to the shared pool by one of them can be reused by the other. Please note that this does not mean that both allocators compare equal, this is just information for programmers that want to maximize the use of the pool.
cached_adaptive_pool, offers additional functions to control the cache (the cache can be controlled per instance):
void set_max_cached_nodes(std::size_t n): Sets the maximum cached nodes limit. If cached nodes reach the limit, some are returned to the shared pool. std::size_t get_max_cached_nodes() const: Returns the maximum cached nodes limit. void deallocate_cache(): Returns the cached nodes to the shared pool. An example using cached_adaptive_pool:
109
Boost.Interprocess
#include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/allocators/cached_adaptive_pool.hpp> #include <cassert> using namespace boost::interprocess; int main () { //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create shared memory managed_shared_memory segment(create_only, "MySharedMemory", 65536);
//segment name
//Create a cached_adaptive_pool that allocates ints from the managed segment //The number of chunks per segment is the default value typedef cached_adaptive_pool<int, managed_shared_memory::segment_manager> cached_adaptive_pool_t; cached_adaptive_pool_t allocator_instance(segment.get_segment_manager()); //The max cached nodes are configurable per instance allocator_instance.set_max_cached_nodes(3); //Create another cached_adaptive_pool. Since the segment manager address //is the same, this cached_adaptive_pool will be //attached to the same pool so "allocator_instance2" can deallocate //nodes allocated by "allocator_instance" cached_adaptive_pool_t allocator_instance2(segment.get_segment_manager()); //The max cached nodes are configurable per instance allocator_instance2.set_max_cached_nodes(5); //Create another cached_adaptive_pool using copy-constructor. This //cached_adaptive_pool will also be attached to the same pool cached_adaptive_pool_t allocator_instance3(allocator_instance2); //We can clear the cache allocator_instance3.deallocate_cache(); //All allocators are equal assert(allocator_instance == allocator_instance2); assert(allocator_instance2 == allocator_instance3); //So memory allocated with one can be deallocated with another allocator_instance2.deallocate(allocator_instance.allocate(1), 1); allocator_instance3.deallocate(allocator_instance2.allocate(1), 1); //The common pool will be destroyed here, since no allocator is //attached to the pool return 0; }
110
Boost.Interprocess
boost:interprocess::deque is the implementation of std::deque ready to be used in managed memory segments like shared memory. To use it include:
#include <boost/interprocess/containers/deque.hpp>
list is the implementation of std::list ready to be used in managed memory segments like shared memory. To use it include:
#include <boost/interprocess/containers/list.hpp>
slist is the implementation of SGI's slist container (singly linked list) ready to be used in managed memory segments like shared memory. To use it include:
111
Boost.Interprocess
#include <boost/interprocess/containers/slist.hpp>
set/ multiset/ map/ multimap family is the implementation of std::set/multiset/map/multimap family ready to be used in managed memory segments like shared memory. To use them include:
#include <boost/interprocess/containers/set.hpp> #include <boost/interprocess/containers/map.hpp>
flat_set/ flat_multiset/ flat_map/ flat_multimap classes are the adaptation and extension of Andrei Alexandrescu's famous AssocVector class from Loki library, ready for the shared memory. These classes offer the same functionality as std::set/multiset/map/multimap implemented with an ordered vector, which has faster lookups than the standard ordered associative containers based on red-black trees, but slower insertions. To use it include:
#include <boost/interprocess/containers/flat_set.hpp> #include <boost/interprocess/containers/flat_map.hpp>
basic_string is the implementation of std::basic_string ready to be used in managed memory segments like shared memory. It's implemented using a vector-like contiguous storage, so it has fast c string conversion and can be used with the vectorstream iostream formatting classes. To use it include:
#include <boost/interprocess/containers/string.hpp>
All these containers have the same default arguments as standard containers and they can be used with other, non Boost.Interprocess allocators (std::allocator, or boost::pool_allocator, for example). To place any of these containers in managed memory segments, we must dene the allocator template parameter with a Boost.Interprocess allocator so that the container allocates the values in the managed memory segment. To place the container itself in shared memory, we construct it in the managed memory segment just like any other object with Boost.Interprocess:
112
Boost.Interprocess
#include <boost/interprocess/containers/vector.hpp> #include <boost/interprocess/allocators/allocator.hpp> #include <boost/interprocess/managed_shared_memory.hpp> int main () { using namespace boost::interprocess; //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //A managed shared memory where we can construct objects //associated with a c-string managed_shared_memory segment(create_only, "MySharedMemory", //segment name 65536); //Alias an STL-like allocator of ints that allocates ints from the segment typedef allocator<int, managed_shared_memory::segment_manager> ShmemAllocator; //Alias a vector that uses the previous STL-like allocator typedef vector<int, ShmemAllocator> MyVector; int initVal[] const int *begVal const int *endVal = {0, 1, 2, 3, 4, 5, 6 }; = initVal; = initVal + sizeof(initVal)/sizeof(initVal[0]);
//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 //from a range of iterators MyVector *myvector = segment.construct<MyVector> ("MyVector")/*object name*/ (begVal /*first ctor parameter*/, endVal /*second ctor parameter*/, alloc_inst /*third ctor parameter*/); //Use vector as your want std::sort(myvector->rbegin(), myvector->rend()); // . . . //When done, destroy and delete vector from the segment segment.destroy<MyVector>("MyVector"); return 0; }
These containers also show how easy is to create/modify an existing container making possible to place it in shared memory.
113
Boost.Interprocess
This means that to place any Boost.Interprocess container (including Boost.Interprocess strings) in shared memory or memory mapped les, containers must: Dene their template allocator parameter to a Boost.Interprocess allocator. Every container constructor must take the Boost.Interprocess allocator as parameter. You must use construct<>/nd_or_construct<>... functions to place the container in the managed memory. If you do the rst two points but you don't use construct<> or find_or_construct<> you are creating a container placed only in your process but that allocates memory for contained types from shared memory/memory mapped le. Let's see an example:
#include #include #include #include <boost/interprocess/managed_shared_memory.hpp> <boost/interprocess/containers/vector.hpp> <boost/interprocess/containers/string.hpp> <boost/interprocess/allocators/allocator.hpp>
int main () { using namespace boost::interprocess; //Typedefs 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; typedef vector<MyShmString, StringAllocator> MyShmStringVector; //Open shared memory //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; managed_shared_memory shm(create_only, "MySharedMemory", 10000); //Create allocators CharAllocator charallocator (shm.get_segment_manager()); 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 //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 //"this is my text" text are also in shared memory. MyShmStringVector myvector(stringallocator); myvector.insert(myvector.begin(), 10, mystring); //This vector is fully constructed in shared memory. All pointers
114
Boost.Interprocess
//buffers are constructed in the same shared memory segment //This vector can be safely accessed from other processes. MyShmStringVector *myshmvector = shm.construct<MyShmStringVector>("myshmvector")(stringallocator); myshmvector->insert(myshmvector->begin(), 10, mystring); //Destroy vector. This will free all strings that the vector contains shm.destroy_ptr(myshmvector); return 0; }
115
Boost.Interprocess
int main () { using namespace boost::interprocess; //Typedefs typedef managed_shared_memory::segment_manager typedef allocator<char, SegmentManager> typedef basic_string<char, std::char_traits<char> ,CharAllocator> typedef allocator<MyShmString, SegmentManager> typedef vector<MyShmString, StringAllocator>
//Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; managed_shared_memory shm(create_only, "MySharedMemory", 10000); //Create allocators CharAllocator charallocator (shm.get_segment_manager()); StringAllocator stringallocator(shm.get_segment_manager()); //Create a vector of strings in shared memory. MyShmStringVector *myshmvector = shm.construct<MyShmStringVector>("myshmvector")(stringallocator); //Insert 50 strings in shared memory. The strings will be allocated //only once and no string copy-constructor will be called when inserting //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); //In the following line, no string copy-constructor will be called. //"move_me"'s contents will be transferred to the string created in //the vector myshmvector->push_back(boost::move(move_me)); //The source string is in default constructed state assert(move_me.empty()); //The newly created string will be equal to the "move_me"'s old contents assert(myshmvector->back() == string_to_compare); } //Now erase a string... myshmvector->pop_back(); //...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 //function will be called in this operations!!
116
Boost.Interprocess
myshmvector->insert(myshmvector->begin(), boost::move(string_to_compare)); //Destroy vector. This will free all strings that the vector contains shm.destroy_ptr(myshmvector); return 0; }
Containers of containers
When creating containers of containers, each container needs an allocator. To avoid using several allocators with complex type denitions, we can take advantage of the type erasure provided by void allocators and the ability to implicitly convert void allocators in allocators that allocate other types. Here we have an example that builds a map in shared memory. Key is a string and the mapped type is a class that stores several containers:
#include #include #include #include #include <boost/interprocess/managed_shared_memory.hpp> <boost/interprocess/allocators/allocator.hpp> <boost/interprocess/containers/map.hpp> <boost/interprocess/containers/vector.hpp> <boost/interprocess/containers/string.hpp>
using namespace boost::interprocess; //Typedefs of allocators and containers typedef managed_shared_memory::segment_manager typedef allocator<void, segment_manager_t> typedef allocator<int, segment_manager_t> typedef vector<int, int_allocator> typedef allocator<int_vector, segment_manager_t> typedef vector<int_vector, int_vector_allocator> typedef allocator<char, segment_manager_t> typedef basic_string<char, std::char_traits<char>, char_allocator> class complex_data { int id_; char_string char_string_; int_vector_vector int_vector_vector_; public: //Since void_allocator is convertible to any other allocator<T>, we can simplify //the initialization taking just one allocator for all inner containers. complex_data(int id, const char *name, const void_allocator &void_alloc) : id_(id), char_string_(name, void_alloc), int_vector_vector_(void_alloc) {} //Other members... }; //Definition of the map holding a string as key and complex_data as mapped type typedef std::pair<const char_string, complex_data> map_value_type; typedef std::pair<char_string, complex_data> movable_to_map_value_type; typedef allocator<map_value_type, segment_manager_t> map_value_type_allocator; typedef map< char_string, complex_data , std::less<char_string>, map_value_type_allocator> complex_map_type; int main () { //Remove shared memory on construction and destruction struct shm_remove {
117
Boost.Interprocess
shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create shared memory managed_shared_memory segment(create_only,"MySharedMemory", 65536); //An allocator convertible to any allocator<T, segment_manager_t> type void_allocator alloc_inst (segment.get_segment_manager()); //Construct the shared memory map and fill it complex_map_type *mymap = segment.construct<complex_map_type> //(object name), (first ctor parameter, second ctor parameter) ("MyMap")(std::less<char_string>(), alloc_inst); for(int i = 0; i < 100; ++i){ //Both key(string) and value(complex_data) need an allocator in their constructors char_string key_object(alloc_inst); complex_data mapped_object(i, "default_name", alloc_inst); map_value_type value(key_object, mapped_object); //Modify values and insert them in the map mymap->insert(value); } return 0; }
118
Boost.Interprocess
#include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/allocators/allocator.hpp> #include <boost/unordered_map.hpp> #include <functional> #include <boost/functional/hash.hpp> //boost::unordered_map //std::equal_to //boost::hash
int main () { using namespace boost::interprocess; //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create shared memory managed_shared_memory segment(create_only, "MySharedMemory", 65536); //Note that unordered_map<Key, MappedType>'s value_type is std::pair<const Key, MappedType>, //so the allocator must allocate that pair. typedef int KeyType; typedef float MappedType; typedef std::pair<const int, float> ValueType; //Typedef the allocator typedef allocator<ValueType, managed_shared_memory::segment_manager> ShmemAllocator; //Alias an unordered_map of ints that uses the previous STL-like allocator. typedef boost::unordered_map < KeyType , MappedType , boost::hash<KeyType> ,std::equal_to<KeyType> , ShmemAllocator> MyHashMap; //Construct a shared memory hash map. //Note that the first parameter is the initial bucket count and //after that, the hash function, the equality function and the allocator MyHashMap *myhashmap = segment.construct<MyHashMap>("MyHashMap") //object name ( 3, boost::hash<int>(), std::equal_to<int>() // , segment.get_allocator<ValueType>()); //allocator instance //Insert data in the hash map for(int i = 0; i < 100; ++i){ myhashmap->insert(ValueType(i, (float)i)); } return 0; }
Boost.MultiIndex containers
The widely used Boost.MultiIndex library is compatible with Boost.Interprocess so we can construct pretty good databases in shared memory. Constructing databases in shared memory is a bit tougher than in normal memory, usually because those databases contain strings and those strings need to be placed in shared memory. Shared memory strings require an allocator in their constructors so this usually makes object insertion a bit more complicated. Here is an example that shows how to put a multi index container in shared memory:
119
Boost.Interprocess
#include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/allocators/allocator.hpp> #include <boost/interprocess/containers/string.hpp> #include <boost/multi_index_container.hpp> #include <boost/multi_index/member.hpp> #include <boost/multi_index/ordered_index.hpp> using namespace boost::interprocess; namespace bmi = boost::multi_index; typedef managed_shared_memory::allocator<char>::type char_allocator; typedef basic_string<char, std::char_traits<char>, char_allocator>shm_string; //Data to insert in shared memory struct employee { int id; int age; shm_string name; employee( int id_ , int age_ , const char *name_ , const char_allocator &a) : id(id_), age(age_), name(name_, a) {} }; //Tags struct id{}; struct age{}; struct name{}; // Define a multi_index_container of employees with following indices: // - a unique index sorted by employee::int, // - a non-unique index sorted by employee::name, // - a non-unique index sorted by employee::age. typedef bmi::multi_index_container< employee, bmi::indexed_by< bmi::ordered_unique <bmi::tag<id>, BOOST_MULTI_INDEX_MEMBER(employee,int,id)>, bmi::ordered_non_unique< bmi::tag<name>,BOOST_MULTI_INDEX_MEMBER(employee,shm_string,name)>, bmi::ordered_non_unique <bmi::tag<age>, BOOST_MULTI_INDEX_MEMBER(employee,int,age)> >, managed_shared_memory::allocator<employee>::type > employee_set; int main () { //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create shared memory managed_shared_memory segment(create_only,"MySharedMemory", 65536); //Construct the multi_index in shared memory employee_set *es = segment.construct<employee_set>
120
Boost.Interprocess
//Now insert elements char_allocator ca(segment.get_allocator<char>()); es->insert(employee(0,31, "Joe", ca)); es->insert(employee(1,27, "Robert", ca)); es->insert(employee(2,40, "John", ca)); return 0; }
Programmers can place Boost.CircularBuffer containers in sharecd memory provided they disable debugging facilities with denes BOOST_CB_DISABLE_DEBUG or the more general NDEBUG. The reason is that those debugging facilities are only compatible with raw pointers.
121
Boost.Interprocess
When a user requests N bytes of memory, the allocator traverses the free block list looking for a block large enough. If the "mem" part of the block has the same size as the requested memory, we erase the block from the list and return a pointer to the "mem" part of the block. If the "mem" part size is bigger than needed, we split the block in two blocks, one of the requested size and the other with remaining size. Now, we take the block with the exact size, erase it from list and give it to the user. When the user deallocates a block, we traverse the list (remember that the list is ordered), and search its place depending on the block address. Once found, we try to merge the block with adjacent blocks if possible. To ease implementation, the size of the free memory block is measured in multiples of "basic_size" bytes. The basic size will be the size of the control block aligned to machine most restrictive alignment. This algorithm is a low size overhead algorithm suitable for simple allocation schemes. This algorithm should only be used when size is a major concern, because the performance of this algorithm suffers when the memory is fragmented. This algorithm has linear allocation and deallocation time, so when the number of allocations is high, the user should use a more performance-friendly algorithm. In most 32 systems, with 8 byte alignment, "basic_size" is 8 bytes. This means that an allocation request of 1 byte leads to the creation of a 16 byte block, where 8 bytes are available to the user. The allocation of 8 bytes leads also to the same 16 byte block.
122
Boost.Interprocess
rbtree_best_fit memory layout: main allocated block free block allocated block free block header _______________ _______________ _________________________________ _______________ _________________________________ | || | || | | || | || | | | | main header ||next|prev| mem ||next|prev|left|right|par ent| mem ||next|prev| mem ||next|prev|left|right|parent| mem | |_______________||_________|_____||_________|_________________|_____||_________|_____||_________|_________________|_____|
This allocation algorithm is pretty fast and scales well with big shared memory segments and big number of allocations. To form a block a minimum memory size is needed: the sum of the doubly linked list and the red-black tree control data. The size of a block is measured in multiples of the most restrictive alignment value. In most 32 systems with 8 byte alignment the minimum size of a block is 24 byte. When a block is allocated the control data related to the red black tree is overwritten by the user (because it's only needed for free blocks). In those systems a 1 byte allocation request means that: 24 bytes of memory from the segment are used to form a block. 16 bytes of them are usable for the user. For really small allocations (<= 8 bytes), this algorithm wastes more memory than the simple sequential t algorithm (8 bytes more). For allocations bigger than 8 bytes the memory overhead is exactly the same. This is the default allocation algorithm in Boost.Interprocess managed memory segments.
123
Boost.Interprocess
The problem is even worse if the string is a shared-memory string, because to extract data, we must copy the data rst from sharedmemory to a std::string and then to a std::stringstream. To encode data in a shared memory string we should copy data from a std::stringstream to a std::string and then to the shared-memory string. Because of this overhead, Boost.Interprocess offers a way to format memory-strings (in shared memory, memory mapped les or any other memory segment) that can avoid all unneeded string copy and memory allocation/deallocations, while using all iostream facilities. Boost.Interprocess vectorstream and bufferstream implement vector-based and xed-size buffer based storage support for iostreams and all the formatting/locale hard work is done by standard std::basic_streambuf<> and std::basic_iostream<> classes.
124
Boost.Interprocess
//!A basic_iostream class that holds a character vector specified by CharVector //!template parameter as its formatting buffer. The vector must have //!contiguous storage, like std::vector, boost::interprocess::vector or //!boost::interprocess::basic_string template <class CharVector, class CharTraits = std::char_traits<typename CharVector::value_type> > class basic_vectorstream : public std::basic_iostream<typename CharVector::value_type, CharTraits> { public: typedef CharVector typedef typename std::basic_ios <typename CharVector::value_type, CharTraits>::char_type typedef typename std::basic_ios<char_type, CharTraits>::int_type typedef typename std::basic_ios<char_type, CharTraits>::pos_type typedef typename std::basic_ios<char_type, CharTraits>::off_type typedef typename std::basic_ios<char_type, CharTraits>::traits_type //!Constructor. Throws if vector_type default constructor throws. basic_vectorstream(std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out); //!Constructor. Throws if vector_type(const Parameter ¶m) throws. template<class Parameter> basic_vectorstream(const Parameter ¶m, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out); ~basic_vectorstream(){} //!Returns the address of the stored stream buffer. basic_vectorbuf<CharVector, CharTraits>* rdbuf() const; //!Swaps the underlying vector with the passed vector. //!This function resets the position in the stream. //!Does not throw. void swap_vector(vector_type &vect); //!Returns a const reference to the internal vector. //!Does not throw. const vector_type &vector() const; //!Preallocates memory from the internal vector. //!Resets the stream to the first position. //!Throws if the internals vector's memory allocation throws. void reserve(typename vector_type::size_type size); }; vector_type; char_type; int_type; pos_type; off_type; traits_type;
The vector type is templatized, so that we can use any type of vector: std::vector, boost::interprocess::vector... But the storage must be contiguous, we can't use a deque. We can even use boost::interprocess::basic_string, since it has a vector interface and it has contiguous storage. We can't use std::string, because although some std::string implementation are vector-based, others can have optimizations and reference-counted implementations. The user can obtain a const reference to the internal vector using vector_type vector() const function and he also can swap the internal vector with an external one calling void swap_vector(vector_type &vect). The swap function resets the stream position. This functions allow efcient methods to obtain the formatted data avoiding all allocations and data copies. Let's see an example to see how to use vectorstream:
125
Boost.Interprocess
using namespace boost::interprocess; typedef allocator<int, managed_shared_memory::segment_manager> IntAllocator; typedef allocator<char, managed_shared_memory::segment_manager> CharAllocator; typedef vector<int, IntAllocator> MyVector; typedef basic_string <char, std::char_traits<char>, CharAllocator> MyString; typedef basic_vectorstream<MyString> MyVectorStream; int main () { //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; managed_shared_memory segment( create_only, "MySharedMemory", //segment name 65536); //segment size in bytes //Construct shared memory vector MyVector *myvector = segment.construct<MyVector>("MyVector") (IntAllocator(segment.get_segment_manager())); //Fill vector myvector->reserve(100); for(int i = 0; i < 100; ++i){ myvector->push_back(i); } //Create the vectorstream. To create the internal shared memory //basic_string we need to pass the shared memory allocator as //a constructor argument MyVectorStream myvectorstream(CharAllocator(segment.get_segment_manager())); //Reserve the internal string myvectorstream.reserve(100*5); //Write all vector elements as text in the internal string //Data will be directly written in shared memory, because //internal string's allocator is a shared memory allocator for(std::size_t i = 0, max = myvector->size(); i < max; ++i){ myvectorstream << (*myvector)[i] << std::endl; } //Auxiliary vector to compare original data MyVector *myvector2 = segment.construct<MyVector>("MyVector2") (IntAllocator(segment.get_segment_manager()));
126
Boost.Interprocess
//Avoid reallocations myvector2->reserve(100); //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)); //Compare vectors assert(std::equal(myvector->begin(), myvector->end(), myvector2->begin())); //Create a copy of the internal string MyString stringcopy (myvectorstream.vector()); //Now we create a new empty shared memory string... MyString *mystring = segment.construct<MyString>("MyString") (CharAllocator(segment.get_segment_manager())); //...and we swap vectorstream's internal string //with the new one: after this statement mystring //will be the owner of the formatted data. //No reallocations, no data copies myvectorstream.swap_vector(*mystring); //Let's compare both strings assert(stringcopy == *mystring); //Done, destroy and delete vectors and string from the segment segment.destroy_ptr(myvector2); segment.destroy_ptr(myvector); segment.destroy_ptr(mystring); return 0; }
127
Boost.Interprocess
//!A basic_iostream class that uses a fixed size character buffer //!as its formatting buffer. template <class CharT, class CharTraits = std::char_traits<CharT> > class basic_bufferstream : public std::basic_iostream<CharT, CharTraits> { public: // Typedefs typedef typename std::basic_ios <CharT, CharTraits>::char_type char_type; typedef typename std::basic_ios<char_type, CharTraits>::int_type typedef typename std::basic_ios<char_type, CharTraits>::pos_type typedef typename std::basic_ios<char_type, CharTraits>::off_type typedef typename std::basic_ios<char_type, CharTraits>::traits_type //!Constructor. Does not throw. basic_bufferstream(std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out); //!Constructor. Assigns formatting buffer. Does not throw. basic_bufferstream(CharT *buffer, std::size_t length, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out); //!Returns the address of the stored stream buffer. basic_bufferbuf<CharT, CharTraits>* rdbuf() const; //!Returns the pointer and size of the internal buffer. //!Does not throw. std::pair<CharT *, std::size_t> buffer() const; //!Sets the underlying buffer to a new value. Resets //!stream position. Does not throw. void buffer(CharT *buffer, std::size_t length); }; //Some typedefs to simplify usage typedef basic_bufferstream<char> typedef basic_bufferstream<wchar_t> // ...
bufferstream; wbufferstream;
While reading from a xed size buffer, bufferstream activates endbit ag if we try to read an address beyond the end of the buffer. While writing to a xed size buffer, bufferstream will active the badbit ag if a buffer overow is going to happen and disallows writing. This way, the xed size buffer formatting through bufferstream is secure and efcient, and offers a good alternative to sprintf/sscanf functions. Let's see an example:
128
Boost.Interprocess
using namespace boost::interprocess; int main () { //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create shared memory managed_shared_memory segment(create_only, "MySharedMemory", 65536); //Fill data std::vector<int> data; data.reserve(100); for(int i = 0; i < 100; ++i){ data.push_back(i); } const std::size_t BufferSize = 100*5; //Allocate a buffer in shared memory to write data char *my_cstring = segment.construct<char>("MyCString")[BufferSize](0); bufferstream mybufstream(my_cstring, BufferSize); //Now write data to the buffer for(int i = 0; i < 100; ++i){ mybufstream << data[i] << std::endl; } //Check there was no overflow attempt assert(mybufstream.good()); //Extract all values from the shared memory string //directly to a vector. std::vector<int> data2; std::istream_iterator<int> it(mybufstream), itend; std::copy(it, itend, std::back_inserter(data2)); //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()); //Compare data assert(std::equal(data.begin(), data.end(), data2.begin())); //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){
//segment name
129
Boost.Interprocess
mybufstream << data[i%5] << std::endl; } //Now make sure badbit is active //which means overflow attempt. assert(!mybufstream.good()); assert(mybufstream.bad()); segment.destroy_ptr(my_cstring); return 0; }
As seen, bufferstream offers an efcient way to format data without any allocation and extra copies. This is very helpful in embedded systems, or formatting inside time-critical loops, where stringstream extra copies would be too expensive. Unlike sprintf/sscanf, it has protection against buffer overows. As we know, according to the Technical Report on C++ Performance, it's possible to design efcient iostreams for embedded platforms, so this bufferstream class comes handy to format data to stack, static or shared memory buffers.
130
Boost.Interprocess
Intrusive pointer
boost::interprocess::intrusive_ptr is the generalization of boost::intrusive_ptr<> to allow non-raw pointers as intrusive pointer members. As the well-known boost::intrusive_ptr we must specify the pointee type but we also must also
So boost::interprocess::intrusive_ptr<MyClass, void*> is equivalent to boost::intrusive_ptr<MyClass>. But if we want to place the intrusive_ptr in shared memory we must specify a relative pointer type like boost::interprocess::intrusive_ptr<MyClass, boost::interprocess::offset_ptr<void> >
131
Boost.Interprocess
#include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/smart_ptr/intrusive_ptr.hpp> using namespace boost::interprocess; namespace N { //A class that has an internal reference count class reference_counted_class { private: //Non-copyable reference_counted_class(const reference_counted_class &); //Non-assignable reference_counted_class & operator=(const reference_counted_class &); //A typedef to save typing typedef managed_shared_memory::segment_manager segment_manager; //This is the reference count unsigned int m_use_count; //The segment manager allows deletion from shared memory segment offset_ptr<segment_manager> mp_segment_manager; public: //Constructor reference_counted_class(segment_manager *s_mngr) : m_use_count(0), mp_segment_manager(s_mngr){} //Destructor ~reference_counted_class(){} public: //Returns the reference count unsigned int use_count() const { return m_use_count; } //Adds a reference inline friend void intrusive_ptr_add_ref(reference_counted_class * p) { ++p->m_use_count; } //Releases a reference inline friend void intrusive_ptr_release(reference_counted_class * p) { if(--p->m_use_count == 0) p->mp_segment_manager->destroy_ptr(p); } }; } //namespace N {
//A class that has an intrusive pointer to reference_counted_class class intrusive_ptr_owner { 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) : m_intrusive_ptr(ptr){} }; int main() { //Remove shared memory on construction and destruction struct shm_remove {
132
Boost.Interprocess
shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create shared memory managed_shared_memory shmem(create_only, "MySharedMemory", 10000); //Create the unique reference counted object in shared memory 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 = shmem.construct<intrusive_ptr_owner> (anonymous_instance)[10](ref_counted); //Now test that reference count is ten if(ref_counted->use_count() != 10) return 1; //Now destroy the array of intrusive pointer owners //This should destroy every intrusive_ptr and because of //that reference_counted_class will be destroyed shmem.destroy_ptr(intrusive_owner_array); //Now the reference counted object should have been destroyed if(shmem.find<intrusive_ptr_owner>("ref_counted").first) return 1; //Success! return 0; }
Scoped pointer
boost::interprocess::scoped_ptr<> is the big brother of boost::scoped_ptr<>, which adds a custom deleter to specify how the pointer passed to the scoped_ptr must be destroyed. Also, the pointer typedef of the deleter will specify the pointer type
stored by scoped_ptr.
//!scoped_ptr stores a pointer to a dynamically allocated object. //!The object pointed to is guaranteed to be deleted, either on destruction //!of the scoped_ptr, or via an explicit reset. The user can avoid this //!deletion using release(). //!scoped_ptr is parameterized on T (the type of the object pointed to) and //!Deleter (the functor to be executed to delete the internal pointer). //!The internal pointer will be of the same pointer type as typename //!Deleter::pointer type (that is, if typename Deleter::pointer is //!offset_ptr<void>, the internal pointer will be offset_ptr<T>). template<class T, class Deleter> class scoped_ptr; scoped_ptr<> comes handy to implement rollbacks with exceptions: if an exception is thrown or we call return in the scope of scoped_ptr<> the deleter is automatically called so that the deleter can be considered as a rollback function. If all goes well, we call release() member function to avoid rollback when the scoped_ptr goes out of scope.
133
Boost.Interprocess
#include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/smart_ptr/scoped_ptr.hpp> using namespace boost::interprocess; class my_class {}; class my_exception {}; //A functor that destroys the shared memory object template<class T> class my_deleter { private: //A typedef to save typing typedef managed_shared_memory::segment_manager segment_manager; //This my_deleter is created in the stack, not in shared memory, //so we can use raw pointers segment_manager *mp_segment_manager; public: //This typedef will specify the pointer type that //scoped_ptr will store typedef T *pointer; //Constructor my_deleter(segment_manager *s_mngr) : mp_segment_manager(s_mngr){} void operator()(pointer object_to_delete) { mp_segment_manager->destroy_ptr(object_to_delete); }; int main () { //Create shared memory //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; managed_shared_memory shmem(create_only, "MySharedMemory", 10000); //In the first try, there will be no exceptions //in the second try we will throw an exception for(int i = 0; i < 2; ++i){ //Create an object in shared memory 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 my_deleter<my_class> d(shmem.get_segment_manager()); try{ scoped_ptr<my_class, my_deleter<my_class> > s_ptr(my_object, d); //Let's emulate a exception capable operation //In the second try, throw an exception
134
Boost.Interprocess
if(i == 1){ throw(my_exception()); } //If we have passed the dangerous zone //we can release the scoped pointer //to avoid destruction s_ptr.release(); } catch(const my_exception &){} //Here, scoped_ptr is destroyed //so it we haven't thrown an exception //the object should be there, otherwise, destroyed if(i == 0){ //Make sure the object is alive if(!shmem.find<my_class>("my_object").first){ return 1; } //Now we can use it and delete it manually shmem.destroy<my_class>("my_object"); } else{ //Make sure the object has been deleted if(shmem.find<my_class>("my_object").first){ return 1; } } } return 0; }
T is the type of the pointed type. VoidAllocator is the allocator to be used to allocate auxiliary elements such as the reference count, the deleter... The internal pointer typedef of the allocator will determine the type of pointer that shared_ptr will internally use, so allocators dening pointer as offset_ptr<void> will make all internal pointers used by shared_ptr to be also relative pointers. See boost::interprocess::allocator for a working allocator. Deleter is the function object that will be used to destroy the pointed object when the last reference to the object is destroyed. The deleter functor will take a pointer to T of the same category as the void pointer dened by VoidAllocator::pointer. See boost::interprocess::deleter for a generic deleter that erases a object from a managed segment.
135
Boost.Interprocess
With correctly specied parameters, Boost.Interprocess users can create objects in shared memory that hold shared pointers pointing to other objects also in shared memory, obtaining the benets of reference counting. Let's see how to create a shared pointer in a managed shared memory:
#include #include #include #include #include <boost/interprocess/managed_shared_memory.hpp> <boost/interprocess/smart_ptr/shared_ptr.hpp> <boost/interprocess/allocators/allocator.hpp> <boost/interprocess/smart_ptr/deleter.hpp> <cassert>
using namespace boost::interprocess; //This is type of the object we want to share class MyType {}; typedef typedef typedef typedef managed_shared_memory::segment_manager segment_manager_type; allocator<void, segment_manager_type> void_allocator_type; deleter<MyType, segment_manager_type> deleter_type; shared_ptr<MyType, void_allocator_type, deleter_type> my_shared_ptr;
int main () { //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; managed_shared_memory segment(create_only, "MySharedMemory", 4096); //Create a shared pointer in shared memory //pointing to a newly created object in the segment my_shared_ptr &shared_ptr_instance = *segment.construct<my_shared_ptr>("shared ptr") //Arguments to construct the shared pointer ( segment.construct<MyType>("object to share")() , void_allocator_type(segment.get_segment_manager()) , deleter_type(segment.get_segment_manager()) ); assert(shared_ptr_instance.use_count() == 1);
//Destroy "shared ptr". "object to share" will be automatically destroyed segment.destroy_ptr(&shared_ptr_instance); return 0; } boost::interprocess::shared_ptr is very exible and congurable (we can specify the allocator and the deleter, for example),
but as shown the creation of a shared pointer in managed segments need too much typing. To simplify this usage, boost::interprocess::shared_ptr header offers a shared pointer denition helper class (managed_shared_ptr) and a function (make_managed_shared_ptr) to easily construct a shared pointer from a type allocated in a managed segment with an allocator that will allocate the reference count also in the managed segment and a deleter that will erase the object from the segment. These utilities will use a Boost.Interprocess allocator (boost::interprocess::allocator) and deleter (boost::interprocess::deleter) to do their job. The denition of the previous shared pointer could be simplied to the following:
typedef managed_shared_ptr<MyType, managed_shared_memory>::type my_shared_ptr;
136
Boost.Interprocess
Boost.Interprocess also offers a weak pointer named weak_ptr (with its corresponding managed_weak_ptr and make_managed_weak_ptr utilities) to implement non-owning observers of an object owned by shared_ptr. Now let's see a detailed example of the use of shared_ptr: and weak_ptr
#include #include #include #include <boost/interprocess/managed_mapped_file.hpp> <boost/interprocess/smart_ptr/shared_ptr.hpp> <boost/interprocess/smart_ptr/weak_ptr.hpp> <cassert>
using namespace boost::interprocess; //This is type of the object we want to share struct type_to_share {}; //This is the type of a shared pointer to the previous type //that will be built in the mapped file typedef managed_shared_ptr<type_to_share, managed_mapped_file>::type shared_ptr_type; typedef managed_weak_ptr<type_to_share, managed_mapped_file>::type weak_ptr_type; //This is a type holding a shared pointer struct shared_ptr_owner { shared_ptr_owner(const shared_ptr_type &other_shared_ptr) : shared_ptr_(other_shared_ptr) {} shared_ptr_owner(const shared_ptr_owner &other_owner) : shared_ptr_(other_owner.shared_ptr_) {} shared_ptr_type shared_ptr_; //... }; int main () { //Define file names const char *MappedFile
= "MyMappedFile";
//Destroy any previous file with the name to be used. struct file_remove { file_remove(const char *MappedFile) : MappedFile_(MappedFile) { file_mapping::remove(MappedFile_); } ~file_remove(){ file_mapping::remove(MappedFile_); } const char *MappedFile_; } remover(MappedFile); { managed_mapped_file file(create_only, MappedFile, 65536); //Construct the shared type in the file and //pass ownership to this local shared pointer shared_ptr_type local_shared_ptr = make_managed_shared_ptr (file.construct<type_to_share>("object to share")(), file); assert(local_shared_ptr.use_count() == 1);
137
Boost.Interprocess
//Share ownership of the object between local_shared_ptr and a new "owner1" shared_ptr_owner *owner1 = file.construct<shared_ptr_owner>("owner1")(local_shared_ptr); assert(local_shared_ptr.use_count() == 2); //local_shared_ptr releases object ownership local_shared_ptr.reset(); assert(local_shared_ptr.use_count() == 0); assert(owner1->shared_ptr_.use_count() == 1); //Share ownership of the object between "owner1" and a new "owner2" shared_ptr_owner *owner2 = file.construct<shared_ptr_owner>("owner2")(*owner1); assert(owner1->shared_ptr_.use_count() == 2); assert(owner2->shared_ptr_.use_count() == 2); assert(owner1->shared_ptr_.get() == owner2->shared_ptr_.get()); //The mapped file is unmapped here. Objects have been flushed to disk } { //Reopen the mapped file and find again all owners managed_mapped_file file(open_only, MappedFile); shared_ptr_owner *owner1 = file.find<shared_ptr_owner>("owner1").first; shared_ptr_owner *owner2 = file.find<shared_ptr_owner>("owner2").first; assert(owner1 && owner2); //Check everything is as expected assert(file.find<type_to_share>("object to share").first != 0); assert(owner1->shared_ptr_.use_count() == 2); assert(owner2->shared_ptr_.use_count() == 2); assert(owner1->shared_ptr_.get() == owner2->shared_ptr_.get()); //Now destroy one of the owners, the reference count drops. file.destroy_ptr(owner1); assert(owner2->shared_ptr_.use_count() == 1); //Create a weak pointer weak_ptr_type local_observer1(owner2->shared_ptr_); assert(local_observer1.use_count() == owner2->shared_ptr_.use_count()); { //Create a local shared pointer shared_ptr_type local_shared_ptr = assert(local_observer1.use_count() assert(local_observer1.use_count() } from the weak pointer local_observer1.lock(); == owner2->shared_ptr_.use_count()); == 2);
//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. } return 0; }
138
Boost.Interprocess
In general, using Boost.Interprocess' shared_ptr and weak_ptr is very similar to their counterparts boost::shared_ptr and boost::weak_ptr, but they need more template parameters and more run-time parameters in their constructors. Just like boost::shared_ptr can be stored in a STL container, shared_ptr can also be stored in Boost.Interprocess containers. If a programmer just uses shared_ptr to be able to insert objects dynamically constructed in the managed segment in a container, but does not need to share the ownership of that object with other objects unique_ptr is a much faster and easier to use alternative.
Unique pointer
Unique ownership smart pointers are really useful to free programmers from manual resource liberation of non-shared objects. Boost.Interprocess' unique_ptr is much like scoped_ptr but it's moveable and can be easily inserted in Boost.Interprocess containers. Here is the declaration of the unique pointer class:
template <class T, class D> class unique_ptr;
T is the type of the object pointed by unique_ptr. D is the deleter that will erase the object type of the object pointed by unique_ptr when the unique pointer is destroyed (and if still owns ownership of the object). If the deleter denes an internal pointer typedef, unique_ptr will use an internal pointer of the same type. So if D::pointer is offset_ptr<T> the unique pointer will store a relative pointer instead of a raw one. This allows placing unique_ptr in shared memory and memory-mapped les.
unique_ptr can release the ownership of the stored pointer so it's useful also to be used as a rollback function. One of the main
properties of the class is that is not copyable, but only moveable. When a unique pointer is moved to another one, the ownership of the pointer is transferred from the source unique pointer to the target unique pointer. If the target unique pointer owned an object, that object is rst deleted before taking ownership of the new object.
unique_ptr also offers auxiliary types to easily dene and construct unique pointers that can be placed in managed segments and will correctly delete the owned object from the segment: managed_unique_ptr and make_managed_unique_ptr utilities.
Here we see an example of the use unique_ptr including creating containers of such objects:
139
Boost.Interprocess
using namespace boost::interprocess; //This is type of the object we'll allocate dynamically struct MyType { MyType(int number = 0) : number_(number) {} int number_; }; //This is the type of a unique pointer to the previous type //that will be built in the mapped file 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; typedef list < unique_ptr_type , allocator<unique_ptr_type, managed_mapped_file::segment_manager> > unique_ptr_list_t; int main () { //Define file names const char *MappedFile
= "MyMappedFile";
//Destroy any previous file with the name to be used. struct file_remove { file_remove(const char *MappedFile) : MappedFile_(MappedFile) { file_mapping::remove(MappedFile_); } ~file_remove(){ file_mapping::remove(MappedFile_); } const char *MappedFile_; } remover(MappedFile); { managed_mapped_file file(create_only, MappedFile, 65536); //Construct an object in the file and //pass ownership to this local unique pointer unique_ptr_type local_unique_ptr (make_managed_unique_ptr (file.construct<MyType>("unique object")(), file)); assert(local_unique_ptr.get() != 0); //Reset the unique pointer. The object is automatically destroyed local_unique_ptr.reset(); assert(file.find<MyType>("unique object").first == 0); //Now create a vector of unique pointers unique_ptr_vector_t *unique_vector = file.construct<unique_ptr_vector_t>("unique vector")(file.get_segment_manager());
140
Boost.Interprocess
//Speed optimization unique_vector->reserve(100); //Now insert all values for(int i = 0; i < 100; ++i){ unique_ptr_type p(make_managed_unique_ptr(file.construct<MyType>(anonymous_in stance)(i), file)); 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())); //The unique ptr of the vector is now empty... assert(unique_vector->back() == 0); unique_vector->pop_back(); //...and the list has taken ownership of the value assert(unique_list->front() != 0); assert(unique_list->front()->number_ == i); } assert(unique_list->size() == 100); //Now destroy the empty vector. file.destroy_ptr(unique_vector); //The mapped file is unmapped here. Objects have been flushed to disk } { //Reopen the mapped file and find again the list managed_mapped_file file(open_only, MappedFile); unique_ptr_list_t *unique_list = file.find<unique_ptr_list_t>("unique list").first; assert(unique_list); assert(unique_list->size() == 100); unique_ptr_list_t::const_iterator list_it = unique_list->begin(); 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); } return 0; }
141
Boost.Interprocess
The memory algorithm takes care of memory synchronizations, just like malloc/free guarantees that two threads can call malloc/free at the same time. This is usually achieved placing a process-shared mutex as a member of the memory algorithm. Take in care that the memory algorithm knows nothing about the segment (if it is shared memory, a shared memory le, etc.). For the memory algorithm the segment is just a xed size memory buffer. The memory algorithm is also a conguration point for the rest of the Boost.Interprocess framework since it denes two basic types as member typedefs:
142
Boost.Interprocess
The void_pointer typedef denes the pointer type that will be used in the Boost.Interprocess framework (segment manager, allocators, containers). If the memory algorithm is ready to be placed in a shared memory/mapped le mapped in different base addresses, this pointer type will be dened as offset_ptr<void> or a similar relative pointer. If the memory algorithm will be used just with xed address mapping, void_pointer can be dened as void*. The rest of the interface of a Boost.Interprocess memory algorithm is described in Writing a new shared memory allocation algorithm section. As memory algorithm examples, you can see the implementations simple_seq_fit or rbtree_best_fit classes.
The segment manager initializes the memory algorithm and tells the memory manager that it should not use the memory where the rest of the segment manager's member are placed for dynamic allocations. The other members of the segment manager are a recursive mutex (dened by the memory algorithm's mutex_family::recursive_mutex typedef member), and two indexes (maps): one to implement named allocations, and another one to implement "unique instance" allocations. The rst index is a map with a pointer to a c-string (the name of the named object) as a key and a structure with information of the dynamically allocated object (the most important being the address and the size of the object). The second index is used to implement "unique instances" and is basically the same as the rst index, but the name of the object comes from a typeid(T).name() operation. The memory needed to store [name pointer, object information] pairs in the index is allocated also via the memory algorithm, so we can tell that internal indexes are just like ordinary user objects built in the segment. The rest of the memory to store the name of the object, the object itself, and meta-data for destruction/deallocation is allocated using the memory algorithm in a single allocate() call. As seen, the segment manager knows nothing about shared memory/memory mapped les. The segment manager itself does not allocate portions of the segment, it just asks the memory algorithm to allocate the needed memory from the rest of the segment. The segment manager is a class built above the memory algorithm that offers named object construction, unique instance constructions, and many other services. The segment manager is implemented in Boost.Interprocess by the segment_manager class.
template<class CharType ,class MemoryAlgorithm ,template<class IndexConfig> class IndexType> class segment_manager;
143
Boost.Interprocess
As seen, the segment manager is quite generic: we can specify the character type to be used to identify named objects, we can specify the memory algorithm that will control dynamically the portions of the memory segment, and we can specify also the index type that will store the [name pointer, object information] mapping. We can construct our own index types as explained in Building custom indexes section.
144
Boost.Interprocess
The pool allocates chunks of memory using the segment manager's raw memory allocation functions. The chunk contains a pointer to form a singly linked list of chunks. The pool will contain a pointer to the rst chunk. The rest of the memory of the chunk is divided in nodes of the requested size and no memory is used as payload for each node. Since the memory of a free node is not used that memory is used to place a pointer to form a singly linked list of free nodes. The pool has a pointer to the rst free node. Allocating a node is just taking the rst free node from the list. If the list is empty, a new chunk is allocated, linked in the list of chunks and the new free nodes are linked in the free node list. Deallocation returns the node to the free node list. When the pool is destroyed, the list of chunks is traversed and memory is returned to the segment manager. The pool is implemented by the private_node_pool and shared_node_pool classes.
Boost.Interprocess containers
Boost.Interprocess containers are standard conforming counterparts of STL containers in boost::interprocess namespace, but with these little details: Boost.Interprocess STL containers don't assume that memory allocated with an allocator can be deallocated with other allocator of the same type. They always compare allocators with operator==() to know if this is possible. The pointers of the internal structures of the Boost.Interprocess containers are of the same type the pointer type dened by the allocator of the container. This allows placing containers in managed memory segments mapped in different base addresses.
145
Boost.Interprocess
Performance of Boost.Interprocess
This section tries to explain the performance characteristics of Boost.Interprocess, so that you can optimize Boost.Interprocess usage if you need more performance.
146
Boost.Interprocess
Call the destructor of the object (many if it's an array). Deallocate the memory buffer containing the name, metadata and the object itself using the allocation algorithm. Unlock the recursive mutex. The steps when destroying a named object using the pointer of the object (destroy_ptr(T *ptr)) are these: Lock a recursive mutex . Depending on the index type, this can be different: If the index is a node index, (marked with boost::interprocess::is_node_index specialization): Take the iterator stored near the object and call erase(iterator). This can require element reordering if the index is a balanced tree, an ordered vector... If it's not an node index: Take the name stored near the object and erase the index entry calling `erase(const key &). This can require element reordering if the index is a balanced tree, an ordered vector... Call the destructor of the object (many if it's an array). Deallocate the memory buffer containing the name, metadata and the object itself using the allocation algorithm. Unlock the recursive mutex. If you see that the performance is not good enough you have these alternatives: Maybe the problem is that the lock time is too big and it hurts parallelism. Try to reduce the number of named objects in the global index and if your application serves several clients try to build a new managed memory segment for each one instead of using a common one. Use another Boost.Interprocess index type if you feel the default one is not fast enough. If you are not still satised, write your own index type. See Building custom indexes for this. Destruction via pointer is at least as fast as using the name of the object and can be faster (in node containers, for example). So if your problem is that you make at lot of named destructions, try to use the pointer. If the index is a node index you can save some time.
147
Boost.Interprocess
Customizing Boost.Interprocess
Writing a new shared memory allocation algorithm
If the default algorithm does not satisfy user requirements, it's easy to provide different algorithms like bitmapping or more advanced segregated lists to meet requirements. The class implementing the algorithm must be compatible with shared memory, so it shouldn't have any virtual function or virtual inheritance or any indirect base class with virtual function or inheritance. This is the interface to be implemented:
class my_algorithm { public: //!The mutex type to be used by the rest of Interprocess framework typedef implementation_defined mutex_family; //!The pointer type to be used by the rest of Interprocess framework typedef implementation_defined void_pointer; //!Constructor. "size" is the total size of the managed memory segment, //!"extra_hdr_bytes" indicates the extra bytes after the sizeof(my_algorithm) //!that the allocator should not use at all. my_algorithm (std::size_t size, std::size_t extra_hdr_bytes); //!Obtains the minimum size needed by the algorithm static std::size_t get_min_size (std::size_t extra_hdr_bytes); //!Allocates bytes, returns 0 if there is not more memory void* allocate (std::size_t nbytes); //!Deallocates previously allocated bytes void deallocate (void *adr); //!Returns the size of the memory segment std::size_t get_size() const; //!Increases managed memory in extra_size bytes more void grow(std::size_t extra_size); /*...*/ };
The void_pointer typedef species the pointer type to be used in the Boost.Interprocess framework that uses the algorithm. For example, if we dene
typedef void * void_pointer;
all Boost.Interprocess framework using this algorithm will use raw pointers as members. But if we dene:
typedef offset_ptr<void> void_pointer;
148
Boost.Interprocess
The mutex_family is a structure containing typedefs for different interprocess_mutex types to be used in the Boost.Interprocess framework. For example the dened
struct mutex_family { typedef boost::interprocess::interprocess_mutex typedef boost::interprocess::interprocess_recursive_mutex };
mutex_type; recursive_mutex_type;
denes all interprocess_mutex types using boost::interprocess interprocess_mutex types. The user can specify the desired mutex family.
typedef mutex_family mutex_family;
The new algorithm (let's call it my_algorithm) must implement all the functions that boost::interprocess::rbtree_best_t class offers: my_algorithm's constructor must take 2 arguments: size indicates the total size of the managed memory segment, and my_algorithm object will be always constructed a at offset 0 of the memory segment. The extra_hdr_bytes parameter indicates the number of bytes after the offset sizeof(my_algorithm) that my_algorithm can't use at all. This extra bytes will be used to store additional data that should not be overwritten. So, my_algorithm will be placed at address XXX of the memory segment, and will manage the [XXX + sizeof(my_algorithm) + extra_hdr_bytes, XXX + size) range of the segment. The get_min_size() function should return the minimum space the algorithm needs to be valid with the passed extra_hdr_bytes parameter. This function will be used to check if the memory segment is big enough to place the algorithm there. The allocate() function must return 0 if there is no more available memory. The memory returned by my_algorithm must be aligned to the most restrictive memory alignment of the system, for example, to the value returned by ipcdetail::alignment_of<boost::detail::max_align>::value. This function should be executed with the synchronization capabilities offered by typename mutex_family::mutex_type interprocess_mutex. That means, that if we dene typedef mutex_family mutex_family; then this function should offer the same synchronization as if it was surrounded by an interprocess_mutex lock/unlock. Normally, this is implemented using a member of type mutex_family::mutex_type, but it could be done using atomic instructions or lock free algorithms. The deallocate() function must make the returned buffer available for new allocations. This function should offer the same synchronization as allocate(). The size() function will return the passed size parameter in the constructor. So, my_algorithm should store the size internally. The grow() function will expand the managed memory by my_algorithm in extra_size bytes. So size() function should return the updated size, and the new managed memory range will be (if the address where the algorithm is constructed is XXX): [XXX + sizeof(my_algorithm) + extra_hdr_bytes, XXX + old_size + extra_size). This function should offer the same synchronization as allocate(). That's it. Now we can create new managed shared memory that uses our new algorithm:
//Managed memory segment to allocate named (c-string) objects //using a user-defined memory allocation algorithm basic_managed_shared_memory<char, ,my_algorithm ,flat_map_index> my_managed_shared_memory;
149
Boost.Interprocess
The user can create new STL compatible allocators that use the segment manager to access to all memory management/object construction functions. All Boost.Interprocess' STL compatible allocators are based on this approach. Remember that to be compatible with managed memory segments, allocators should dene their pointer typedef as the same pointer family as segment_manager::void_pointer typedef. This means that if segment_manager::void_pointer is offset_ptr<void>, MySTLAllocator<int> should dene pointer as offset_ptr<int>. The reason for this is that allocators are members of containers, and if we want to put the container in a managed memory segment, the allocator should be ready for that.
or
150
Boost.Interprocess
so that ordered arrays or deques can be used as index types. Some known classes following this basic interface are boost::unordered_map, boost::interprocess::flat_map and boost::interprocess::map. The class must be a class template taking only a traits struct of this type:
struct index_traits { typedef /*...*/ typedef /*...*/ typedef /*...*/ };
The key_type typedef of the passed index_traits will be a specialization of the following class:
//!The key of the named allocation information index. Stores a to //!a null string and the length of the string to speed up sorting template<...> struct index_key { typedef /*...*/ char_type; typedef /*...*/ const_char_ptr_t; //Pointer to the object's name (null terminated) const_char_ptr_t mp_str; //Length of the name buffer (null NOT included) std::size_t m_len; //!Constructor of the key index_key (const CharT *name, std::size_t length); //!Less than function for index ordering bool operator < (const index_key & right) const; //!Equal to function for index ordering bool operator == (const index_key & right) const; };
The mapped_type is not directly modied by the customized index but it is needed to dene the index type. The segment_manager will be the type of the segment manager that will manage the index. segment_manager will dene interesting internal types like void_pointer or mutex_family. The constructor of the customized index type must take a pointer to segment_manager as constructor argument:
constructor(segment_manager *segment_mngr);
The index must provide a memory reservation function, that optimizes the index if the user knows the number of elements to be inserted in the index:
void reserve(std::size_t n);
For example, the index type flat_map_index based in boost::interprocess::flat_map is just dened as:
151
Boost.Interprocess
namespace boost { namespace interprocess { //!Helper class to define typedefs from IndexTraits template <class MapConfig> struct flat_map_index_aux { typedef typename MapConfig::key_type key_type; typedef typename MapConfig::mapped_type mapped_type; typedef typename MapConfig:: segment_manager_base segment_manager_base; typedef std::less<key_type> key_less; typedef std::pair<key_type, mapped_type> value_type; typedef allocator<value_type ,segment_manager_base> allocator_type; typedef flat_map<key_type, mapped_type, key_less, allocator_type> index_t; }; //!Index type based in flat_map. Just derives from flat_map and //!defines the interface needed by managed memory segments. template <class MapConfig> class flat_map_index //Derive class from flat_map specialization : public flat_map_index_aux<MapConfig>::index_t { /// @cond typedef flat_map_index_aux<MapConfig> index_aux; typedef typename index_aux::index_t base_type; typedef typename index_aux:: segment_manager_base segment_manager_base; /// @endcond public: //!Constructor. Takes a pointer to the segment manager. Can throw flat_map_index(segment_manager_base *segment_mngr) : base_type(typename index_aux::key_less(), typename index_aux::allocator_type(segment_mngr)) {} //!This reserves memory to optimize the insertion of n elements in the index void reserve(typename segment_manager_base::size_type n) { base_type::reserve(n); } //!This frees all unnecessary memory void shrink_to_fit() { base_type::shrink_to_fit(); } }; }} //namespace boost { namespace interprocess
If the user is dening a node container based index (a container whose iterators are not invalidated when inserting or erasing other elements), Boost.Interprocess can optimize named object destruction when destructing via pointer. Boost.Interprocess can store an iterator next to the object and instead of using the name of the object to erase the index entry, it uses the iterator, which is a faster operation. So if you are creating a new node container based index (for example, a tree), you should dene an specialization of boost::interprocess::is_node_index<...> dened in <boost/interprocess/detail/utilities.hpp>:
152
Boost.Interprocess
//!Trait classes to detect //!index. This allows more //!when deallocating named template<class MapConfig> struct is_node_index <my_index<MapConfig> > { static const bool value };
= true;
Interprocess also denes other index types: boost::map_index uses boost::interprocess::map as index type. boost::null_index that uses an dummy index type if the user just needs anonymous allocations and wants to save some space and class instantations. Dening a new managed memory segment that uses the new index is easy. For example, a new managed shared memory that uses the new index:
//!Defines a managed shared memory with a c-strings as //!a keys, the red-black tree best fit algorithm (with process-shared mutexes //!and offset_ptr pointers) as raw shared memory management algorithm //!and a custom index typedef basic_managed_shared_memory < char, rbtree_best_fit<mutex_family>, my_index_type > my_managed_shared_memory;
153
Boost.Interprocess
154
Boost.Interprocess
Thanks to...
People
Many people have contributed with ideas and revisions, so this is the place to thank them: Thanks to all people who have shown interest in the library and have downloaded and tested the snapshots. Thanks to Francis Andre and Anders Hybertz for their ideas and suggestions. Many of them are not implemented yet but I hope to include them when library gets some stability. Thanks to Matt Doyle, Steve LoBasso, Glenn Schrader, Hiang Swee Chiang, Phil Endecott, Rene Rivera, Harold Pirtle, Paul Ryan, Shumin Wu, Michal Wozniak, Peter Johnson, Alex Ott, Shane Guillory, Steven Wooding and Kim Barrett for their bug xes and library testing. Thanks to Martin Adrian who suggested the use of Interprocess framework for user dened buffers. Thanks to Synge Todo for his boostbook-doxygen patch to improve Interprocess documentation. Thanks to Olaf Krzikalla for his Intrusive library. I have taken some ideas to improve red black tree implementation from his library. Thanks to Daniel James for his unordered_map/set family and his help with allocators. His great unordered implementation has been a reference to design exception safe containers. Thanks to Howard Hinnant for his amazing help, specially explaining allocator swapping, move semantics and for developing upgradable mutex and lock transfer features. Thanks to Pavel Vozenilek for his continuous review process, suggestions, code and help. He is the major supporter of Interprocess library. The library has grown with his many and great advices. And nally, thank you to all Boosters. Long live to C++!
Release Notes
Boost 1.52 Release
Added shrink_by and advise functions in mapped_region. ABI breakingReimplemented message_queue with a circular buffer index (the old behavior used an ordered array, leading to excessive copies). This should greatly increase performance but breaks ABI. Old behaviour/ABI can be used undening macro BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX in boost/interprocess/detail/workaround.hpp Improved message_queue insertion time avoiding priority search for common cases (both array and circular buffer congurations). Implemented sharable_mutex and interproces_condition_any. Improved offset_ptr performance. Added integer overow checks.
155
Boost.Interprocess
Source & ABI breaking: Removed flush from managed_shared_memory. as it is unspecied according to POSIX: "The effect of msync() on a shared memory object or a typed memory object is unspecied" . Fixed bug #7152,
156
Boost.Interprocess
157
Boost.Interprocess
158
Boost.Interprocess
Fixed bug in deque::erase(). Thanks to Steve LoBasso. Fixed bug in atomic_dec32(). Thanks to Glenn Schrader. Improved (multi)map/(multi)set constructors taking iterators. Now those have linear time if the iterator range is already sorted. ABI breaking: (multi)map/(multi)set now reduce their node size. The color bit is embedded in the parent pointer. Now, the size of a node is the size of 3 pointers in most systems. This optimization is activated for raw and offset_ptr pointers. (multi)map/(multi)set now reuse memory from old nodes in the assignment operator. ABI breaking: Implemented node-containers based on intrusive containers. This saves code size, since many instantiations share the same algorithms. Corrected code to be compilable with Visual C++ 8.0. Added function to zero free memory in memory algorithms and the segment manager. This function is useful for security reasons and to improve compression ratios for les created with managed_mapped_file. Added support for intrusive index types in managed memory segments. Intrusive indexes save extra memory allocations to allocate the index since with just one allocation, we allocate room for the value, the name and the hook to insert the object in the index. Created new index type: iset_index. It's an index based on an intrusive set (rb-tree). Created new index type: iunordered_set_index. It's an index based on a pseudo-intrusive unordered set (hash table). ABI breaking: The intrusive index iset_index is now the default index type. Optimized vector to take advantage of boost::has_trivial_destructor. This optimization avoids calling destructors of elements that have a trivial destructor. Optimized vector to take advantage of has_trivial_destructor_after_move trait. This optimization avoids calling destructors of elements that have a trivial destructor if the element has been moved (which is the case of many movable types). This trick was provided by Howard Hinnant. Added security check to avoid integer overow bug in allocators and named construction functions. Added alignment checks to forward and backwards expansion functions. Fixed bug in atomic functions for PPC. Fixed race-condition error when creating and opening a managed segment. Added adaptive pools. Source breaking: Changed node allocators' template parameter order to make them easier to use. Added support for native windows shared memory. Added more tests. Corrected the presence of private functions in the reference section. Added function (deallocate_free_chunks()) to manually deallocate completely free chunks from node allocators. Implemented N1780 proposal to LWG issue 233: Insertion hints in associative containers in interprocess multiset and multimap classes. Source breaking: A shared memory object is now used including shared_memory_object.hpp header instead of shared memory.hpp.
159
Boost.Interprocess
ABI breaking: Changed global mutex when initializing managed shared memory and memory mapped les. This change tries to minimize deadlocks. Source breaking: Changed shared memory, memory mapped les and mapped region's open mode to a single mode_t type. Added extra WIN32_LEAN_AND_MEAN before including DateTime headers to avoid socket redenition errors when using Interprocess and Asio in windows. ABI breaking: mapped_region constructor no longer requires classes derived from memory_mappable, but classes must fulll the MemoryMappable concept. Added in-place reallocation capabilities to basic_string. ABI breaking: Reimplemented and optimized small string optimization. The narrow string class has zero byte overhead with an internal 11 byte buffer in 32 systems! Added move semantics to containers. Improves performance when using containers of containers. ABI breaking: End nodes of node containers (list, slist, map/set) are now embedded in the containers instead of allocated using the allocator. This allows no-throw move-constructors and improves performance. ABI breaking: slist and list containers now have constant-time size() function. The size of the container is added as a member.
Books
Great book about multithreading, and POSIX: "Programming with Posix Threads", David R. Butenhof The UNIX inter-process bible: "UNIX Network Programming, Volume 2: Interprocess Communications", W. Richard Stevens Current STL allocator issues: "Effective STL", Scott Meyers My C++ bible: "Thinking in C++, Volume 1 & 2", Bruce Eckel and Chuck Allison The book every C++ programmer should read: "Inside the C++ Object Model", Stanley B. Lippman A must-read: "ISO/IEC TR 18015: Technical Report on C++ Performance", ISO WG21-SC22 members.
Links
A framework to put the STL in shared memory: "A C++ Standard Allocator for the Standard Template Library" . Instantiating C++ objects in shared memory: "Using objects in shared memory for C++ application" . A shared memory allocator and relative pointer: "Taming Shared Memory" .
Future improvements...
There are some Interprocess features that I would like to implement and some Boost.Interprocess code that can be much better. Let's see some ideas:
160
Boost.Interprocess
Security attributes
Boost.Interprocess does not dene security attributes for shared memory and synchronization objects. Standard C++ also ignores security attributes with les so adding security attributes would require some serious work.
161
Boost.Interprocess
Indexes
Class Index
A
accept_ownership_type Struct accept_ownership_type, 450 adaptive_pool Class template adaptive_pool, 284, 285 adaptive_pool: a process-shared adaptive pool assert, 105 advise Class mapped_region, 368, 370 allocate Class template adaptive_pool, 284, 286 Class template allocator, 289, 290 Class template cached_adaptive_pool, 294, 296 Class template cached_node_allocator, 300, 302 Class template node_allocator, 305, 307 Class template private_adaptive_pool, 311, 313 Class template private_node_allocator, 317, 319 Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 385, 385 Multiple allocation functions, 81, 81 Performance of raw memory allocations, 146, 146 Synchronization guarantees, 74 The segment manager, 143 Writing a new shared memory allocation algorithm, 148, 149, 149, 149 allocate_aligned Class template rbtree_best_t, 371, 373 Class template segment_manager_base, 384, 385, 385 allocate_individual Class template adaptive_pool, 284, 287 Class template allocator, 289, 291 Class template cached_adaptive_pool, 294, 297 Class template cached_node_allocator, 300, 303 Class template node_allocator, 305, 308 Class template private_adaptive_pool, 311, 314 Class template private_node_allocator, 317, 320 allocate_many Class template adaptive_pool, 284, 286, 286 Class template allocator, 289, 291, 291 Class template cached_adaptive_pool, 294, 297, 297 Class template cached_node_allocator, 300, 302, 303 Class template node_allocator, 305, 307, 308 Class template private_adaptive_pool, 311, 314, 314 Class template private_node_allocator, 317, 319, 319 Multiple allocation functions, 81, 81, 81 allocate_one Class template adaptive_pool, 284, 287, 287 Class template allocator, 289, 291, 291 Class template cached_adaptive_pool, 294, 297, 297 Class template cached_node_allocator, 300, 303, 303 Class template node_allocator, 305, 308, 308 Class template private_adaptive_pool, 311, 314, 314 Class template private_node_allocator, 317, 320, 320
162
Boost.Interprocess
Allocating aligned memory portions assert, 79 allocator Class template allocator, 289, 344 Class template segment_manager, 387 Struct template allocator, 392 allocator_holder Class template iunordered_set_index, 337 allocator_type Building custom indexes, 150 Struct template at_map_index_aux, 334 all_memory_deallocated Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 386 Anonymous condition example buffer, 39 lock, 39, 39 Anonymous mutex example lock, 35, 35 while, 35, 35 assert adaptive_pool: a process-shared adaptive pool, 105 Allocating aligned memory portions, 79 cached_adaptive_pool: Avoiding synchronization overhead, 108 cached_node_allocator: caching nodes to avoid overhead, 102 Expand in place memory allocation, 83 Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 Growing managed segments, 77 Mapping Address Independent Pointer: offset_ptr, 29 Move semantics in Interprocess containers, 115 node_allocator: A process-shared segregated storage, 99 private_adaptive_pool: a private adaptive pool, 107 private_node_allocator: a private segregated storage, 100 Shared pointer and weak pointer, 135 Transferring Unlocked Locks, 56 Unique pointer, 139 atomic_func Class template segment_manager, 387, 390 Executing an object function atomically, 76
B
bad_alloc Class bad_alloc, 330, 330 base_t Class template basic_bufferbuf, 423 base_type Building custom indexes, 150 basic_bufferbuf Class template basic_bufferbuf, 349, 423 basic_bufferstream Class template basic_bufferstream, 350, 427 Formatting directly in your character buffer: bufferstream, 127 basic_ibufferstream Class template basic_ibufferstream, 350, 424 basic_managed_external_buffer Class template basic_managed_external_buffer, 348, 356, 356
163
Boost.Interprocess
basic_managed_heap_memory Class template basic_managed_heap_memory, 349, 357, 357 basic_managed_mapped_le Class template basic_managed_mapped_le, 349, 359 basic_managed_shared_memory Class template basic_managed_shared_memory, 348, 361, 361 basic_managed_windows_shared_memory Class template basic_managed_windows_shared_memory, 348, 364, 364 basic_managed_xsi_shared_memory Class template basic_managed_xsi_shared_memory, 349, 366, 366 basic_obufferstream Class template basic_obufferstream, 350, 425 basic_vectorbuf Class template basic_vectorbuf, 350, 428 basic_vectorstream Class template basic_vectorstream, 351, 432 Formatting directly in your character vector: vectorstream, 124 Be Careful With Iostream Writing ush, 62 begin Class template null_index, 339, 340, 340 Boost unordered containers name, 118 BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR Header < boost/interprocess/offset_ptr.hpp >, 374 Macro BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR, 381, 381, 381 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF Header < boost/interprocess/offset_ptr.hpp >, 374 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF, 381, 381, 381 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER Header < boost/interprocess/offset_ptr.hpp >, 374 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER, 381, 381, 381 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR Header < boost/interprocess/offset_ptr.hpp >, 374 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR, 381, 381, 381 bucket_ptr Class template iunordered_set_index, 337 bucket_traits Class template iunordered_set_index, 337 bucket_type Class template iunordered_set_index, 337 buffer Anonymous condition example, 39 Building custom indexes, 150 Class template basic_bufferbuf, 423, 424, 424 Class template basic_bufferstream, 427, 427, 427 Class template basic_ibufferstream, 424, 425, 425 Class template basic_obufferstream, 425, 426, 426 Formatting directly in your character buffer: bufferstream, 127, 127 Header < boost/interprocess/allocators/allocator.hpp >, 288 Introduction, 66, 66 bufferbuf Header < boost/interprocess/streams/bufferstream.hpp >, 422 bufferstream Formatting directly in your character buffer: bufferstream, 127 Header < boost/interprocess/streams/bufferstream.hpp >, 422 Building custom indexes allocator_type, 150
164
Boost.Interprocess
base_type, 150 buffer, 150 char_type, 150 at_map_index_aux, 150 index_aux, 150 index_t, 150 key_less, 150 key_type, 150, 150 mapped_type, 150, 150 name, 150 reserve, 150, 150 segment_manager, 150 segment_manager_base, 150, 150 shrink_to_t, 150 value_type, 150
C
cached_adaptive_pool Class template cached_adaptive_pool, 294, 295 cached_adaptive_pool: Avoiding synchronization overhead assert, 108 set_max_cached_nodes, 109 cached_node_allocator Class template cached_node_allocator, 300, 301 cached_node_allocator: caching nodes to avoid overhead assert, 102 set_max_cached_nodes, 103 char_ptr Class template message_queue_t, 353 char_type Building custom indexes, 150 Class template basic_bufferbuf, 423 Class template basic_bufferstream, 427 Class template basic_ibufferstream, 424 Class template basic_obufferstream, 425 Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template segment_manager, 387 Class template std, 430 Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 check_sanity Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 386 Class bad_alloc bad_alloc, 330, 330 interprocess_exception, 330 wait, 330 Class le_lock le_lock, 434 lock, 434, 435 lock_sharable, 434, 435 swap, 434, 435 timed_lock, 434, 435 timed_lock_sharable, 434, 435 try_lock, 434, 435 try_lock_sharable, 434, 435
165
Boost.Interprocess
unlock, 434, 435 unlock_sharable, 434, 435 Class le_mapping le_mapping, 331, 331 remove, 331, 332 swap, 331, 332 Class interprocess_condition interprocess_condition, 436, 436 notify_all, 436, 437 notify_one, 436, 437 pred, 437 timed_wait, 436, 437, 437 wait, 436, 437, 437 Class interprocess_condition_any interprocess_condition_any, 438, 438 notify_all, 438, 438 notify_one, 438, 438 pred, 439 timed_wait, 438, 439, 439 wait, 438, 438, 439 Class interprocess_exception interprocess_exception, 329, 329 Class interprocess_mutex interprocess_mutex, 439, 439 lock, 439, 440 timed_lock, 439, 440 try_lock, 439, 440 unlock, 439, 440 Class interprocess_recursive_mutex interprocess_recursive_mutex, 441, 441 lock, 441, 441 timed_lock, 441, 441 try_lock, 441, 441 unlock, 441, 441 Class interprocess_semaphore interprocess_semaphore, 442, 442 post, 442, 442 timed_wait, 442, 443 try_wait, 442, 443 wait, 442, 443 Class interprocess_sharable_mutex interprocess_sharable_mutex, 444, 444 lock, 444, 444 lock_sharable, 444, 445 timed_lock, 444, 445 timed_lock_sharable, 444, 445 try_lock, 444, 444 try_lock_sharable, 444, 445 unlock, 444, 445 unlock_sharable, 444, 445 Class interprocess_upgradable_mutex interprocess_upgradable_mutex, 446, 446 lock, 446, 447 lock_sharable, 446, 447 lock_upgradable, 446, 447 timed_lock, 446, 447 timed_lock_sharable, 446, 447 timed_lock_upgradable, 446, 448
166
Boost.Interprocess
timed_unlock_upgradable_and_lock, 446, 448 try_lock, 446, 447 try_lock_sharable, 446, 447 try_lock_upgradable, 446, 448 try_unlock_sharable_and_lock, 446, 449 try_unlock_sharable_and_lock_upgradable, 446, 449 try_unlock_upgradable_and_lock, 446, 448 unlock, 446, 447 unlock_and_lock_sharable, 446, 448 unlock_and_lock_upgradable, 446, 448 unlock_sharable, 446, 447 unlock_upgradable, 446, 448 unlock_upgradable_and_lock, 446, 448 unlock_upgradable_and_lock_sharable, 446, 448 Class lock_exception interprocess_exception, 330 lock_exception, 330, 330 Class mapped_region advise, 368, 370 ush, 368, 369 get_page_size, 368, 370 mapped_region, 368, 368, 368 shrink_by, 368, 369 swap, 368, 369 Class named_condition named_condition, 452, 452, 453 notify_all, 452, 453 notify_one, 452, 453 pred, 453 remove, 452, 453, 454 timed_wait, 452, 453, 453 wait, 452, 453, 453 Class named_condition_any named_condition_any, 454, 454, 455 notify_all, 454, 455 notify_one, 454, 455 pred, 456 remove, 454, 455, 456 timed_wait, 454, 455, 456 wait, 454, 455, 455 Class named_mutex lock, 456, 457 named_mutex, 456, 456, 457 remove, 456, 457, 457 timed_lock, 456, 457 try_lock, 456, 457 unlock, 456, 457 Class named_recursive_mutex lock, 458, 459 named_recursive_mutex, 458, 458, 458 remove, 458, 459, 459 timed_lock, 458, 459 try_lock, 458, 459 unlock, 458, 459 Class named_semaphore named_semaphore, 460, 460, 460 post, 460, 461 remove, 460, 460, 461
167
Boost.Interprocess
timed_wait, 460, 461 try_wait, 460, 461 wait, 460, 461 Class named_sharable_mutex lock, 462, 463 lock_sharable, 462, 463 named_sharable_mutex, 462, 462, 462 remove, 462, 462, 464 timed_lock, 462, 463 timed_lock_sharable, 462, 463 try_lock, 462, 463 try_lock_sharable, 462, 463 unlock, 462, 463 unlock_sharable, 462, 463 Class named_upgradable_mutex lock, 465, 466 lock_sharable, 465, 466 lock_upgradable, 465, 467 named_upgradable_mutex, 465, 465, 465 remove, 465, 466, 468 timed_lock, 465, 466 timed_lock_sharable, 465, 466 timed_lock_upgradable, 465, 467 timed_unlock_upgradable_and_lock, 465, 468 try_lock, 465, 466 try_lock_sharable, 465, 466 try_lock_upgradable, 465, 467 try_unlock_sharable_and_lock, 465, 468 try_unlock_sharable_and_lock_upgradable, 465, 468 try_unlock_upgradable_and_lock, 465, 468 unlock, 465, 466 unlock_and_lock_sharable, 465, 467 unlock_and_lock_upgradable, 465, 467 unlock_sharable, 465, 467 unlock_upgradable, 465, 467 unlock_upgradable_and_lock, 465, 467 unlock_upgradable_and_lock_sharable, 465, 467 Class null_mutex lock, 469, 469, 469 lock_sharable, 469, 470, 470 lock_upgradable, 469, 470, 470 null_mutex, 469, 469 timed_lock, 469, 470, 470 timed_lock_sharable, 469, 470, 470 timed_lock_upgradable, 469, 470, 470 timed_unlock_upgradable_and_lock, 469, 471, 471 try_lock, 469, 469, 469 try_lock_sharable, 469, 470, 470 try_lock_upgradable, 469, 470, 470 try_unlock_sharable_and_lock, 469, 471, 471 try_unlock_sharable_and_lock_upgradable, 469, 471, 471 try_unlock_upgradable_and_lock, 469, 471, 471 unlock, 469, 470, 470 unlock_and_lock_sharable, 469, 470, 470 unlock_and_lock_upgradable, 469, 470, 470 unlock_sharable, 469, 470, 470 unlock_upgradable, 469, 470, 470 unlock_upgradable_and_lock, 469, 471, 471
168
Boost.Interprocess
unlock_upgradable_and_lock_sharable, 469, 470, 470 Class permissions permissions, 382 set_default, 382, 382 set_permissions, 382, 382 set_unrestricted, 382, 382 Class remove_le_on_destroy remove_le_on_destroy, 333 Class remove_shared_memory_on_destroy remove_shared_memory_on_destroy, 395 Class shared_memory_object remove, 393, 394, 394 shared_memory_object, 393 swap, 393, 394 truncate, 393, 394 Class template adaptive_pool adaptive_pool, 284, 285 allocate, 284, 286 allocate_individual, 284, 287 allocate_many, 284, 286, 286 allocate_one, 284, 287, 287 const_pointer, 284 const_reference, 284 deallocate, 284, 286, 286, 287 deallocate_free_blocks, 284, 286 deallocate_individual, 284, 287 deallocate_many, 284, 287 deallocate_one, 284, 287, 287, 287, 287 difference_type, 284 other, 284 pointer, 284 rebind, 284 reference, 284 segment_manager, 284 size_type, 284 swap, 284, 287 value_type, 284 void_pointer, 284 Class template allocator allocate, 289, 290 allocate_individual, 289, 291 allocate_many, 289, 291, 291 allocate_one, 289, 291, 291 allocator, 289, 344 construct, 289, 292 const_pointer, 289 const_reference, 289 deallocate, 289, 290, 291, 291 deallocate_individual, 289, 291 deallocate_many, 289, 291 deallocate_one, 289, 291, 291, 291, 291 destroy, 289, 292 difference_type, 289 other, 289 pointer, 289 rebind, 289 reference, 289 segment_manager, 289
169
Boost.Interprocess
size_type, 289 swap, 289, 292 value_type, 289 version, 289 void_pointer, 289 Class template basic_bufferbuf base_t, 423 basic_bufferbuf, 349, 423 buffer, 423, 424, 424 char_type, 423 int_type, 423 off_type, 423 pos_type, 423 traits_type, 423 Class template basic_bufferstream basic_bufferstream, 350, 427 buffer, 427, 427, 427 char_type, 427 int_type, 427 off_type, 427 pos_type, 427 traits_type, 427 Class template basic_ibufferstream basic_ibufferstream, 350, 424 buffer, 424, 425, 425 char_type, 424 int_type, 424 off_type, 424 pos_type, 424 traits_type, 424 Class template basic_managed_external_buffer basic_managed_external_buffer, 348, 356, 356 grow, 356, 357 size_type, 356 swap, 356, 357 Class template basic_managed_heap_memory basic_managed_heap_memory, 349, 357, 357 grow, 357, 358 size_type, 357 swap, 357, 358 Class template basic_managed_mapped_le basic_managed_mapped_le, 349, 359 ush, 359, 360 grow, 359, 360 remove, 360 shrink_to_t, 359, 360 swap, 359, 360 Class template basic_managed_shared_memory basic_managed_shared_memory, 348, 361, 361 grow, 361, 362 remove, 362 shrink_to_t, 361, 363 swap, 361, 362 Class template basic_managed_windows_shared_memory basic_managed_windows_shared_memory, 348, 364, 364 size_type, 364 swap, 364, 365 Class template basic_managed_xsi_shared_memory
170
Boost.Interprocess
basic_managed_xsi_shared_memory, 349, 366, 366 remove, 366, 367, 367 size_type, 366 swap, 366, 367 Class template basic_obufferstream basic_obufferstream, 350, 425 buffer, 425, 426, 426 char_type, 425 int_type, 425 off_type, 425 pos_type, 425 traits_type, 425 Class template basic_vectorbuf basic_vectorbuf, 350, 428 char_type, 428 clear, 428, 429, 429 int_type, 428 off_type, 428 pos_type, 428 reserve, 428, 429 swap_vector, 428, 429 traits_type, 428 vector_type, 428 Class template basic_vectorstream basic_vectorstream, 351, 432 char_type, 432 clear, 432, 433, 433 int_type, 432 off_type, 432 pos_type, 432 reserve, 432, 433, 433 swap_vector, 432, 433 traits_type, 432 vector_type, 432 Class template cached_adaptive_pool allocate, 294, 296 allocate_individual, 294, 297 allocate_many, 294, 297, 297 allocate_one, 294, 297, 297 cached_adaptive_pool, 294, 295 construct, 294, 296 const_pointer, 294 const_reference, 294 deallocate, 294, 296, 297, 297 deallocate_free_blocks, 294, 296 deallocate_individual, 294, 297 deallocate_many, 294, 297 deallocate_one, 294, 297, 297, 297, 297 destroy, 294, 296 difference_type, 294 other, 294 pointer, 294 rebind, 294 reference, 294 segment_manager, 294 set_max_cached_nodes, 294, 297 size_type, 294 swap, 294, 298
171
Boost.Interprocess
value_type, 294 void_pointer, 294 Class template cached_node_allocator allocate, 300, 302 allocate_individual, 300, 303 allocate_many, 300, 302, 303 allocate_one, 300, 303, 303 cached_node_allocator, 300, 301 construct, 300, 302 const_pointer, 300 const_reference, 300 deallocate, 300, 302, 302, 303 deallocate_free_blocks, 300, 302 deallocate_individual, 300, 303 deallocate_many, 300, 303 deallocate_one, 300, 303, 303, 303, 303 destroy, 300, 302 difference_type, 300 other, 300 pointer, 300 rebind, 300 reference, 300 segment_manager, 300 set_max_cached_nodes, 300, 303 size_type, 300 swap, 300, 303 value_type, 300 void_pointer, 300 Class template deleter deleter, 396 pointer, 396 Class template enable_shared_from_this enable_shared_from_this, 397 Class template at_map_index reserve, 334, 334 shrink_to_t, 334, 334 Class template intrusive_ptr element_type, 399 get, 399, 400, 400, 400, 400, 400 intrusive_ptr, 352, 399 intrusive_ptr_add_ref, 399, 399, 400, 400 intrusive_ptr_release, 399, 400 pointer, 399 swap, 399, 401 Class template iset_index const_iterator, 335 nd, 335, 336, 336 insert_commit_data, 335 iset_index_aux, 335 iterator, 335 reserve, 335, 335 shrink_to_t, 335, 336 value_type, 335 Class template iunordered_set_index allocator_holder, 337 bucket_ptr, 337 bucket_traits, 337 bucket_type, 337
172
Boost.Interprocess
const_iterator, 337 nd, 337, 338, 338 insert_commit, 337, 338 insert_commit_data, 337 iterator, 337 iunordered_set_index_aux, 337 reserve, 337, 337 shrink_to_t, 337, 337 size_type, 337 value_type, 337 Class template map_index reserve, 338, 339 shrink_to_t, 338, 339 Class template message_queue_t char_ptr, 353 difference_type, 353 get_num_msg, 353, 355 message_queue_t, 352, 353 receive, 353, 354 remove, 353, 354, 355 send, 353, 354 size_type, 353 timed_receive, 353, 355 timed_send, 353, 354 try_receive, 353, 355 try_send, 353, 354 void_pointer, 353 Class template node_allocator allocate, 305, 307 allocate_individual, 305, 308 allocate_many, 305, 307, 308 allocate_one, 305, 308, 308 construct, 305, 307 const_pointer, 305 const_reference, 305 deallocate, 305, 307, 307, 308 deallocate_free_blocks, 305, 307 deallocate_individual, 305, 308 deallocate_many, 305, 308 deallocate_one, 305, 308, 308, 308, 308 destroy, 305, 307 difference_type, 305 node_allocator, 305, 306 other, 305 pointer, 305 rebind, 305 reference, 305 segment_manager, 305 size_type, 305 swap, 305, 308 value_type, 305 void_pointer, 305 Class template null_index begin, 339, 340, 340 const_iterator, 339 end, 339, 340, 340, 340, 340, 340, 340 iterator, 339 null_index, 339, 339, 347
173
Boost.Interprocess
Class template offset_ptr difference_type, 376 element_type, 376 get, 376, 378 iterator_category, 376 offset_ptr, 345, 376, 376, 377, 377, 377, 377, 377, 378 offset_type, 376 other, 376 pointer, 376 pointer_to, 376, 379 rebind, 376 reference, 376 value_type, 376 Class template private_adaptive_pool allocate, 311, 313 allocate_individual, 311, 314 allocate_many, 311, 314, 314 allocate_one, 311, 314, 314 construct, 311, 313 const_pointer, 311 const_reference, 311 deallocate, 311, 313, 314, 314 deallocate_free_blocks, 311, 313 deallocate_individual, 311, 314 deallocate_many, 311, 314 deallocate_one, 311, 314, 314, 314, 314 destroy, 311, 313 difference_type, 311 other, 311 pointer, 311 private_adaptive_pool, 311, 312 rebind, 311 reference, 311 segment_manager, 311 size_type, 311 swap, 311, 314 value_type, 311 void_pointer, 311 Class template private_node_allocator allocate, 317, 319 allocate_individual, 317, 320 allocate_many, 317, 319, 319 allocate_one, 317, 320, 320 construct, 317, 319 const_pointer, 317 const_reference, 317 deallocate, 317, 319, 319, 320 deallocate_free_blocks, 317, 319 deallocate_individual, 317, 320 deallocate_many, 317, 320 deallocate_one, 317, 320, 320, 320, 320 destroy, 317, 319 difference_type, 317 other, 317 pointer, 317 private_node_allocator, 317, 318 rebind, 317 reference, 317
174
Boost.Interprocess
segment_manager, 317 size_type, 317 swap, 317, 320 value_type, 317 void_pointer, 317 Class template rbtree_best_t allocate, 371, 372 allocate_aligned, 371, 373 all_memory_deallocated, 371, 372 check_sanity, 371, 372 deallocate, 371, 372 difference_type, 371 get_min_size, 371, 373 grow, 371, 372 multiallocation_chain, 371 mutex_family, 371 rbtree_best_t, 346, 371, 371 shrink_to_t, 371, 372 size_type, 371 void_pointer, 371 zero_free_memory, 371, 372 Class template scoped_lock lock, 472, 474, 474 lock_exception, 474, 474, 474, 475 mutex_type, 472 release, 472, 475 scoped_lock, 343, 472 swap, 472, 475 timed_lock, 472, 474, 474 timed_unlock_upgradable_and_lock, 474 try_lock, 472, 474, 474 try_unlock_sharable_and_lock, 474 try_unlock_upgradable_and_lock, 473 unlock, 472, 474, 475, 475 unlock_upgradable_and_lock, 473 Class template scoped_ptr deleter_type, 405 element_type, 405 get, 405, 406, 406 pointer, 405 release, 405, 405, 406 reset, 405, 405, 405 scoped_ptr, 351, 405, 405, 405 swap, 405, 406 unspecied_bool_type, 405 Class template segment_manager allocator, 387 atomic_func, 387, 390 char_type, 387 construct, 387, 389, 389 construct_it, 387, 389, 390 const_named_iterator, 387 const_unique_iterator, 387 deleter, 387 destroy, 387, 390, 390 destroy_ptr, 387, 390 difference_type, 387 nd, 387, 388, 389
175
Boost.Interprocess
nd_or_construct, 387, 389, 389 nd_or_construct_it, 387, 389, 390 get_allocator, 387, 391 get_deleter, 387, 391 get_instance_length, 387, 391 get_instance_name, 387, 391 get_instance_type, 387, 391 get_min_size, 387, 391 get_num_named_objects, 387, 390 get_num_unique_objects, 387, 391 memory_algorithm, 387 mutex_family, 387 reserve_named_objects, 387, 390 reserve_unique_objects, 387, 390 segment_manager, 348, 387, 387, 388 segment_manager_base, 387 segment_manager_base_type, 387 shrink_to_t_indexes, 387, 390 size_type, 387 try_atomic_func, 387, 390 type, 387 void_pointer, 387 Class template segment_manager_base allocate, 384, 385, 385 allocate_aligned, 384, 385, 385 all_memory_deallocated, 384, 386 check_sanity, 384, 386 deallocate, 384, 385 get_min_size, 384, 386 grow, 384, 385 memory_algorithm, 384 mutex_family, 384 segment_manager_base, 384 segment_manager_base_type, 384 shrink_to_t, 384, 386 void_pointer, 384 zero_free_memory, 384, 386 Class template sharable_lock lock, 476, 478 lock_exception, 478, 478, 478, 478 lock_sharable, 478 mutex_type, 476 release, 476, 478 sharable_lock, 343, 476, 476, 476, 477, 477 swap, 476, 479 timed_lock, 476, 478 timed_lock_sharable, 478 try_lock, 476, 478 try_lock_sharable, 478 unlock, 476, 478 unlock_and_lock_sharable, 477 unlock_sharable, 477, 478 unlock_upgradable_and_lock_sharable, 477 Class template shared_ptr const_allocator_pointer, 410 const_deleter_pointer, 410 const_reference, 410 element_type, 410
176
Boost.Interprocess
get, 410, 411, 412 pointer, 410 reference, 410 reset, 410, 412, 412, 412 shared_ptr, 352, 410 swap, 410, 413 value_type, 410 Class template simple_seq_t simple_seq_t, 346, 373 size_type, 373 Class template std char_type, 430 clear, 430, 431, 431 int_type, 430 off_type, 430 pos_type, 430 reserve, 430, 431, 431, 432, 432 swap_vector, 430, 431, 431 traits_type, 430 vector_type, 430 Class template unique_ptr deleter_type, 415 element_type, 415 get, 415, 416, 417, 418, 418, 418 get_deleter, 415, 416, 417, 418, 418, 418 pointer, 415 release, 415, 418 reset, 415, 418 swap, 415, 418 unique_ptr, 415, 415, 416, 416 Class template unordered_map_index reserve, 340, 341 shrink_to_t, 340, 341 unordered_map_index_aux, 340 Class template upgradable_lock lock, 479, 481 lock_exception, 481, 481, 481, 481 lock_upgradable, 481 mutex_type, 479 release, 479, 482 swap, 479, 482 timed_lock, 479, 481 timed_lock_upgradable, 481 try_lock, 479, 481 try_lock_upgradable, 481 try_unlock_sharable_and_lock_upgradable, 481 unlock, 479, 481 unlock_upgradable, 481, 481 upgradable_lock, 343, 479, 479, 480, 480, 481 Class template weak_ptr element_type, 420 lock, 420, 421 reset, 420, 421 swap, 420, 422 value_type, 420 weak_ptr, 409, 409, 420 Class windows_shared_memory swap, 483, 484
177
Boost.Interprocess
windows_shared_memory, 483 Class xsi_key xsi_key, 485 Class xsi_shared_memory remove, 486, 487, 487 swap, 486, 487 xsi_shared_memory, 486 clear Class template basic_vectorbuf, 428, 429, 429 Class template basic_vectorstream, 432, 433, 433 Class template std, 430, 431, 431 Common Managed Mapped Files managed_mapped_le, 70 wmanaged_mapped_le, 70 Common Managed Shared Memory Classes xed_managed_shared_memory, 67 managed_shared_memory, 67 wxed_managed_shared_memory, 67 wmanaged_shared_memory, 67 construct Class template allocator, 289, 292 Class template cached_adaptive_pool, 294, 296 Class template cached_node_allocator, 300, 302 Class template node_allocator, 305, 307 Class template private_adaptive_pool, 311, 313 Class template private_node_allocator, 317, 319 Class template segment_manager, 387, 389, 389 Constructing Managed Mapped Files remove, 70 construct_it Class template segment_manager, 387, 389, 390 const_allocator_pointer Class template shared_ptr, 410 const_deleter_pointer Class template shared_ptr, 410 const_iterator Class template iset_index, 335 Class template iunordered_set_index, 337 Class template null_index, 339 const_named_iterator Class template segment_manager, 387 const_pointer Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 const_reference Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template shared_ptr, 410
178
Boost.Interprocess
const_unique_iterator Class template segment_manager, 387 Containers of containers void_allocator, 117 create_only_t Struct create_only_t, 325 Creating maps in shared memory name, 8 Creating named shared memory objects if, 4 Creating vectors in shared memory if, 6
D
data What's A Message Queue?, 62 deallocate Class template adaptive_pool, 284, 286, 286, 287 Class template allocator, 289, 290, 291, 291 Class template cached_adaptive_pool, 294, 296, 297, 297 Class template cached_node_allocator, 300, 302, 302, 303 Class template node_allocator, 305, 307, 307, 308 Class template private_adaptive_pool, 311, 313, 314, 314 Class template private_node_allocator, 317, 319, 319, 320 Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 385 Performance of raw memory allocations, 146 Writing a new shared memory allocation algorithm, 148, 149 deallocate_free_blocks Class template adaptive_pool, 284, 286 Class template cached_adaptive_pool, 294, 296 Class template cached_node_allocator, 300, 302 Class template node_allocator, 305, 307 Class template private_adaptive_pool, 311, 313 Class template private_node_allocator, 317, 319 deallocate_individual Class template adaptive_pool, 284, 287 Class template allocator, 289, 291 Class template cached_adaptive_pool, 294, 297 Class template cached_node_allocator, 300, 303 Class template node_allocator, 305, 308 Class template private_adaptive_pool, 311, 314 Class template private_node_allocator, 317, 320 deallocate_many Class template adaptive_pool, 284, 287 Class template allocator, 289, 291 Class template cached_adaptive_pool, 294, 297 Class template cached_node_allocator, 300, 303 Class template node_allocator, 305, 308 Class template private_adaptive_pool, 311, 314 Class template private_node_allocator, 317, 320 deallocate_one Class template adaptive_pool, 284, 287, 287, 287, 287 Class template allocator, 289, 291, 291, 291, 291 Class template cached_adaptive_pool, 294, 297, 297, 297, 297 Class template cached_node_allocator, 300, 303, 303, 303, 303 Class template node_allocator, 305, 308, 308, 308, 308
179
Boost.Interprocess
Class template private_adaptive_pool, 311, 314, 314, 314, 314 Class template private_node_allocator, 317, 320, 320, 320, 320 defer_lock_type Struct defer_lock_type, 449 deleter Class template deleter, 396 Class template segment_manager, 387 Struct template deleter, 392 Struct template managed_shared_ptr, 413 deleter_type Class template scoped_ptr, 405 Class template unique_ptr, 415 Shared pointer and weak pointer, 135 Demotions (Upgradable Mutex only) unlock_and_lock_sharable, 49 unlock_and_lock_upgradable, 49 unlock_upgradable_and_lock_sharable, 49 destroy Class template allocator, 289, 292 Class template cached_adaptive_pool, 294, 296 Class template cached_node_allocator, 300, 302 Class template node_allocator, 305, 307 Class template private_adaptive_pool, 311, 313 Class template private_node_allocator, 317, 319 Class template segment_manager, 387, 390, 390 destroy_ptr Class template segment_manager, 387, 390 difference_type Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template message_queue_t, 353 Class template node_allocator, 305 Class template offset_ptr, 376 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template rbtree_best_t, 371 Class template segment_manager, 387 Direct iostream formatting: vectorstream and bufferstream while, 124
E
element_type Class template intrusive_ptr, 399 Class template offset_ptr, 376 Class template scoped_ptr, 405 Class template shared_ptr, 410 Class template unique_ptr, 415 Class template weak_ptr, 420 enable_shared_from_this Class template enable_shared_from_this, 397 end Class template null_index, 339, 340, 340, 340, 340, 340, 340 Example: Serializing a database through the message queue if, 93 while, 93
180
Boost.Interprocess
Exclusive Locking (Sharable & Upgradable Mutexes) lock, 47 timed_lock, 47 try_lock, 47 unlock, 47 Executing an object function atomically atomic_func, 76 Expand in place memory allocation assert, 83
F
File Locking Operations lock, 58 lock_sharable, 58 timed_lock, 58 timed_lock_sharable, 58 try_lock, 58 try_lock_sharable, 58 unlock, 58 unlock_sharable, 58 le_lock Class le_lock, 434 le_mapping Class le_mapping, 331, 331 nd Class template iset_index, 335, 336, 336 Class template iunordered_set_index, 337, 338, 338 Class template segment_manager, 387, 388, 389 Performance of named allocations, 146 nd_or_construct Class template segment_manager, 387, 389, 389 nd_or_construct_it Class template segment_manager, 387, 389, 390 xed_managed_shared_memory Common Managed Shared Memory Classes, 67 Header < boost/interprocess/interprocess_fwd.hpp >, 341 at_map_index_aux Building custom indexes, 150 Struct template at_map_index_aux, 334 ush Be Careful With Iostream Writing, 62 Class mapped_region, 368, 369 Class template basic_managed_mapped_le, 359, 360 for Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 Formatting directly in your character buffer: bufferstream assert, 127 basic_bufferstream, 127 buffer, 127, 127 bufferstream, 127 char_type, 127 for, 127 int_type, 127 off_type, 127 pos_type, 127 traits_type, 127
181
Boost.Interprocess
wbufferstream, 127 Formatting directly in your character vector: vectorstream assert, 124 basic_vectorstream, 124 char_type, 124 for, 124 int_type, 124 off_type, 124 pos_type, 124 reserve, 124 swap_vector, 124, 124 traits_type, 124 vector_type, 124 Function template make_managed_shared_ptr make_managed_shared_ptr, 413, 414 Function template make_managed_unique_ptr make_managed_unique_ptr, 419 Function template make_managed_weak_ptr make_managed_weak_ptr, 422 Function template swap swap, 403, 406 Function template to_raw_pointer to_raw_pointer, 404, 407
G
get Class template intrusive_ptr, 399, 400, 400, 400, 400, 400 Class template offset_ptr, 376, 378 Class template scoped_ptr, 405, 406, 406 Class template shared_ptr, 410, 411, 412 Class template unique_ptr, 415, 416, 417, 418, 418, 418 get_allocator Class template segment_manager, 387, 391 get_deleter Class template segment_manager, 387, 391 Class template unique_ptr, 415, 416, 417, 418, 418, 418 get_instance_length Class template segment_manager, 387, 391 get_instance_name Class template segment_manager, 387, 391 get_instance_type Class template segment_manager, 387, 391 get_min_size Class template rbtree_best_t, 371, 373 Class template segment_manager, 387, 391 Class template segment_manager_base, 384, 386 Writing a new shared memory allocation algorithm, 148, 149 get_num_msg Class template message_queue_t, 353, 355 get_num_named_objects Class template segment_manager, 387, 390 get_num_unique_objects Class template segment_manager, 387, 391 get_page_size Class mapped_region, 368, 370 Global try_to_lock try_lock, 450
182
Boost.Interprocess
grow Class template basic_managed_external_buffer, 356, 357 Class template basic_managed_heap_memory, 357, 358 Class template basic_managed_mapped_le, 359, 360 Class template basic_managed_shared_memory, 361, 362 Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 385 Managed Heap Memory: Boost.Interprocess machinery in heap memory, 91 Writing a new shared memory allocation algorithm, 148, 149 Growing managed segments assert, 77
H
Header < boost/interprocess/allocators/allocator.hpp > buffer, 288 Header < boost/interprocess/errors.hpp > native_error_t, 328 Header < boost/interprocess/interprocess_fwd.hpp > xed_managed_shared_memory, 341 managed_external_buffer, 341 managed_heap_memory, 341 managed_mapped_le, 341 managed_shared_memory, 341 managed_windows_shared_memory, 341 managed_xsi_shared_memory, 341 message_queue, 341 wxed_managed_shared_memory, 341 wmanaged_external_buffer, 341 wmanaged_heap_memory, 341 wmanaged_mapped_le, 341 wmanaged_shared_memory, 341 wmanaged_windows_shared_memory, 341 wmanaged_xsi_shared_memory, 341 Header < boost/interprocess/offset_ptr.hpp > BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR, 374 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF, 374 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER, 374 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR, 374 Header < boost/interprocess/smart_ptr/intrusive_ptr.hpp > swap, 397 to_raw_pointer, 397 Header < boost/interprocess/smart_ptr/scoped_ptr.hpp > swap, 404 to_raw_pointer, 404 Header < boost/interprocess/smart_ptr/shared_ptr.hpp > make_managed_shared_ptr, 407 swap, 407 to_raw_pointer, 407 Header < boost/interprocess/smart_ptr/unique_ptr.hpp > make_managed_unique_ptr, 414 swap, 414 Header < boost/interprocess/smart_ptr/weak_ptr.hpp > make_managed_weak_ptr, 419 swap, 419 Header < boost/interprocess/streams/bufferstream.hpp > bufferbuf, 422 bufferstream, 422
183
Boost.Interprocess
ibufferstream, 422 obufferstream, 422 wbufferbuf, 422 wbufferstream, 422 wibufferstream, 422 wobufferstream, 422
I
ibufferstream Header < boost/interprocess/streams/bufferstream.hpp >, 422 if Creating named shared memory objects, 4 Creating vectors in shared memory, 6 Example: Serializing a database through the message queue, 93 Intrusive pointer, 131 Managed External Buffer: Constructing all Boost.Interprocess objects in a user provided buffer, 88 Multiple allocation functions, 81 Opening managed shared memory and mapped les with Copy On Write or Read Only modes, 86 Scoped lock, 34 Scoped pointer, 133 Sharable Lock And Upgradable Lock, 51 Using shared memory as a pool of unnamed memory blocks, 3 index_aux Building custom indexes, 150 index_t Building custom indexes, 150 Struct template at_map_index_aux, 334 insert_commit Class template iunordered_set_index, 337, 338 insert_commit_data Class template iset_index, 335 Class template iunordered_set_index, 337 interprocess_condition Class interprocess_condition, 436, 436 interprocess_condition_any Class interprocess_condition_any, 438, 438 interprocess_exception Class bad_alloc, 330 Class interprocess_exception, 329, 329 Class lock_exception, 330 interprocess_mutex Class interprocess_mutex, 439, 439 interprocess_recursive_mutex Class interprocess_recursive_mutex, 441, 441 interprocess_semaphore Class interprocess_semaphore, 442, 442 interprocess_sharable_mutex Class interprocess_sharable_mutex, 444, 444 interprocess_upgradable_mutex Class interprocess_upgradable_mutex, 446, 446 Introduction buffer, 66, 66 Intrusive pointer if, 131 intrusive_ptr_add_ref, 131, 131 intrusive_ptr_release, 131, 131 segment_manager, 131, 131
184
Boost.Interprocess
intrusive_ptr Class template intrusive_ptr, 352, 399 intrusive_ptr_add_ref Class template intrusive_ptr, 399, 399, 400, 400 Intrusive pointer, 131, 131 intrusive_ptr_release Class template intrusive_ptr, 399, 400 Intrusive pointer, 131, 131 int_type Class template basic_bufferbuf, 423 Class template basic_bufferstream, 427 Class template basic_ibufferstream, 424 Class template basic_obufferstream, 425 Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template std, 430 Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 iset_index_aux Class template iset_index, 335 iterator Class template iset_index, 335 Class template iunordered_set_index, 337 Class template null_index, 339 Multiple allocation functions, 81 iterator_category Class template offset_ptr, 376 iunordered_set_index_aux Class template iunordered_set_index, 337
K
key_less Building custom indexes, 150 Struct template at_map_index_aux, 334 key_type Building custom indexes, 150, 150 Struct template at_map_index_aux, 334
L
lock Anonymous condition example, 39, 39 Anonymous mutex example, 35, 35 Class le_lock, 434, 435 Class interprocess_mutex, 439, 440 Class interprocess_recursive_mutex, 441, 441 Class interprocess_sharable_mutex, 444, 444 Class interprocess_upgradable_mutex, 446, 447 Class named_mutex, 456, 457 Class named_recursive_mutex, 458, 459 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 469, 469 Class template scoped_lock, 472, 474, 474 Class template sharable_lock, 476, 478 Class template upgradable_lock, 479, 481 Class template weak_ptr, 420, 421 Exclusive Locking (Sharable & Upgradable Mutexes), 47
185
Boost.Interprocess
File Locking Operations, 58 Mutex Operations, 32 Named mutex example, 38 Scoped lock, 34 Sharable Lock And Upgradable Lock, 51 What's a Sharable and an Upgradable Mutex?, 46 Lock Transfers Through Move Semantics unlock_and_lock_sharable, 53 lock_exception Class lock_exception, 330, 330 Class template scoped_lock, 474, 474, 474, 475 Class template sharable_lock, 478, 478, 478, 478 Class template upgradable_lock, 481, 481, 481, 481 lock_sharable Class le_lock, 434, 435 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 470, 470 Class template sharable_lock, 478 File Locking Operations, 58 Sharable Lock And Upgradable Lock, 51, 51 Sharable Locking (Sharable & Upgradable Mutexes), 48 lock_upgradable Class interprocess_upgradable_mutex, 446, 447 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template upgradable_lock, 481 Sharable Lock And Upgradable Lock, 51 Upgradable Locking (Upgradable Mutex only), 48
M
Macro BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR, 381, 381, 381 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF, 381, 381, 381 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER, 381, 381, 381 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR, 381, 381, 381 make_managed_shared_ptr Function template make_managed_shared_ptr, 413, 414 Header < boost/interprocess/smart_ptr/shared_ptr.hpp >, 407 make_managed_unique_ptr Function template make_managed_unique_ptr, 419 Header < boost/interprocess/smart_ptr/unique_ptr.hpp >, 414 make_managed_weak_ptr Function template make_managed_weak_ptr, 422 Header < boost/interprocess/smart_ptr/weak_ptr.hpp >, 419 Managed External Buffer: Constructing all Boost.Interprocess objects in a user provided buffer if, 88 managed_external_buffer, 88 wmanaged_external_buffer, 88 Managed Heap Memory: Boost.Interprocess machinery in heap memory grow, 91 managed_heap_memory, 91
186
Boost.Interprocess
wmanaged_heap_memory, 91 managed_external_buffer Header < boost/interprocess/interprocess_fwd.hpp >, 341 Managed External Buffer: Constructing all Boost.Interprocess objects in a user provided buffer, 88 managed_heap_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 Managed Heap Memory: Boost.Interprocess machinery in heap memory, 91 managed_mapped_le Common Managed Mapped Files, 70 Header < boost/interprocess/interprocess_fwd.hpp >, 341 managed_shared_memory Common Managed Shared Memory Classes, 67 Header < boost/interprocess/interprocess_fwd.hpp >, 341 managed_shared_ptr Struct template managed_shared_ptr, 413 managed_unique_ptr Struct template managed_unique_ptr, 419 managed_weak_ptr Struct template managed_weak_ptr, 422 managed_windows_shared_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 managed_xsi_shared_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 mapped_region Class mapped_region, 368, 368, 368 mapped_type Building custom indexes, 150, 150 Struct template at_map_index_aux, 334 Mapping Address Independent Pointer: offset_ptr assert, 29 memory_algorithm Class template segment_manager, 387 Class template segment_manager_base, 384 message_queue Header < boost/interprocess/interprocess_fwd.hpp >, 341 message_queue_t Class template message_queue_t, 352, 353 Move semantics in Interprocess containers assert, 115 multiallocation_chain Class template rbtree_best_t, 371 Multiple allocation functions, 81 Multiple allocation functions allocate, 81, 81 allocate_many, 81, 81, 81 if, 81 iterator, 81 multiallocation_chain, 81 while, 81 Mutex Operations lock, 32 timed_lock, 32 try_lock, 32 unlock, 32 mutex_family Class template rbtree_best_t, 371 Class template segment_manager, 387 Class template segment_manager_base, 384
187
Boost.Interprocess
Struct mutex_family, 451 The memory algorithm, 142 Writing a new shared memory allocation algorithm, 148, 148, 148, 148, 149 mutex_type Class template scoped_lock, 472 Class template sharable_lock, 476 Class template upgradable_lock, 479 Struct mutex_family, 451 Struct null_mutex_family, 451 Writing a new shared memory allocation algorithm, 148
N
name Boost unordered containers, 118 Building custom indexes, 150 Creating maps in shared memory, 8 Named mutex example lock, 38 named_condition Class named_condition, 452, 452, 453 named_condition_any Class named_condition_any, 454, 454, 455 named_mutex Class named_mutex, 456, 456, 457 named_recursive_mutex Class named_recursive_mutex, 458, 458, 458 named_semaphore Class named_semaphore, 460, 460, 460 named_sharable_mutex Class named_sharable_mutex, 462, 462, 462 named_upgradable_mutex Class named_upgradable_mutex, 465, 465, 465 native_error_t Header < boost/interprocess/errors.hpp >, 328 node_allocator Class template node_allocator, 305, 306 node_allocator: A process-shared segregated storage assert, 99 notify_all Class interprocess_condition, 436, 437 Class interprocess_condition_any, 438, 438 Class named_condition, 452, 453 Class named_condition_any, 454, 455 notify_one Class interprocess_condition, 436, 437 Class interprocess_condition_any, 438, 438 Class named_condition, 452, 453 Class named_condition_any, 454, 455 null_index Class template null_index, 339, 339, 347 null_mutex Class null_mutex, 469, 469 null_mutex_family Struct null_mutex_family, 451
O
obufferstream
188
Boost.Interprocess
Header < boost/interprocess/streams/bufferstream.hpp >, 422 offset_ptr Class template offset_ptr, 345, 376, 376, 377, 377, 377, 377, 377, 378 offset_type Class template offset_ptr, 376 off_type Class template basic_bufferbuf, 423 Class template basic_bufferstream, 427 Class template basic_ibufferstream, 424 Class template basic_obufferstream, 425 Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template std, 430 Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 Opening managed shared memory and mapped les with Copy On Write or Read Only modes if, 86 open_copy_on_write_t Struct open_copy_on_write_t, 326 open_only_t Struct open_only_t, 325 open_or_create_t Struct open_or_create_t, 326 open_read_only_t Struct open_read_only_t, 325 open_read_private_t Struct open_read_private_t, 326 other Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305 Class template offset_ptr, 376 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Struct template rebind, 287, 292, 298, 304, 309, 315, 320, 380
P
Performance of named allocations nd, 146 Performance of raw memory allocations allocate, 146, 146 deallocate, 146 reserve, 146 permissions Class permissions, 382 pointer Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template deleter, 396 Class template intrusive_ptr, 399 Class template node_allocator, 305 Class template offset_ptr, 376 Class template private_adaptive_pool, 311
189
Boost.Interprocess
Class template private_node_allocator, 317 Class template scoped_ptr, 405 Class template shared_ptr, 410 Class template unique_ptr, 415 Scoped pointer, 133 pointer_to Class template offset_ptr, 376, 379 post Class interprocess_semaphore, 442, 442 Class named_semaphore, 460, 461 pos_type Class template basic_bufferbuf, 423 Class template basic_bufferstream, 427 Class template basic_ibufferstream, 424 Class template basic_obufferstream, 425 Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template std, 430 Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 pred Class interprocess_condition, 437 Class interprocess_condition_any, 439 Class named_condition, 453 Class named_condition_any, 456 private_adaptive_pool Class template private_adaptive_pool, 311, 312 private_adaptive_pool: a private adaptive pool assert, 107 private_node_allocator Class template private_node_allocator, 317, 318 private_node_allocator: a private segregated storage assert, 100 Promotions (Upgradable Mutex only) timed_unlock_upgradable_and_lock, 50 try_unlock_sharable_and_lock, 50 try_unlock_sharable_and_lock_upgradable, 50 try_unlock_upgradable_and_lock, 50 unlock_upgradable_and_lock, 50
R
rbtree_best_t Class template rbtree_best_t, 346, 371, 371 rebind Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305 Class template offset_ptr, 376 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Struct template rebind, 287, 292, 298, 304, 309, 315, 320, 380 receive Class template message_queue_t, 353, 354 recursive_mutex_type Struct mutex_family, 451
190
Boost.Interprocess
Struct null_mutex_family, 451 Writing a new shared memory allocation algorithm, 148 reference Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305 Class template offset_ptr, 376 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template shared_ptr, 410 release Class template scoped_lock, 472, 475 Class template scoped_ptr, 405, 405, 406 Class template sharable_lock, 476, 478 Class template unique_ptr, 415, 418 Class template upgradable_lock, 479, 482 Scoped pointer, 133, 133 remove Class le_mapping, 331, 332 Class named_condition, 452, 453, 454 Class named_condition_any, 454, 455, 456 Class named_mutex, 456, 457, 457 Class named_recursive_mutex, 458, 459, 459 Class named_semaphore, 460, 460, 461 Class named_sharable_mutex, 462, 462, 464 Class named_upgradable_mutex, 465, 466, 468 Class shared_memory_object, 393, 394, 394 Class template basic_managed_mapped_le, 360 Class template basic_managed_shared_memory, 362 Class template basic_managed_xsi_shared_memory, 366, 367, 367 Class template message_queue_t, 353, 354, 355 Class xsi_shared_memory, 486, 487, 487 Constructing Managed Mapped Files, 70 Removing shared memory, 17 remove_le_on_destroy Class remove_le_on_destroy, 333 remove_shared_memory_on_destroy Class remove_shared_memory_on_destroy, 395 Removing shared memory remove, 17 reserve Building custom indexes, 150, 150 Class template basic_vectorbuf, 428, 429 Class template basic_vectorstream, 432, 433, 433 Class template at_map_index, 334, 334 Class template iset_index, 335, 335 Class template iunordered_set_index, 337, 337 Class template map_index, 338, 339 Class template std, 430, 431, 431, 432, 432 Class template unordered_map_index, 340, 341 Formatting directly in your character vector: vectorstream, 124 Performance of raw memory allocations, 146 reserve_named_objects Class template segment_manager, 387, 390 reserve_unique_objects Class template segment_manager, 387, 390
191
Boost.Interprocess
reset Class template scoped_ptr, 405, 405, 405 Class template shared_ptr, 410, 412, 412, 412 Class template unique_ptr, 415, 418 Class template weak_ptr, 420, 421
S
Scoped lock if, 34 lock, 34 unlock, 34 Scoped Lock and Sharable Lock With File Locking unlock_and_lock_sharable, 60 Scoped pointer if, 133 pointer, 133 release, 133, 133 segment_manager, 133, 133 scoped_lock Class template scoped_lock, 343, 472 scoped_ptr Class template scoped_ptr, 351, 405, 405, 405 segment_manager Building custom indexes, 150 Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template segment_manager, 348, 387, 387, 388 Intrusive pointer, 131, 131 Scoped pointer, 133, 133 segment_manager_base Building custom indexes, 150, 150 Class template segment_manager, 387 Class template segment_manager_base, 384 Struct template at_map_index_aux, 334 segment_manager_base_type Class template segment_manager, 387 Class template segment_manager_base, 384 send Class template message_queue_t, 353, 354 set_default Class permissions, 382, 382 set_max_cached_nodes cached_adaptive_pool: Avoiding synchronization overhead, 109 cached_node_allocator: caching nodes to avoid overhead, 103 Class template cached_adaptive_pool, 294, 297 Class template cached_node_allocator, 300, 303 set_permissions Class permissions, 382, 382 set_unrestricted Class permissions, 382, 382 Sharable Lock And Upgradable Lock if, 51
192
Boost.Interprocess
lock, 51 lock_sharable, 51, 51 lock_upgradable, 51 timed_lock_sharable, 51 timed_lock_upgradable, 51 try_lock_sharable, 51 try_lock_upgradable, 51 unlock_sharable, 51, 51 unlock_upgradable, 51 Sharable Locking (Sharable & Upgradable Mutexes) lock_sharable, 48 timed_lock_sharable, 48 try_lock_sharable, 48 unlock_sharable, 48 sharable_lock Class template sharable_lock, 343, 476, 476, 476, 477, 477 Shared pointer and weak pointer assert, 135 deleter_type, 135 shared_memory_object Class shared_memory_object, 393 shared_ptr Class template shared_ptr, 352, 410 shrink_by Class mapped_region, 368, 369 shrink_to_t Building custom indexes, 150 Class template basic_managed_mapped_le, 359, 360 Class template basic_managed_shared_memory, 361, 363 Class template at_map_index, 334, 334 Class template iset_index, 335, 336 Class template iunordered_set_index, 337, 337 Class template map_index, 338, 339 Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 386 Class template unordered_map_index, 340, 341 shrink_to_t_indexes Class template segment_manager, 387, 390 Simple Lock Transfer unlock, 53 unlock_sharable, 53 simple_seq_t Class template simple_seq_t, 346, 373 size_type Class template adaptive_pool, 284 Class template allocator, 289 Class template basic_managed_external_buffer, 356 Class template basic_managed_heap_memory, 357 Class template basic_managed_windows_shared_memory, 364 Class template basic_managed_xsi_shared_memory, 366 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template iunordered_set_index, 337 Class template message_queue_t, 353 Class template node_allocator, 305 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template rbtree_best_t, 371
193
Boost.Interprocess
Class template segment_manager, 387 Class template simple_seq_t, 373 Struct accept_ownership_type accept_ownership_type, 450 Struct create_only_t create_only_t, 325 Struct defer_lock_type defer_lock_type, 449 Struct mutex_family mutex_family, 451 mutex_type, 451 recursive_mutex_type, 451 Struct null_mutex_family mutex_type, 451 null_mutex_family, 451 recursive_mutex_type, 451 Struct open_copy_on_write_t open_copy_on_write_t, 326 Struct open_only_t open_only_t, 325 Struct open_or_create_t open_or_create_t, 326 Struct open_read_only_t open_read_only_t, 325 Struct open_read_private_t open_read_private_t, 326 Struct template allocator allocator, 392 type, 392 Struct template deleter deleter, 392 type, 392 Struct template at_map_index_aux allocator_type, 334 at_map_index_aux, 334 index_t, 334 key_less, 334 key_type, 334 mapped_type, 334 segment_manager_base, 334 value_type, 334 Struct template managed_shared_ptr deleter, 413 managed_shared_ptr, 413 type, 413 void_allocator, 413 Struct template managed_unique_ptr managed_unique_ptr, 419 type, 419 Struct template managed_weak_ptr managed_weak_ptr, 422 type, 422 Struct template rebind other, 287, 292, 298, 304, 309, 315, 320, 380 rebind, 287, 292, 298, 304, 309, 315, 320, 380 Struct try_to_lock_type try_to_lock_type, 450 swap
194
Boost.Interprocess
Class le_lock, 434, 435 Class le_mapping, 331, 332 Class mapped_region, 368, 369 Class shared_memory_object, 393, 394 Class template adaptive_pool, 284, 287 Class template allocator, 289, 292 Class template basic_managed_external_buffer, 356, 357 Class template basic_managed_heap_memory, 357, 358 Class template basic_managed_mapped_le, 359, 360 Class template basic_managed_shared_memory, 361, 362 Class template basic_managed_windows_shared_memory, 364, 365 Class template basic_managed_xsi_shared_memory, 366, 367 Class template cached_adaptive_pool, 294, 298 Class template cached_node_allocator, 300, 303 Class template intrusive_ptr, 399, 401 Class template node_allocator, 305, 308 Class template private_adaptive_pool, 311, 314 Class template private_node_allocator, 317, 320 Class template scoped_lock, 472, 475 Class template scoped_ptr, 405, 406 Class template sharable_lock, 476, 479 Class template shared_ptr, 410, 413 Class template unique_ptr, 415, 418 Class template upgradable_lock, 479, 482 Class template weak_ptr, 420, 422 Class windows_shared_memory, 483, 484 Class xsi_shared_memory, 486, 487 Function template swap, 403, 406 Header < boost/interprocess/smart_ptr/intrusive_ptr.hpp >, 397 Header < boost/interprocess/smart_ptr/scoped_ptr.hpp >, 404 Header < boost/interprocess/smart_ptr/shared_ptr.hpp >, 407 Header < boost/interprocess/smart_ptr/unique_ptr.hpp >, 414 Header < boost/interprocess/smart_ptr/weak_ptr.hpp >, 419 swap_vector Class template basic_vectorbuf, 428, 429 Class template basic_vectorstream, 432, 433 Class template std, 430, 431, 431 Formatting directly in your character vector: vectorstream, 124, 124 Synchronization guarantees allocate, 74
T
The memory algorithm mutex_family, 142 void_pointer, 142 The segment manager allocate, 143 timed_lock Class le_lock, 434, 435 Class interprocess_mutex, 439, 440 Class interprocess_recursive_mutex, 441, 441 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_mutex, 456, 457 Class named_recursive_mutex, 458, 459 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466
195
Boost.Interprocess
Class null_mutex, 469, 470, 470 Class template scoped_lock, 472, 474, 474 Class template sharable_lock, 476, 478 Class template upgradable_lock, 479, 481 Exclusive Locking (Sharable & Upgradable Mutexes), 47 File Locking Operations, 58 Mutex Operations, 32 timed_lock_sharable Class le_lock, 434, 435 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 470, 470 Class template sharable_lock, 478 File Locking Operations, 58 Sharable Lock And Upgradable Lock, 51 Sharable Locking (Sharable & Upgradable Mutexes), 48 timed_lock_upgradable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template upgradable_lock, 481 Sharable Lock And Upgradable Lock, 51 Upgradable Locking (Upgradable Mutex only), 48 timed_receive Class template message_queue_t, 353, 355 timed_send Class template message_queue_t, 353, 354 timed_unlock_upgradable_and_lock Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 468 Class null_mutex, 469, 471, 471 Class template scoped_lock, 474 Promotions (Upgradable Mutex only), 50 Transfers To Scoped Lock, 55 timed_wait Class interprocess_condition, 436, 437, 437 Class interprocess_condition_any, 438, 439, 439 Class interprocess_semaphore, 442, 443 Class named_condition, 452, 453, 453 Class named_condition_any, 454, 455, 456 Class named_semaphore, 460, 461 to_raw_pointer Function template to_raw_pointer, 404, 407 Header < boost/interprocess/smart_ptr/intrusive_ptr.hpp >, 397 Header < boost/interprocess/smart_ptr/scoped_ptr.hpp >, 404 Header < boost/interprocess/smart_ptr/shared_ptr.hpp >, 407 traits_type Class template basic_bufferbuf, 423 Class template basic_bufferstream, 427 Class template basic_ibufferstream, 424 Class template basic_obufferstream, 425 Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template std, 430 Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124
196
Boost.Interprocess
Transferring Unlocked Locks assert, 56 unlock_and_lock_sharable, 56 Transfers To Scoped Lock timed_unlock_upgradable_and_lock, 55 try_unlock_sharable_and_lock, 55 try_unlock_upgradable_and_lock, 55 unlock_upgradable_and_lock, 55 Transfers To Sharable Lock unlock_and_lock_sharable, 56 unlock_upgradable_and_lock_sharable, 56 Transfers To Upgradable Lock try_unlock_sharable_and_lock_upgradable, 55 unlock_and_lock_upgradable, 55 truncate Class shared_memory_object, 393, 394 try_atomic_func Class template segment_manager, 387, 390 try_lock Class le_lock, 434, 435 Class interprocess_mutex, 439, 440 Class interprocess_recursive_mutex, 441, 441 Class interprocess_sharable_mutex, 444, 444 Class interprocess_upgradable_mutex, 446, 447 Class named_mutex, 456, 457 Class named_recursive_mutex, 458, 459 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 469, 469 Class template scoped_lock, 472, 474, 474 Class template sharable_lock, 476, 478 Class template upgradable_lock, 479, 481 Exclusive Locking (Sharable & Upgradable Mutexes), 47 File Locking Operations, 58 Global try_to_lock, 450 Mutex Operations, 32 try_lock_sharable Class le_lock, 434, 435 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 470, 470 Class template sharable_lock, 478 File Locking Operations, 58 Sharable Lock And Upgradable Lock, 51 Sharable Locking (Sharable & Upgradable Mutexes), 48 try_lock_upgradable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template upgradable_lock, 481 Sharable Lock And Upgradable Lock, 51 Upgradable Locking (Upgradable Mutex only), 48 try_receive Class template message_queue_t, 353, 355 try_send Class template message_queue_t, 353, 354
197
Boost.Interprocess
try_to_lock_type Struct try_to_lock_type, 450 try_unlock_sharable_and_lock Class interprocess_upgradable_mutex, 446, 449 Class named_upgradable_mutex, 465, 468 Class null_mutex, 469, 471, 471 Class template scoped_lock, 474 Promotions (Upgradable Mutex only), 50 Transfers To Scoped Lock, 55 try_unlock_sharable_and_lock_upgradable Class interprocess_upgradable_mutex, 446, 449 Class named_upgradable_mutex, 465, 468 Class null_mutex, 469, 471, 471 Class template upgradable_lock, 481 Promotions (Upgradable Mutex only), 50 Transfers To Upgradable Lock, 55 try_unlock_upgradable_and_lock Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 468 Class null_mutex, 469, 471, 471 Class template scoped_lock, 473 Promotions (Upgradable Mutex only), 50 Transfers To Scoped Lock, 55 try_wait Class interprocess_semaphore, 442, 443 Class named_semaphore, 460, 461 type Class template segment_manager, 387 Struct template allocator, 392 Struct template deleter, 392 Struct template managed_shared_ptr, 413 Struct template managed_unique_ptr, 419 Struct template managed_weak_ptr, 422
U
Unique pointer assert, 139 unique_ptr Class template unique_ptr, 415, 415, 416, 416 unlock Class le_lock, 434, 435 Class interprocess_mutex, 439, 440 Class interprocess_recursive_mutex, 441, 441 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_mutex, 456, 457 Class named_recursive_mutex, 458, 459 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 470, 470 Class template scoped_lock, 472, 474, 475, 475 Class template sharable_lock, 476, 478 Class template upgradable_lock, 479, 481 Exclusive Locking (Sharable & Upgradable Mutexes), 47 File Locking Operations, 58 Mutex Operations, 32 Scoped lock, 34
198
Boost.Interprocess
Simple Lock Transfer, 53 unlock_and_lock_sharable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template sharable_lock, 477 Demotions (Upgradable Mutex only), 49 Lock Transfers Through Move Semantics, 53 Scoped Lock and Sharable Lock With File Locking, 60 Transferring Unlocked Locks, 56 Transfers To Sharable Lock, 56 unlock_and_lock_upgradable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Demotions (Upgradable Mutex only), 49 Transfers To Upgradable Lock, 55 unlock_sharable Class le_lock, 434, 435 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template sharable_lock, 477, 478 File Locking Operations, 58 Sharable Lock And Upgradable Lock, 51, 51 Sharable Locking (Sharable & Upgradable Mutexes), 48 Simple Lock Transfer, 53 unlock_upgradable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template upgradable_lock, 481, 481 Sharable Lock And Upgradable Lock, 51 Upgradable Locking (Upgradable Mutex only), 48 unlock_upgradable_and_lock Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 471, 471 Class template scoped_lock, 473 Promotions (Upgradable Mutex only), 50 Transfers To Scoped Lock, 55 unlock_upgradable_and_lock_sharable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template sharable_lock, 477 Demotions (Upgradable Mutex only), 49 Transfers To Sharable Lock, 56 unordered_map_index_aux Class template unordered_map_index, 340 unspecied_bool_type Class template scoped_ptr, 405 Upgradable Locking (Upgradable Mutex only) lock_upgradable, 48 timed_lock_upgradable, 48 try_lock_upgradable, 48
199
Boost.Interprocess
unlock_upgradable, 48 upgradable_lock Class template upgradable_lock, 343, 479, 479, 480, 480, 481 Using shared memory as a pool of unnamed memory blocks if, 3
V
value_type Building custom indexes, 150 Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template iset_index, 335 Class template iunordered_set_index, 337 Class template node_allocator, 305 Class template offset_ptr, 376 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template shared_ptr, 410 Class template weak_ptr, 420 Struct template at_map_index_aux, 334 vector_type Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template std, 430 Formatting directly in your character vector: vectorstream, 124 version Class template allocator, 289 void_allocator Containers of containers, 117 Struct template managed_shared_ptr, 413 void_pointer Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template message_queue_t, 353 Class template node_allocator, 305 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template rbtree_best_t, 371 Class template segment_manager, 387 Class template segment_manager_base, 384 The memory algorithm, 142 Writing a new shared memory allocation algorithm, 148, 148, 148, 148
W
wait Class bad_alloc, 330 Class interprocess_condition, 436, 437, 437 Class interprocess_condition_any, 438, 438, 439 Class interprocess_semaphore, 442, 443 Class named_condition, 452, 453, 453 Class named_condition_any, 454, 455, 455 Class named_semaphore, 460, 461 wbufferbuf
200
Boost.Interprocess
Header < boost/interprocess/streams/bufferstream.hpp >, 422 wbufferstream Formatting directly in your character buffer: bufferstream, 127 Header < boost/interprocess/streams/bufferstream.hpp >, 422 weak_ptr Class template weak_ptr, 409, 409, 420 wxed_managed_shared_memory Common Managed Shared Memory Classes, 67 Header < boost/interprocess/interprocess_fwd.hpp >, 341 What's A Message Queue? data, 62 What's a Sharable and an Upgradable Mutex? lock, 46 while Anonymous mutex example, 35, 35 Direct iostream formatting: vectorstream and bufferstream, 124 Example: Serializing a database through the message queue, 93 Multiple allocation functions, 81 wibufferstream Header < boost/interprocess/streams/bufferstream.hpp >, 422 windows_shared_memory Class windows_shared_memory, 483 wmanaged_external_buffer Header < boost/interprocess/interprocess_fwd.hpp >, 341 Managed External Buffer: Constructing all Boost.Interprocess objects in a user provided buffer, 88 wmanaged_heap_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 Managed Heap Memory: Boost.Interprocess machinery in heap memory, 91 wmanaged_mapped_le Common Managed Mapped Files, 70 Header < boost/interprocess/interprocess_fwd.hpp >, 341 wmanaged_shared_memory Common Managed Shared Memory Classes, 67 Header < boost/interprocess/interprocess_fwd.hpp >, 341 wmanaged_windows_shared_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 wmanaged_xsi_shared_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 wobufferstream Header < boost/interprocess/streams/bufferstream.hpp >, 422 Writing a new shared memory allocation algorithm allocate, 148, 149, 149, 149 deallocate, 148, 149 get_min_size, 148, 149 grow, 148, 149 mutex_family, 148, 148, 148, 148, 149 mutex_type, 148 recursive_mutex_type, 148 void_pointer, 148, 148, 148, 148
X
xsi_key Class xsi_key, 485 xsi_shared_memory Class xsi_shared_memory, 486
201
Boost.Interprocess
Z
zero_free_memory Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 386
Typedef Index
A
accept_ownership_type Struct accept_ownership_type, 450 adaptive_pool Class template adaptive_pool, 284, 285 adaptive_pool: a process-shared adaptive pool assert, 105 advise Class mapped_region, 368, 370 allocate Class template adaptive_pool, 284, 286 Class template allocator, 289, 290 Class template cached_adaptive_pool, 294, 296 Class template cached_node_allocator, 300, 302 Class template node_allocator, 305, 307 Class template private_adaptive_pool, 311, 313 Class template private_node_allocator, 317, 319 Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 385, 385 Multiple allocation functions, 81, 81 Performance of raw memory allocations, 146, 146 Synchronization guarantees, 74 The segment manager, 143 Writing a new shared memory allocation algorithm, 148, 149, 149, 149 allocate_aligned Class template rbtree_best_t, 371, 373 Class template segment_manager_base, 384, 385, 385 allocate_individual Class template adaptive_pool, 284, 287 Class template allocator, 289, 291 Class template cached_adaptive_pool, 294, 297 Class template cached_node_allocator, 300, 303 Class template node_allocator, 305, 308 Class template private_adaptive_pool, 311, 314 Class template private_node_allocator, 317, 320 allocate_many Class template adaptive_pool, 284, 286, 286 Class template allocator, 289, 291, 291 Class template cached_adaptive_pool, 294, 297, 297 Class template cached_node_allocator, 300, 302, 303 Class template node_allocator, 305, 307, 308 Class template private_adaptive_pool, 311, 314, 314 Class template private_node_allocator, 317, 319, 319 Multiple allocation functions, 81, 81, 81 allocate_one Class template adaptive_pool, 284, 287, 287 Class template allocator, 289, 291, 291 Class template cached_adaptive_pool, 294, 297, 297 Class template cached_node_allocator, 300, 303, 303
202
Boost.Interprocess
Class template node_allocator, 305, 308, 308 Class template private_adaptive_pool, 311, 314, 314 Class template private_node_allocator, 317, 320, 320 Allocating aligned memory portions assert, 79 allocator Class template allocator, 289, 344 Class template segment_manager, 387 Struct template allocator, 392 allocator_holder Class template iunordered_set_index, 337 allocator_type Building custom indexes, 150 Struct template at_map_index_aux, 334 all_memory_deallocated Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 386 Anonymous condition example buffer, 39 lock, 39, 39 Anonymous mutex example lock, 35, 35 while, 35, 35 assert adaptive_pool: a process-shared adaptive pool, 105 Allocating aligned memory portions, 79 cached_adaptive_pool: Avoiding synchronization overhead, 108 cached_node_allocator: caching nodes to avoid overhead, 102 Expand in place memory allocation, 83 Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 Growing managed segments, 77 Mapping Address Independent Pointer: offset_ptr, 29 Move semantics in Interprocess containers, 115 node_allocator: A process-shared segregated storage, 99 private_adaptive_pool: a private adaptive pool, 107 private_node_allocator: a private segregated storage, 100 Shared pointer and weak pointer, 135 Transferring Unlocked Locks, 56 Unique pointer, 139 atomic_func Class template segment_manager, 387, 390 Executing an object function atomically, 76
B
bad_alloc Class bad_alloc, 330, 330 base_t Class template basic_bufferbuf, 423 base_type Building custom indexes, 150 basic_bufferbuf Class template basic_bufferbuf, 349, 423 basic_bufferstream Class template basic_bufferstream, 350, 427 Formatting directly in your character buffer: bufferstream, 127 basic_ibufferstream
203
Boost.Interprocess
Class template basic_ibufferstream, 350, 424 basic_managed_external_buffer Class template basic_managed_external_buffer, 348, 356, 356 basic_managed_heap_memory Class template basic_managed_heap_memory, 349, 357, 357 basic_managed_mapped_le Class template basic_managed_mapped_le, 349, 359 basic_managed_shared_memory Class template basic_managed_shared_memory, 348, 361, 361 basic_managed_windows_shared_memory Class template basic_managed_windows_shared_memory, 348, 364, 364 basic_managed_xsi_shared_memory Class template basic_managed_xsi_shared_memory, 349, 366, 366 basic_obufferstream Class template basic_obufferstream, 350, 425 basic_vectorbuf Class template basic_vectorbuf, 350, 428 basic_vectorstream Class template basic_vectorstream, 351, 432 Formatting directly in your character vector: vectorstream, 124 Be Careful With Iostream Writing ush, 62 begin Class template null_index, 339, 340, 340 Boost unordered containers name, 118 BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR Header < boost/interprocess/offset_ptr.hpp >, 374 Macro BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR, 381, 381, 381 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF Header < boost/interprocess/offset_ptr.hpp >, 374 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF, 381, 381, 381 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER Header < boost/interprocess/offset_ptr.hpp >, 374 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER, 381, 381, 381 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR Header < boost/interprocess/offset_ptr.hpp >, 374 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR, 381, 381, 381 bucket_ptr Class template iunordered_set_index, 337 bucket_traits Class template iunordered_set_index, 337 bucket_type Class template iunordered_set_index, 337 buffer Anonymous condition example, 39 Building custom indexes, 150 Class template basic_bufferbuf, 423, 424, 424 Class template basic_bufferstream, 427, 427, 427 Class template basic_ibufferstream, 424, 425, 425 Class template basic_obufferstream, 425, 426, 426 Formatting directly in your character buffer: bufferstream, 127, 127 Header < boost/interprocess/allocators/allocator.hpp >, 288 Introduction, 66, 66 bufferbuf Header < boost/interprocess/streams/bufferstream.hpp >, 422 bufferstream Formatting directly in your character buffer: bufferstream, 127
204
Boost.Interprocess
Header < boost/interprocess/streams/bufferstream.hpp >, 422 Building custom indexes allocator_type, 150 base_type, 150 buffer, 150 char_type, 150 at_map_index_aux, 150 index_aux, 150 index_t, 150 key_less, 150 key_type, 150, 150 mapped_type, 150, 150 name, 150 reserve, 150, 150 segment_manager, 150 segment_manager_base, 150, 150 shrink_to_t, 150 value_type, 150
C
cached_adaptive_pool Class template cached_adaptive_pool, 294, 295 cached_adaptive_pool: Avoiding synchronization overhead assert, 108 set_max_cached_nodes, 109 cached_node_allocator Class template cached_node_allocator, 300, 301 cached_node_allocator: caching nodes to avoid overhead assert, 102 set_max_cached_nodes, 103 char_ptr Class template message_queue_t, 353 char_type Building custom indexes, 150 Class template basic_bufferbuf, 423 Class template basic_bufferstream, 427 Class template basic_ibufferstream, 424 Class template basic_obufferstream, 425 Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template segment_manager, 387 Class template std, 430 Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 check_sanity Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 386 Class bad_alloc bad_alloc, 330, 330 interprocess_exception, 330 wait, 330 Class le_lock le_lock, 434 lock, 434, 435 lock_sharable, 434, 435 swap, 434, 435 timed_lock, 434, 435
205
Boost.Interprocess
timed_lock_sharable, 434, 435 try_lock, 434, 435 try_lock_sharable, 434, 435 unlock, 434, 435 unlock_sharable, 434, 435 Class le_mapping le_mapping, 331, 331 remove, 331, 332 swap, 331, 332 Class interprocess_condition interprocess_condition, 436, 436 notify_all, 436, 437 notify_one, 436, 437 pred, 437 timed_wait, 436, 437, 437 wait, 436, 437, 437 Class interprocess_condition_any interprocess_condition_any, 438, 438 notify_all, 438, 438 notify_one, 438, 438 pred, 439 timed_wait, 438, 439, 439 wait, 438, 438, 439 Class interprocess_exception interprocess_exception, 329, 329 Class interprocess_mutex interprocess_mutex, 439, 439 lock, 439, 440 timed_lock, 439, 440 try_lock, 439, 440 unlock, 439, 440 Class interprocess_recursive_mutex interprocess_recursive_mutex, 441, 441 lock, 441, 441 timed_lock, 441, 441 try_lock, 441, 441 unlock, 441, 441 Class interprocess_semaphore interprocess_semaphore, 442, 442 post, 442, 442 timed_wait, 442, 443 try_wait, 442, 443 wait, 442, 443 Class interprocess_sharable_mutex interprocess_sharable_mutex, 444, 444 lock, 444, 444 lock_sharable, 444, 445 timed_lock, 444, 445 timed_lock_sharable, 444, 445 try_lock, 444, 444 try_lock_sharable, 444, 445 unlock, 444, 445 unlock_sharable, 444, 445 Class interprocess_upgradable_mutex interprocess_upgradable_mutex, 446, 446 lock, 446, 447 lock_sharable, 446, 447 lock_upgradable, 446, 447
206
Boost.Interprocess
timed_lock, 446, 447 timed_lock_sharable, 446, 447 timed_lock_upgradable, 446, 448 timed_unlock_upgradable_and_lock, 446, 448 try_lock, 446, 447 try_lock_sharable, 446, 447 try_lock_upgradable, 446, 448 try_unlock_sharable_and_lock, 446, 449 try_unlock_sharable_and_lock_upgradable, 446, 449 try_unlock_upgradable_and_lock, 446, 448 unlock, 446, 447 unlock_and_lock_sharable, 446, 448 unlock_and_lock_upgradable, 446, 448 unlock_sharable, 446, 447 unlock_upgradable, 446, 448 unlock_upgradable_and_lock, 446, 448 unlock_upgradable_and_lock_sharable, 446, 448 Class lock_exception interprocess_exception, 330 lock_exception, 330, 330 Class mapped_region advise, 368, 370 ush, 368, 369 get_page_size, 368, 370 mapped_region, 368, 368, 368 shrink_by, 368, 369 swap, 368, 369 Class named_condition named_condition, 452, 452, 453 notify_all, 452, 453 notify_one, 452, 453 pred, 453 remove, 452, 453, 454 timed_wait, 452, 453, 453 wait, 452, 453, 453 Class named_condition_any named_condition_any, 454, 454, 455 notify_all, 454, 455 notify_one, 454, 455 pred, 456 remove, 454, 455, 456 timed_wait, 454, 455, 456 wait, 454, 455, 455 Class named_mutex lock, 456, 457 named_mutex, 456, 456, 457 remove, 456, 457, 457 timed_lock, 456, 457 try_lock, 456, 457 unlock, 456, 457 Class named_recursive_mutex lock, 458, 459 named_recursive_mutex, 458, 458, 458 remove, 458, 459, 459 timed_lock, 458, 459 try_lock, 458, 459 unlock, 458, 459 Class named_semaphore
207
Boost.Interprocess
named_semaphore, 460, 460, 460 post, 460, 461 remove, 460, 460, 461 timed_wait, 460, 461 try_wait, 460, 461 wait, 460, 461 Class named_sharable_mutex lock, 462, 463 lock_sharable, 462, 463 named_sharable_mutex, 462, 462, 462 remove, 462, 462, 464 timed_lock, 462, 463 timed_lock_sharable, 462, 463 try_lock, 462, 463 try_lock_sharable, 462, 463 unlock, 462, 463 unlock_sharable, 462, 463 Class named_upgradable_mutex lock, 465, 466 lock_sharable, 465, 466 lock_upgradable, 465, 467 named_upgradable_mutex, 465, 465, 465 remove, 465, 466, 468 timed_lock, 465, 466 timed_lock_sharable, 465, 466 timed_lock_upgradable, 465, 467 timed_unlock_upgradable_and_lock, 465, 468 try_lock, 465, 466 try_lock_sharable, 465, 466 try_lock_upgradable, 465, 467 try_unlock_sharable_and_lock, 465, 468 try_unlock_sharable_and_lock_upgradable, 465, 468 try_unlock_upgradable_and_lock, 465, 468 unlock, 465, 466 unlock_and_lock_sharable, 465, 467 unlock_and_lock_upgradable, 465, 467 unlock_sharable, 465, 467 unlock_upgradable, 465, 467 unlock_upgradable_and_lock, 465, 467 unlock_upgradable_and_lock_sharable, 465, 467 Class null_mutex lock, 469, 469, 469 lock_sharable, 469, 470, 470 lock_upgradable, 469, 470, 470 null_mutex, 469, 469 timed_lock, 469, 470, 470 timed_lock_sharable, 469, 470, 470 timed_lock_upgradable, 469, 470, 470 timed_unlock_upgradable_and_lock, 469, 471, 471 try_lock, 469, 469, 469 try_lock_sharable, 469, 470, 470 try_lock_upgradable, 469, 470, 470 try_unlock_sharable_and_lock, 469, 471, 471 try_unlock_sharable_and_lock_upgradable, 469, 471, 471 try_unlock_upgradable_and_lock, 469, 471, 471 unlock, 469, 470, 470 unlock_and_lock_sharable, 469, 470, 470 unlock_and_lock_upgradable, 469, 470, 470
208
Boost.Interprocess
unlock_sharable, 469, 470, 470 unlock_upgradable, 469, 470, 470 unlock_upgradable_and_lock, 469, 471, 471 unlock_upgradable_and_lock_sharable, 469, 470, 470 Class permissions permissions, 382 set_default, 382, 382 set_permissions, 382, 382 set_unrestricted, 382, 382 Class remove_le_on_destroy remove_le_on_destroy, 333 Class remove_shared_memory_on_destroy remove_shared_memory_on_destroy, 395 Class shared_memory_object remove, 393, 394, 394 shared_memory_object, 393 swap, 393, 394 truncate, 393, 394 Class template adaptive_pool adaptive_pool, 284, 285 allocate, 284, 286 allocate_individual, 284, 287 allocate_many, 284, 286, 286 allocate_one, 284, 287, 287 const_pointer, 284 const_reference, 284 deallocate, 284, 286, 286, 287 deallocate_free_blocks, 284, 286 deallocate_individual, 284, 287 deallocate_many, 284, 287 deallocate_one, 284, 287, 287, 287, 287 difference_type, 284 other, 284 pointer, 284 rebind, 284 reference, 284 segment_manager, 284 size_type, 284 swap, 284, 287 value_type, 284 void_pointer, 284 Class template allocator allocate, 289, 290 allocate_individual, 289, 291 allocate_many, 289, 291, 291 allocate_one, 289, 291, 291 allocator, 289, 344 construct, 289, 292 const_pointer, 289 const_reference, 289 deallocate, 289, 290, 291, 291 deallocate_individual, 289, 291 deallocate_many, 289, 291 deallocate_one, 289, 291, 291, 291, 291 destroy, 289, 292 difference_type, 289 other, 289 pointer, 289
209
Boost.Interprocess
rebind, 289 reference, 289 segment_manager, 289 size_type, 289 swap, 289, 292 value_type, 289 version, 289 void_pointer, 289 Class template basic_bufferbuf base_t, 423 basic_bufferbuf, 349, 423 buffer, 423, 424, 424 char_type, 423 int_type, 423 off_type, 423 pos_type, 423 traits_type, 423 Class template basic_bufferstream basic_bufferstream, 350, 427 buffer, 427, 427, 427 char_type, 427 int_type, 427 off_type, 427 pos_type, 427 traits_type, 427 Class template basic_ibufferstream basic_ibufferstream, 350, 424 buffer, 424, 425, 425 char_type, 424 int_type, 424 off_type, 424 pos_type, 424 traits_type, 424 Class template basic_managed_external_buffer basic_managed_external_buffer, 348, 356, 356 grow, 356, 357 size_type, 356 swap, 356, 357 Class template basic_managed_heap_memory basic_managed_heap_memory, 349, 357, 357 grow, 357, 358 size_type, 357 swap, 357, 358 Class template basic_managed_mapped_le basic_managed_mapped_le, 349, 359 ush, 359, 360 grow, 359, 360 remove, 360 shrink_to_t, 359, 360 swap, 359, 360 Class template basic_managed_shared_memory basic_managed_shared_memory, 348, 361, 361 grow, 361, 362 remove, 362 shrink_to_t, 361, 363 swap, 361, 362 Class template basic_managed_windows_shared_memory basic_managed_windows_shared_memory, 348, 364, 364
210
Boost.Interprocess
size_type, 364 swap, 364, 365 Class template basic_managed_xsi_shared_memory basic_managed_xsi_shared_memory, 349, 366, 366 remove, 366, 367, 367 size_type, 366 swap, 366, 367 Class template basic_obufferstream basic_obufferstream, 350, 425 buffer, 425, 426, 426 char_type, 425 int_type, 425 off_type, 425 pos_type, 425 traits_type, 425 Class template basic_vectorbuf basic_vectorbuf, 350, 428 char_type, 428 clear, 428, 429, 429 int_type, 428 off_type, 428 pos_type, 428 reserve, 428, 429 swap_vector, 428, 429 traits_type, 428 vector_type, 428 Class template basic_vectorstream basic_vectorstream, 351, 432 char_type, 432 clear, 432, 433, 433 int_type, 432 off_type, 432 pos_type, 432 reserve, 432, 433, 433 swap_vector, 432, 433 traits_type, 432 vector_type, 432 Class template cached_adaptive_pool allocate, 294, 296 allocate_individual, 294, 297 allocate_many, 294, 297, 297 allocate_one, 294, 297, 297 cached_adaptive_pool, 294, 295 construct, 294, 296 const_pointer, 294 const_reference, 294 deallocate, 294, 296, 297, 297 deallocate_free_blocks, 294, 296 deallocate_individual, 294, 297 deallocate_many, 294, 297 deallocate_one, 294, 297, 297, 297, 297 destroy, 294, 296 difference_type, 294 other, 294 pointer, 294 rebind, 294 reference, 294 segment_manager, 294
211
Boost.Interprocess
set_max_cached_nodes, 294, 297 size_type, 294 swap, 294, 298 value_type, 294 void_pointer, 294 Class template cached_node_allocator allocate, 300, 302 allocate_individual, 300, 303 allocate_many, 300, 302, 303 allocate_one, 300, 303, 303 cached_node_allocator, 300, 301 construct, 300, 302 const_pointer, 300 const_reference, 300 deallocate, 300, 302, 302, 303 deallocate_free_blocks, 300, 302 deallocate_individual, 300, 303 deallocate_many, 300, 303 deallocate_one, 300, 303, 303, 303, 303 destroy, 300, 302 difference_type, 300 other, 300 pointer, 300 rebind, 300 reference, 300 segment_manager, 300 set_max_cached_nodes, 300, 303 size_type, 300 swap, 300, 303 value_type, 300 void_pointer, 300 Class template deleter deleter, 396 pointer, 396 Class template enable_shared_from_this enable_shared_from_this, 397 Class template at_map_index reserve, 334, 334 shrink_to_t, 334, 334 Class template intrusive_ptr element_type, 399 get, 399, 400, 400, 400, 400, 400 intrusive_ptr, 352, 399 intrusive_ptr_add_ref, 399, 399, 400, 400 intrusive_ptr_release, 399, 400 pointer, 399 swap, 399, 401 Class template iset_index const_iterator, 335 nd, 335, 336, 336 insert_commit_data, 335 iset_index_aux, 335 iterator, 335 reserve, 335, 335 shrink_to_t, 335, 336 value_type, 335 Class template iunordered_set_index allocator_holder, 337
212
Boost.Interprocess
bucket_ptr, 337 bucket_traits, 337 bucket_type, 337 const_iterator, 337 nd, 337, 338, 338 insert_commit, 337, 338 insert_commit_data, 337 iterator, 337 iunordered_set_index_aux, 337 reserve, 337, 337 shrink_to_t, 337, 337 size_type, 337 value_type, 337 Class template map_index reserve, 338, 339 shrink_to_t, 338, 339 Class template message_queue_t char_ptr, 353 difference_type, 353 get_num_msg, 353, 355 message_queue_t, 352, 353 receive, 353, 354 remove, 353, 354, 355 send, 353, 354 size_type, 353 timed_receive, 353, 355 timed_send, 353, 354 try_receive, 353, 355 try_send, 353, 354 void_pointer, 353 Class template node_allocator allocate, 305, 307 allocate_individual, 305, 308 allocate_many, 305, 307, 308 allocate_one, 305, 308, 308 construct, 305, 307 const_pointer, 305 const_reference, 305 deallocate, 305, 307, 307, 308 deallocate_free_blocks, 305, 307 deallocate_individual, 305, 308 deallocate_many, 305, 308 deallocate_one, 305, 308, 308, 308, 308 destroy, 305, 307 difference_type, 305 node_allocator, 305, 306 other, 305 pointer, 305 rebind, 305 reference, 305 segment_manager, 305 size_type, 305 swap, 305, 308 value_type, 305 void_pointer, 305 Class template null_index begin, 339, 340, 340 const_iterator, 339
213
Boost.Interprocess
end, 339, 340, 340, 340, 340, 340, 340 iterator, 339 null_index, 339, 339, 347 Class template offset_ptr difference_type, 376 element_type, 376 get, 376, 378 iterator_category, 376 offset_ptr, 345, 376, 376, 377, 377, 377, 377, 377, 378 offset_type, 376 other, 376 pointer, 376 pointer_to, 376, 379 rebind, 376 reference, 376 value_type, 376 Class template private_adaptive_pool allocate, 311, 313 allocate_individual, 311, 314 allocate_many, 311, 314, 314 allocate_one, 311, 314, 314 construct, 311, 313 const_pointer, 311 const_reference, 311 deallocate, 311, 313, 314, 314 deallocate_free_blocks, 311, 313 deallocate_individual, 311, 314 deallocate_many, 311, 314 deallocate_one, 311, 314, 314, 314, 314 destroy, 311, 313 difference_type, 311 other, 311 pointer, 311 private_adaptive_pool, 311, 312 rebind, 311 reference, 311 segment_manager, 311 size_type, 311 swap, 311, 314 value_type, 311 void_pointer, 311 Class template private_node_allocator allocate, 317, 319 allocate_individual, 317, 320 allocate_many, 317, 319, 319 allocate_one, 317, 320, 320 construct, 317, 319 const_pointer, 317 const_reference, 317 deallocate, 317, 319, 319, 320 deallocate_free_blocks, 317, 319 deallocate_individual, 317, 320 deallocate_many, 317, 320 deallocate_one, 317, 320, 320, 320, 320 destroy, 317, 319 difference_type, 317 other, 317 pointer, 317
214
Boost.Interprocess
private_node_allocator, 317, 318 rebind, 317 reference, 317 segment_manager, 317 size_type, 317 swap, 317, 320 value_type, 317 void_pointer, 317 Class template rbtree_best_t allocate, 371, 372 allocate_aligned, 371, 373 all_memory_deallocated, 371, 372 check_sanity, 371, 372 deallocate, 371, 372 difference_type, 371 get_min_size, 371, 373 grow, 371, 372 multiallocation_chain, 371 mutex_family, 371 rbtree_best_t, 346, 371, 371 shrink_to_t, 371, 372 size_type, 371 void_pointer, 371 zero_free_memory, 371, 372 Class template scoped_lock lock, 472, 474, 474 lock_exception, 474, 474, 474, 475 mutex_type, 472 release, 472, 475 scoped_lock, 343, 472 swap, 472, 475 timed_lock, 472, 474, 474 timed_unlock_upgradable_and_lock, 474 try_lock, 472, 474, 474 try_unlock_sharable_and_lock, 474 try_unlock_upgradable_and_lock, 473 unlock, 472, 474, 475, 475 unlock_upgradable_and_lock, 473 Class template scoped_ptr deleter_type, 405 element_type, 405 get, 405, 406, 406 pointer, 405 release, 405, 405, 406 reset, 405, 405, 405 scoped_ptr, 351, 405, 405, 405 swap, 405, 406 unspecied_bool_type, 405 Class template segment_manager allocator, 387 atomic_func, 387, 390 char_type, 387 construct, 387, 389, 389 construct_it, 387, 389, 390 const_named_iterator, 387 const_unique_iterator, 387 deleter, 387 destroy, 387, 390, 390
215
Boost.Interprocess
destroy_ptr, 387, 390 difference_type, 387 nd, 387, 388, 389 nd_or_construct, 387, 389, 389 nd_or_construct_it, 387, 389, 390 get_allocator, 387, 391 get_deleter, 387, 391 get_instance_length, 387, 391 get_instance_name, 387, 391 get_instance_type, 387, 391 get_min_size, 387, 391 get_num_named_objects, 387, 390 get_num_unique_objects, 387, 391 memory_algorithm, 387 mutex_family, 387 reserve_named_objects, 387, 390 reserve_unique_objects, 387, 390 segment_manager, 348, 387, 387, 388 segment_manager_base, 387 segment_manager_base_type, 387 shrink_to_t_indexes, 387, 390 size_type, 387 try_atomic_func, 387, 390 type, 387 void_pointer, 387 Class template segment_manager_base allocate, 384, 385, 385 allocate_aligned, 384, 385, 385 all_memory_deallocated, 384, 386 check_sanity, 384, 386 deallocate, 384, 385 get_min_size, 384, 386 grow, 384, 385 memory_algorithm, 384 mutex_family, 384 segment_manager_base, 384 segment_manager_base_type, 384 shrink_to_t, 384, 386 void_pointer, 384 zero_free_memory, 384, 386 Class template sharable_lock lock, 476, 478 lock_exception, 478, 478, 478, 478 lock_sharable, 478 mutex_type, 476 release, 476, 478 sharable_lock, 343, 476, 476, 476, 477, 477 swap, 476, 479 timed_lock, 476, 478 timed_lock_sharable, 478 try_lock, 476, 478 try_lock_sharable, 478 unlock, 476, 478 unlock_and_lock_sharable, 477 unlock_sharable, 477, 478 unlock_upgradable_and_lock_sharable, 477 Class template shared_ptr const_allocator_pointer, 410
216
Boost.Interprocess
const_deleter_pointer, 410 const_reference, 410 element_type, 410 get, 410, 411, 412 pointer, 410 reference, 410 reset, 410, 412, 412, 412 shared_ptr, 352, 410 swap, 410, 413 value_type, 410 Class template simple_seq_t simple_seq_t, 346, 373 size_type, 373 Class template std char_type, 430 clear, 430, 431, 431 int_type, 430 off_type, 430 pos_type, 430 reserve, 430, 431, 431, 432, 432 swap_vector, 430, 431, 431 traits_type, 430 vector_type, 430 Class template unique_ptr deleter_type, 415 element_type, 415 get, 415, 416, 417, 418, 418, 418 get_deleter, 415, 416, 417, 418, 418, 418 pointer, 415 release, 415, 418 reset, 415, 418 swap, 415, 418 unique_ptr, 415, 415, 416, 416 Class template unordered_map_index reserve, 340, 341 shrink_to_t, 340, 341 unordered_map_index_aux, 340 Class template upgradable_lock lock, 479, 481 lock_exception, 481, 481, 481, 481 lock_upgradable, 481 mutex_type, 479 release, 479, 482 swap, 479, 482 timed_lock, 479, 481 timed_lock_upgradable, 481 try_lock, 479, 481 try_lock_upgradable, 481 try_unlock_sharable_and_lock_upgradable, 481 unlock, 479, 481 unlock_upgradable, 481, 481 upgradable_lock, 343, 479, 479, 480, 480, 481 Class template weak_ptr element_type, 420 lock, 420, 421 reset, 420, 421 swap, 420, 422 value_type, 420
217
Boost.Interprocess
weak_ptr, 409, 409, 420 Class windows_shared_memory swap, 483, 484 windows_shared_memory, 483 Class xsi_key xsi_key, 485 Class xsi_shared_memory remove, 486, 487, 487 swap, 486, 487 xsi_shared_memory, 486 clear Class template basic_vectorbuf, 428, 429, 429 Class template basic_vectorstream, 432, 433, 433 Class template std, 430, 431, 431 Common Managed Mapped Files managed_mapped_le, 70 wmanaged_mapped_le, 70 Common Managed Shared Memory Classes xed_managed_shared_memory, 67 managed_shared_memory, 67 wxed_managed_shared_memory, 67 wmanaged_shared_memory, 67 construct Class template allocator, 289, 292 Class template cached_adaptive_pool, 294, 296 Class template cached_node_allocator, 300, 302 Class template node_allocator, 305, 307 Class template private_adaptive_pool, 311, 313 Class template private_node_allocator, 317, 319 Class template segment_manager, 387, 389, 389 Constructing Managed Mapped Files remove, 70 construct_it Class template segment_manager, 387, 389, 390 const_allocator_pointer Class template shared_ptr, 410 const_deleter_pointer Class template shared_ptr, 410 const_iterator Class template iset_index, 335 Class template iunordered_set_index, 337 Class template null_index, 339 const_named_iterator Class template segment_manager, 387 const_pointer Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 const_reference Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305
218
Boost.Interprocess
Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template shared_ptr, 410 const_unique_iterator Class template segment_manager, 387 Containers of containers void_allocator, 117 create_only_t Struct create_only_t, 325 Creating maps in shared memory name, 8 Creating named shared memory objects if, 4 Creating vectors in shared memory if, 6
D
data What's A Message Queue?, 62 deallocate Class template adaptive_pool, 284, 286, 286, 287 Class template allocator, 289, 290, 291, 291 Class template cached_adaptive_pool, 294, 296, 297, 297 Class template cached_node_allocator, 300, 302, 302, 303 Class template node_allocator, 305, 307, 307, 308 Class template private_adaptive_pool, 311, 313, 314, 314 Class template private_node_allocator, 317, 319, 319, 320 Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 385 Performance of raw memory allocations, 146 Writing a new shared memory allocation algorithm, 148, 149 deallocate_free_blocks Class template adaptive_pool, 284, 286 Class template cached_adaptive_pool, 294, 296 Class template cached_node_allocator, 300, 302 Class template node_allocator, 305, 307 Class template private_adaptive_pool, 311, 313 Class template private_node_allocator, 317, 319 deallocate_individual Class template adaptive_pool, 284, 287 Class template allocator, 289, 291 Class template cached_adaptive_pool, 294, 297 Class template cached_node_allocator, 300, 303 Class template node_allocator, 305, 308 Class template private_adaptive_pool, 311, 314 Class template private_node_allocator, 317, 320 deallocate_many Class template adaptive_pool, 284, 287 Class template allocator, 289, 291 Class template cached_adaptive_pool, 294, 297 Class template cached_node_allocator, 300, 303 Class template node_allocator, 305, 308 Class template private_adaptive_pool, 311, 314 Class template private_node_allocator, 317, 320 deallocate_one Class template adaptive_pool, 284, 287, 287, 287, 287 Class template allocator, 289, 291, 291, 291, 291
219
Boost.Interprocess
Class template cached_adaptive_pool, 294, 297, 297, 297, 297 Class template cached_node_allocator, 300, 303, 303, 303, 303 Class template node_allocator, 305, 308, 308, 308, 308 Class template private_adaptive_pool, 311, 314, 314, 314, 314 Class template private_node_allocator, 317, 320, 320, 320, 320 defer_lock_type Struct defer_lock_type, 449 deleter Class template deleter, 396 Class template segment_manager, 387 Struct template deleter, 392 Struct template managed_shared_ptr, 413 deleter_type Class template scoped_ptr, 405 Class template unique_ptr, 415 Shared pointer and weak pointer, 135 Demotions (Upgradable Mutex only) unlock_and_lock_sharable, 49 unlock_and_lock_upgradable, 49 unlock_upgradable_and_lock_sharable, 49 destroy Class template allocator, 289, 292 Class template cached_adaptive_pool, 294, 296 Class template cached_node_allocator, 300, 302 Class template node_allocator, 305, 307 Class template private_adaptive_pool, 311, 313 Class template private_node_allocator, 317, 319 Class template segment_manager, 387, 390, 390 destroy_ptr Class template segment_manager, 387, 390 difference_type Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template message_queue_t, 353 Class template node_allocator, 305 Class template offset_ptr, 376 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template rbtree_best_t, 371 Class template segment_manager, 387 Direct iostream formatting: vectorstream and bufferstream while, 124
E
element_type Class template intrusive_ptr, 399 Class template offset_ptr, 376 Class template scoped_ptr, 405 Class template shared_ptr, 410 Class template unique_ptr, 415 Class template weak_ptr, 420 enable_shared_from_this Class template enable_shared_from_this, 397 end Class template null_index, 339, 340, 340, 340, 340, 340, 340
220
Boost.Interprocess
Example: Serializing a database through the message queue if, 93 while, 93 Exclusive Locking (Sharable & Upgradable Mutexes) lock, 47 timed_lock, 47 try_lock, 47 unlock, 47 Executing an object function atomically atomic_func, 76 Expand in place memory allocation assert, 83
F
File Locking Operations lock, 58 lock_sharable, 58 timed_lock, 58 timed_lock_sharable, 58 try_lock, 58 try_lock_sharable, 58 unlock, 58 unlock_sharable, 58 le_lock Class le_lock, 434 le_mapping Class le_mapping, 331, 331 nd Class template iset_index, 335, 336, 336 Class template iunordered_set_index, 337, 338, 338 Class template segment_manager, 387, 388, 389 Performance of named allocations, 146 nd_or_construct Class template segment_manager, 387, 389, 389 nd_or_construct_it Class template segment_manager, 387, 389, 390 xed_managed_shared_memory Common Managed Shared Memory Classes, 67 Header < boost/interprocess/interprocess_fwd.hpp >, 341 at_map_index_aux Building custom indexes, 150 Struct template at_map_index_aux, 334 ush Be Careful With Iostream Writing, 62 Class mapped_region, 368, 369 Class template basic_managed_mapped_le, 359, 360 for Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 Formatting directly in your character buffer: bufferstream assert, 127 basic_bufferstream, 127 buffer, 127, 127 bufferstream, 127 char_type, 127 for, 127 int_type, 127
221
Boost.Interprocess
off_type, 127 pos_type, 127 traits_type, 127 wbufferstream, 127 Formatting directly in your character vector: vectorstream assert, 124 basic_vectorstream, 124 char_type, 124 for, 124 int_type, 124 off_type, 124 pos_type, 124 reserve, 124 swap_vector, 124, 124 traits_type, 124 vector_type, 124 Function template make_managed_shared_ptr make_managed_shared_ptr, 413, 414 Function template make_managed_unique_ptr make_managed_unique_ptr, 419 Function template make_managed_weak_ptr make_managed_weak_ptr, 422 Function template swap swap, 403, 406 Function template to_raw_pointer to_raw_pointer, 404, 407
G
get Class template intrusive_ptr, 399, 400, 400, 400, 400, 400 Class template offset_ptr, 376, 378 Class template scoped_ptr, 405, 406, 406 Class template shared_ptr, 410, 411, 412 Class template unique_ptr, 415, 416, 417, 418, 418, 418 get_allocator Class template segment_manager, 387, 391 get_deleter Class template segment_manager, 387, 391 Class template unique_ptr, 415, 416, 417, 418, 418, 418 get_instance_length Class template segment_manager, 387, 391 get_instance_name Class template segment_manager, 387, 391 get_instance_type Class template segment_manager, 387, 391 get_min_size Class template rbtree_best_t, 371, 373 Class template segment_manager, 387, 391 Class template segment_manager_base, 384, 386 Writing a new shared memory allocation algorithm, 148, 149 get_num_msg Class template message_queue_t, 353, 355 get_num_named_objects Class template segment_manager, 387, 390 get_num_unique_objects Class template segment_manager, 387, 391 get_page_size
222
Boost.Interprocess
Class mapped_region, 368, 370 Global try_to_lock try_lock, 450 grow Class template basic_managed_external_buffer, 356, 357 Class template basic_managed_heap_memory, 357, 358 Class template basic_managed_mapped_le, 359, 360 Class template basic_managed_shared_memory, 361, 362 Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 385 Managed Heap Memory: Boost.Interprocess machinery in heap memory, 91 Writing a new shared memory allocation algorithm, 148, 149 Growing managed segments assert, 77
H
Header < boost/interprocess/allocators/allocator.hpp > buffer, 288 Header < boost/interprocess/errors.hpp > native_error_t, 328 Header < boost/interprocess/interprocess_fwd.hpp > xed_managed_shared_memory, 341 managed_external_buffer, 341 managed_heap_memory, 341 managed_mapped_le, 341 managed_shared_memory, 341 managed_windows_shared_memory, 341 managed_xsi_shared_memory, 341 message_queue, 341 wxed_managed_shared_memory, 341 wmanaged_external_buffer, 341 wmanaged_heap_memory, 341 wmanaged_mapped_le, 341 wmanaged_shared_memory, 341 wmanaged_windows_shared_memory, 341 wmanaged_xsi_shared_memory, 341 Header < boost/interprocess/offset_ptr.hpp > BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR, 374 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF, 374 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER, 374 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR, 374 Header < boost/interprocess/smart_ptr/intrusive_ptr.hpp > swap, 397 to_raw_pointer, 397 Header < boost/interprocess/smart_ptr/scoped_ptr.hpp > swap, 404 to_raw_pointer, 404 Header < boost/interprocess/smart_ptr/shared_ptr.hpp > make_managed_shared_ptr, 407 swap, 407 to_raw_pointer, 407 Header < boost/interprocess/smart_ptr/unique_ptr.hpp > make_managed_unique_ptr, 414 swap, 414 Header < boost/interprocess/smart_ptr/weak_ptr.hpp > make_managed_weak_ptr, 419 swap, 419
223
Boost.Interprocess
Header < boost/interprocess/streams/bufferstream.hpp > bufferbuf, 422 bufferstream, 422 ibufferstream, 422 obufferstream, 422 wbufferbuf, 422 wbufferstream, 422 wibufferstream, 422 wobufferstream, 422
I
ibufferstream Header < boost/interprocess/streams/bufferstream.hpp >, 422 if Creating named shared memory objects, 4 Creating vectors in shared memory, 6 Example: Serializing a database through the message queue, 93 Intrusive pointer, 131 Managed External Buffer: Constructing all Boost.Interprocess objects in a user provided buffer, 88 Multiple allocation functions, 81 Opening managed shared memory and mapped les with Copy On Write or Read Only modes, 86 Scoped lock, 34 Scoped pointer, 133 Sharable Lock And Upgradable Lock, 51 Using shared memory as a pool of unnamed memory blocks, 3 index_aux Building custom indexes, 150 index_t Building custom indexes, 150 Struct template at_map_index_aux, 334 insert_commit Class template iunordered_set_index, 337, 338 insert_commit_data Class template iset_index, 335 Class template iunordered_set_index, 337 interprocess_condition Class interprocess_condition, 436, 436 interprocess_condition_any Class interprocess_condition_any, 438, 438 interprocess_exception Class bad_alloc, 330 Class interprocess_exception, 329, 329 Class lock_exception, 330 interprocess_mutex Class interprocess_mutex, 439, 439 interprocess_recursive_mutex Class interprocess_recursive_mutex, 441, 441 interprocess_semaphore Class interprocess_semaphore, 442, 442 interprocess_sharable_mutex Class interprocess_sharable_mutex, 444, 444 interprocess_upgradable_mutex Class interprocess_upgradable_mutex, 446, 446 Introduction buffer, 66, 66 Intrusive pointer if, 131
224
Boost.Interprocess
intrusive_ptr_add_ref, 131, 131 intrusive_ptr_release, 131, 131 segment_manager, 131, 131 intrusive_ptr Class template intrusive_ptr, 352, 399 intrusive_ptr_add_ref Class template intrusive_ptr, 399, 399, 400, 400 Intrusive pointer, 131, 131 intrusive_ptr_release Class template intrusive_ptr, 399, 400 Intrusive pointer, 131, 131 int_type Class template basic_bufferbuf, 423 Class template basic_bufferstream, 427 Class template basic_ibufferstream, 424 Class template basic_obufferstream, 425 Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template std, 430 Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 iset_index_aux Class template iset_index, 335 iterator Class template iset_index, 335 Class template iunordered_set_index, 337 Class template null_index, 339 Multiple allocation functions, 81 iterator_category Class template offset_ptr, 376 iunordered_set_index_aux Class template iunordered_set_index, 337
K
key_less Building custom indexes, 150 Struct template at_map_index_aux, 334 key_type Building custom indexes, 150, 150 Struct template at_map_index_aux, 334
L
lock Anonymous condition example, 39, 39 Anonymous mutex example, 35, 35 Class le_lock, 434, 435 Class interprocess_mutex, 439, 440 Class interprocess_recursive_mutex, 441, 441 Class interprocess_sharable_mutex, 444, 444 Class interprocess_upgradable_mutex, 446, 447 Class named_mutex, 456, 457 Class named_recursive_mutex, 458, 459 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 469, 469 Class template scoped_lock, 472, 474, 474 Class template sharable_lock, 476, 478
225
Boost.Interprocess
Class template upgradable_lock, 479, 481 Class template weak_ptr, 420, 421 Exclusive Locking (Sharable & Upgradable Mutexes), 47 File Locking Operations, 58 Mutex Operations, 32 Named mutex example, 38 Scoped lock, 34 Sharable Lock And Upgradable Lock, 51 What's a Sharable and an Upgradable Mutex?, 46 Lock Transfers Through Move Semantics unlock_and_lock_sharable, 53 lock_exception Class lock_exception, 330, 330 Class template scoped_lock, 474, 474, 474, 475 Class template sharable_lock, 478, 478, 478, 478 Class template upgradable_lock, 481, 481, 481, 481 lock_sharable Class le_lock, 434, 435 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 470, 470 Class template sharable_lock, 478 File Locking Operations, 58 Sharable Lock And Upgradable Lock, 51, 51 Sharable Locking (Sharable & Upgradable Mutexes), 48 lock_upgradable Class interprocess_upgradable_mutex, 446, 447 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template upgradable_lock, 481 Sharable Lock And Upgradable Lock, 51 Upgradable Locking (Upgradable Mutex only), 48
M
Macro BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR, 381, 381, 381 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF, 381, 381, 381 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER, 381, 381, 381 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR, 381, 381, 381 make_managed_shared_ptr Function template make_managed_shared_ptr, 413, 414 Header < boost/interprocess/smart_ptr/shared_ptr.hpp >, 407 make_managed_unique_ptr Function template make_managed_unique_ptr, 419 Header < boost/interprocess/smart_ptr/unique_ptr.hpp >, 414 make_managed_weak_ptr Function template make_managed_weak_ptr, 422 Header < boost/interprocess/smart_ptr/weak_ptr.hpp >, 419 Managed External Buffer: Constructing all Boost.Interprocess objects in a user provided buffer if, 88 managed_external_buffer, 88 wmanaged_external_buffer, 88
226
Boost.Interprocess
Managed Heap Memory: Boost.Interprocess machinery in heap memory grow, 91 managed_heap_memory, 91 wmanaged_heap_memory, 91 managed_external_buffer Header < boost/interprocess/interprocess_fwd.hpp >, 341 Managed External Buffer: Constructing all Boost.Interprocess objects in a user provided buffer, 88 managed_heap_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 Managed Heap Memory: Boost.Interprocess machinery in heap memory, 91 managed_mapped_le Common Managed Mapped Files, 70 Header < boost/interprocess/interprocess_fwd.hpp >, 341 managed_shared_memory Common Managed Shared Memory Classes, 67 Header < boost/interprocess/interprocess_fwd.hpp >, 341 managed_shared_ptr Struct template managed_shared_ptr, 413 managed_unique_ptr Struct template managed_unique_ptr, 419 managed_weak_ptr Struct template managed_weak_ptr, 422 managed_windows_shared_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 managed_xsi_shared_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 mapped_region Class mapped_region, 368, 368, 368 mapped_type Building custom indexes, 150, 150 Struct template at_map_index_aux, 334 Mapping Address Independent Pointer: offset_ptr assert, 29 memory_algorithm Class template segment_manager, 387 Class template segment_manager_base, 384 message_queue Header < boost/interprocess/interprocess_fwd.hpp >, 341 message_queue_t Class template message_queue_t, 352, 353 Move semantics in Interprocess containers assert, 115 multiallocation_chain Class template rbtree_best_t, 371 Multiple allocation functions, 81 Multiple allocation functions allocate, 81, 81 allocate_many, 81, 81, 81 if, 81 iterator, 81 multiallocation_chain, 81 while, 81 Mutex Operations lock, 32 timed_lock, 32 try_lock, 32 unlock, 32 mutex_family
227
Boost.Interprocess
Class template rbtree_best_t, 371 Class template segment_manager, 387 Class template segment_manager_base, 384 Struct mutex_family, 451 The memory algorithm, 142 Writing a new shared memory allocation algorithm, 148, 148, 148, 148, 149 mutex_type Class template scoped_lock, 472 Class template sharable_lock, 476 Class template upgradable_lock, 479 Struct mutex_family, 451 Struct null_mutex_family, 451 Writing a new shared memory allocation algorithm, 148
N
name Boost unordered containers, 118 Building custom indexes, 150 Creating maps in shared memory, 8 Named mutex example lock, 38 named_condition Class named_condition, 452, 452, 453 named_condition_any Class named_condition_any, 454, 454, 455 named_mutex Class named_mutex, 456, 456, 457 named_recursive_mutex Class named_recursive_mutex, 458, 458, 458 named_semaphore Class named_semaphore, 460, 460, 460 named_sharable_mutex Class named_sharable_mutex, 462, 462, 462 named_upgradable_mutex Class named_upgradable_mutex, 465, 465, 465 native_error_t Header < boost/interprocess/errors.hpp >, 328 node_allocator Class template node_allocator, 305, 306 node_allocator: A process-shared segregated storage assert, 99 notify_all Class interprocess_condition, 436, 437 Class interprocess_condition_any, 438, 438 Class named_condition, 452, 453 Class named_condition_any, 454, 455 notify_one Class interprocess_condition, 436, 437 Class interprocess_condition_any, 438, 438 Class named_condition, 452, 453 Class named_condition_any, 454, 455 null_index Class template null_index, 339, 339, 347 null_mutex Class null_mutex, 469, 469 null_mutex_family Struct null_mutex_family, 451
228
Boost.Interprocess
O
obufferstream Header < boost/interprocess/streams/bufferstream.hpp >, 422 offset_ptr Class template offset_ptr, 345, 376, 376, 377, 377, 377, 377, 377, 378 offset_type Class template offset_ptr, 376 off_type Class template basic_bufferbuf, 423 Class template basic_bufferstream, 427 Class template basic_ibufferstream, 424 Class template basic_obufferstream, 425 Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template std, 430 Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 Opening managed shared memory and mapped les with Copy On Write or Read Only modes if, 86 open_copy_on_write_t Struct open_copy_on_write_t, 326 open_only_t Struct open_only_t, 325 open_or_create_t Struct open_or_create_t, 326 open_read_only_t Struct open_read_only_t, 325 open_read_private_t Struct open_read_private_t, 326 other Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305 Class template offset_ptr, 376 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Struct template rebind, 287, 292, 298, 304, 309, 315, 320, 380
P
Performance of named allocations nd, 146 Performance of raw memory allocations allocate, 146, 146 deallocate, 146 reserve, 146 permissions Class permissions, 382 pointer Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template deleter, 396 Class template intrusive_ptr, 399 Class template node_allocator, 305
229
Boost.Interprocess
Class template offset_ptr, 376 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template scoped_ptr, 405 Class template shared_ptr, 410 Class template unique_ptr, 415 Scoped pointer, 133 pointer_to Class template offset_ptr, 376, 379 post Class interprocess_semaphore, 442, 442 Class named_semaphore, 460, 461 pos_type Class template basic_bufferbuf, 423 Class template basic_bufferstream, 427 Class template basic_ibufferstream, 424 Class template basic_obufferstream, 425 Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template std, 430 Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 pred Class interprocess_condition, 437 Class interprocess_condition_any, 439 Class named_condition, 453 Class named_condition_any, 456 private_adaptive_pool Class template private_adaptive_pool, 311, 312 private_adaptive_pool: a private adaptive pool assert, 107 private_node_allocator Class template private_node_allocator, 317, 318 private_node_allocator: a private segregated storage assert, 100 Promotions (Upgradable Mutex only) timed_unlock_upgradable_and_lock, 50 try_unlock_sharable_and_lock, 50 try_unlock_sharable_and_lock_upgradable, 50 try_unlock_upgradable_and_lock, 50 unlock_upgradable_and_lock, 50
R
rbtree_best_t Class template rbtree_best_t, 346, 371, 371 rebind Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305 Class template offset_ptr, 376 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Struct template rebind, 287, 292, 298, 304, 309, 315, 320, 380 receive Class template message_queue_t, 353, 354
230
Boost.Interprocess
recursive_mutex_type Struct mutex_family, 451 Struct null_mutex_family, 451 Writing a new shared memory allocation algorithm, 148 reference Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305 Class template offset_ptr, 376 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template shared_ptr, 410 release Class template scoped_lock, 472, 475 Class template scoped_ptr, 405, 405, 406 Class template sharable_lock, 476, 478 Class template unique_ptr, 415, 418 Class template upgradable_lock, 479, 482 Scoped pointer, 133, 133 remove Class le_mapping, 331, 332 Class named_condition, 452, 453, 454 Class named_condition_any, 454, 455, 456 Class named_mutex, 456, 457, 457 Class named_recursive_mutex, 458, 459, 459 Class named_semaphore, 460, 460, 461 Class named_sharable_mutex, 462, 462, 464 Class named_upgradable_mutex, 465, 466, 468 Class shared_memory_object, 393, 394, 394 Class template basic_managed_mapped_le, 360 Class template basic_managed_shared_memory, 362 Class template basic_managed_xsi_shared_memory, 366, 367, 367 Class template message_queue_t, 353, 354, 355 Class xsi_shared_memory, 486, 487, 487 Constructing Managed Mapped Files, 70 Removing shared memory, 17 remove_le_on_destroy Class remove_le_on_destroy, 333 remove_shared_memory_on_destroy Class remove_shared_memory_on_destroy, 395 Removing shared memory remove, 17 reserve Building custom indexes, 150, 150 Class template basic_vectorbuf, 428, 429 Class template basic_vectorstream, 432, 433, 433 Class template at_map_index, 334, 334 Class template iset_index, 335, 335 Class template iunordered_set_index, 337, 337 Class template map_index, 338, 339 Class template std, 430, 431, 431, 432, 432 Class template unordered_map_index, 340, 341 Formatting directly in your character vector: vectorstream, 124 Performance of raw memory allocations, 146 reserve_named_objects Class template segment_manager, 387, 390
231
Boost.Interprocess
reserve_unique_objects Class template segment_manager, 387, 390 reset Class template scoped_ptr, 405, 405, 405 Class template shared_ptr, 410, 412, 412, 412 Class template unique_ptr, 415, 418 Class template weak_ptr, 420, 421
S
Scoped lock if, 34 lock, 34 unlock, 34 Scoped Lock and Sharable Lock With File Locking unlock_and_lock_sharable, 60 Scoped pointer if, 133 pointer, 133 release, 133, 133 segment_manager, 133, 133 scoped_lock Class template scoped_lock, 343, 472 scoped_ptr Class template scoped_ptr, 351, 405, 405, 405 segment_manager Building custom indexes, 150 Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template segment_manager, 348, 387, 387, 388 Intrusive pointer, 131, 131 Scoped pointer, 133, 133 segment_manager_base Building custom indexes, 150, 150 Class template segment_manager, 387 Class template segment_manager_base, 384 Struct template at_map_index_aux, 334 segment_manager_base_type Class template segment_manager, 387 Class template segment_manager_base, 384 send Class template message_queue_t, 353, 354 set_default Class permissions, 382, 382 set_max_cached_nodes cached_adaptive_pool: Avoiding synchronization overhead, 109 cached_node_allocator: caching nodes to avoid overhead, 103 Class template cached_adaptive_pool, 294, 297 Class template cached_node_allocator, 300, 303 set_permissions Class permissions, 382, 382 set_unrestricted Class permissions, 382, 382
232
Boost.Interprocess
Sharable Lock And Upgradable Lock if, 51 lock, 51 lock_sharable, 51, 51 lock_upgradable, 51 timed_lock_sharable, 51 timed_lock_upgradable, 51 try_lock_sharable, 51 try_lock_upgradable, 51 unlock_sharable, 51, 51 unlock_upgradable, 51 Sharable Locking (Sharable & Upgradable Mutexes) lock_sharable, 48 timed_lock_sharable, 48 try_lock_sharable, 48 unlock_sharable, 48 sharable_lock Class template sharable_lock, 343, 476, 476, 476, 477, 477 Shared pointer and weak pointer assert, 135 deleter_type, 135 shared_memory_object Class shared_memory_object, 393 shared_ptr Class template shared_ptr, 352, 410 shrink_by Class mapped_region, 368, 369 shrink_to_t Building custom indexes, 150 Class template basic_managed_mapped_le, 359, 360 Class template basic_managed_shared_memory, 361, 363 Class template at_map_index, 334, 334 Class template iset_index, 335, 336 Class template iunordered_set_index, 337, 337 Class template map_index, 338, 339 Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 386 Class template unordered_map_index, 340, 341 shrink_to_t_indexes Class template segment_manager, 387, 390 Simple Lock Transfer unlock, 53 unlock_sharable, 53 simple_seq_t Class template simple_seq_t, 346, 373 size_type Class template adaptive_pool, 284 Class template allocator, 289 Class template basic_managed_external_buffer, 356 Class template basic_managed_heap_memory, 357 Class template basic_managed_windows_shared_memory, 364 Class template basic_managed_xsi_shared_memory, 366 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template iunordered_set_index, 337 Class template message_queue_t, 353 Class template node_allocator, 305 Class template private_adaptive_pool, 311
233
Boost.Interprocess
Class template private_node_allocator, 317 Class template rbtree_best_t, 371 Class template segment_manager, 387 Class template simple_seq_t, 373 Struct accept_ownership_type accept_ownership_type, 450 Struct create_only_t create_only_t, 325 Struct defer_lock_type defer_lock_type, 449 Struct mutex_family mutex_family, 451 mutex_type, 451 recursive_mutex_type, 451 Struct null_mutex_family mutex_type, 451 null_mutex_family, 451 recursive_mutex_type, 451 Struct open_copy_on_write_t open_copy_on_write_t, 326 Struct open_only_t open_only_t, 325 Struct open_or_create_t open_or_create_t, 326 Struct open_read_only_t open_read_only_t, 325 Struct open_read_private_t open_read_private_t, 326 Struct template allocator allocator, 392 type, 392 Struct template deleter deleter, 392 type, 392 Struct template at_map_index_aux allocator_type, 334 at_map_index_aux, 334 index_t, 334 key_less, 334 key_type, 334 mapped_type, 334 segment_manager_base, 334 value_type, 334 Struct template managed_shared_ptr deleter, 413 managed_shared_ptr, 413 type, 413 void_allocator, 413 Struct template managed_unique_ptr managed_unique_ptr, 419 type, 419 Struct template managed_weak_ptr managed_weak_ptr, 422 type, 422 Struct template rebind other, 287, 292, 298, 304, 309, 315, 320, 380 rebind, 287, 292, 298, 304, 309, 315, 320, 380 Struct try_to_lock_type
234
Boost.Interprocess
try_to_lock_type, 450 swap Class le_lock, 434, 435 Class le_mapping, 331, 332 Class mapped_region, 368, 369 Class shared_memory_object, 393, 394 Class template adaptive_pool, 284, 287 Class template allocator, 289, 292 Class template basic_managed_external_buffer, 356, 357 Class template basic_managed_heap_memory, 357, 358 Class template basic_managed_mapped_le, 359, 360 Class template basic_managed_shared_memory, 361, 362 Class template basic_managed_windows_shared_memory, 364, 365 Class template basic_managed_xsi_shared_memory, 366, 367 Class template cached_adaptive_pool, 294, 298 Class template cached_node_allocator, 300, 303 Class template intrusive_ptr, 399, 401 Class template node_allocator, 305, 308 Class template private_adaptive_pool, 311, 314 Class template private_node_allocator, 317, 320 Class template scoped_lock, 472, 475 Class template scoped_ptr, 405, 406 Class template sharable_lock, 476, 479 Class template shared_ptr, 410, 413 Class template unique_ptr, 415, 418 Class template upgradable_lock, 479, 482 Class template weak_ptr, 420, 422 Class windows_shared_memory, 483, 484 Class xsi_shared_memory, 486, 487 Function template swap, 403, 406 Header < boost/interprocess/smart_ptr/intrusive_ptr.hpp >, 397 Header < boost/interprocess/smart_ptr/scoped_ptr.hpp >, 404 Header < boost/interprocess/smart_ptr/shared_ptr.hpp >, 407 Header < boost/interprocess/smart_ptr/unique_ptr.hpp >, 414 Header < boost/interprocess/smart_ptr/weak_ptr.hpp >, 419 swap_vector Class template basic_vectorbuf, 428, 429 Class template basic_vectorstream, 432, 433 Class template std, 430, 431, 431 Formatting directly in your character vector: vectorstream, 124, 124 Synchronization guarantees allocate, 74
T
The memory algorithm mutex_family, 142 void_pointer, 142 The segment manager allocate, 143 timed_lock Class le_lock, 434, 435 Class interprocess_mutex, 439, 440 Class interprocess_recursive_mutex, 441, 441 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_mutex, 456, 457 Class named_recursive_mutex, 458, 459
235
Boost.Interprocess
Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 470, 470 Class template scoped_lock, 472, 474, 474 Class template sharable_lock, 476, 478 Class template upgradable_lock, 479, 481 Exclusive Locking (Sharable & Upgradable Mutexes), 47 File Locking Operations, 58 Mutex Operations, 32 timed_lock_sharable Class le_lock, 434, 435 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 470, 470 Class template sharable_lock, 478 File Locking Operations, 58 Sharable Lock And Upgradable Lock, 51 Sharable Locking (Sharable & Upgradable Mutexes), 48 timed_lock_upgradable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template upgradable_lock, 481 Sharable Lock And Upgradable Lock, 51 Upgradable Locking (Upgradable Mutex only), 48 timed_receive Class template message_queue_t, 353, 355 timed_send Class template message_queue_t, 353, 354 timed_unlock_upgradable_and_lock Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 468 Class null_mutex, 469, 471, 471 Class template scoped_lock, 474 Promotions (Upgradable Mutex only), 50 Transfers To Scoped Lock, 55 timed_wait Class interprocess_condition, 436, 437, 437 Class interprocess_condition_any, 438, 439, 439 Class interprocess_semaphore, 442, 443 Class named_condition, 452, 453, 453 Class named_condition_any, 454, 455, 456 Class named_semaphore, 460, 461 to_raw_pointer Function template to_raw_pointer, 404, 407 Header < boost/interprocess/smart_ptr/intrusive_ptr.hpp >, 397 Header < boost/interprocess/smart_ptr/scoped_ptr.hpp >, 404 Header < boost/interprocess/smart_ptr/shared_ptr.hpp >, 407 traits_type Class template basic_bufferbuf, 423 Class template basic_bufferstream, 427 Class template basic_ibufferstream, 424 Class template basic_obufferstream, 425 Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template std, 430
236
Boost.Interprocess
Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 Transferring Unlocked Locks assert, 56 unlock_and_lock_sharable, 56 Transfers To Scoped Lock timed_unlock_upgradable_and_lock, 55 try_unlock_sharable_and_lock, 55 try_unlock_upgradable_and_lock, 55 unlock_upgradable_and_lock, 55 Transfers To Sharable Lock unlock_and_lock_sharable, 56 unlock_upgradable_and_lock_sharable, 56 Transfers To Upgradable Lock try_unlock_sharable_and_lock_upgradable, 55 unlock_and_lock_upgradable, 55 truncate Class shared_memory_object, 393, 394 try_atomic_func Class template segment_manager, 387, 390 try_lock Class le_lock, 434, 435 Class interprocess_mutex, 439, 440 Class interprocess_recursive_mutex, 441, 441 Class interprocess_sharable_mutex, 444, 444 Class interprocess_upgradable_mutex, 446, 447 Class named_mutex, 456, 457 Class named_recursive_mutex, 458, 459 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 469, 469 Class template scoped_lock, 472, 474, 474 Class template sharable_lock, 476, 478 Class template upgradable_lock, 479, 481 Exclusive Locking (Sharable & Upgradable Mutexes), 47 File Locking Operations, 58 Global try_to_lock, 450 Mutex Operations, 32 try_lock_sharable Class le_lock, 434, 435 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 470, 470 Class template sharable_lock, 478 File Locking Operations, 58 Sharable Lock And Upgradable Lock, 51 Sharable Locking (Sharable & Upgradable Mutexes), 48 try_lock_upgradable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template upgradable_lock, 481 Sharable Lock And Upgradable Lock, 51 Upgradable Locking (Upgradable Mutex only), 48 try_receive Class template message_queue_t, 353, 355
237
Boost.Interprocess
try_send Class template message_queue_t, 353, 354 try_to_lock_type Struct try_to_lock_type, 450 try_unlock_sharable_and_lock Class interprocess_upgradable_mutex, 446, 449 Class named_upgradable_mutex, 465, 468 Class null_mutex, 469, 471, 471 Class template scoped_lock, 474 Promotions (Upgradable Mutex only), 50 Transfers To Scoped Lock, 55 try_unlock_sharable_and_lock_upgradable Class interprocess_upgradable_mutex, 446, 449 Class named_upgradable_mutex, 465, 468 Class null_mutex, 469, 471, 471 Class template upgradable_lock, 481 Promotions (Upgradable Mutex only), 50 Transfers To Upgradable Lock, 55 try_unlock_upgradable_and_lock Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 468 Class null_mutex, 469, 471, 471 Class template scoped_lock, 473 Promotions (Upgradable Mutex only), 50 Transfers To Scoped Lock, 55 try_wait Class interprocess_semaphore, 442, 443 Class named_semaphore, 460, 461 type Class template segment_manager, 387 Struct template allocator, 392 Struct template deleter, 392 Struct template managed_shared_ptr, 413 Struct template managed_unique_ptr, 419 Struct template managed_weak_ptr, 422
U
Unique pointer assert, 139 unique_ptr Class template unique_ptr, 415, 415, 416, 416 unlock Class le_lock, 434, 435 Class interprocess_mutex, 439, 440 Class interprocess_recursive_mutex, 441, 441 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_mutex, 456, 457 Class named_recursive_mutex, 458, 459 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 470, 470 Class template scoped_lock, 472, 474, 475, 475 Class template sharable_lock, 476, 478 Class template upgradable_lock, 479, 481 Exclusive Locking (Sharable & Upgradable Mutexes), 47 File Locking Operations, 58
238
Boost.Interprocess
Mutex Operations, 32 Scoped lock, 34 Simple Lock Transfer, 53 unlock_and_lock_sharable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template sharable_lock, 477 Demotions (Upgradable Mutex only), 49 Lock Transfers Through Move Semantics, 53 Scoped Lock and Sharable Lock With File Locking, 60 Transferring Unlocked Locks, 56 Transfers To Sharable Lock, 56 unlock_and_lock_upgradable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Demotions (Upgradable Mutex only), 49 Transfers To Upgradable Lock, 55 unlock_sharable Class le_lock, 434, 435 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template sharable_lock, 477, 478 File Locking Operations, 58 Sharable Lock And Upgradable Lock, 51, 51 Sharable Locking (Sharable & Upgradable Mutexes), 48 Simple Lock Transfer, 53 unlock_upgradable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template upgradable_lock, 481, 481 Sharable Lock And Upgradable Lock, 51 Upgradable Locking (Upgradable Mutex only), 48 unlock_upgradable_and_lock Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 471, 471 Class template scoped_lock, 473 Promotions (Upgradable Mutex only), 50 Transfers To Scoped Lock, 55 unlock_upgradable_and_lock_sharable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template sharable_lock, 477 Demotions (Upgradable Mutex only), 49 Transfers To Sharable Lock, 56 unordered_map_index_aux Class template unordered_map_index, 340 unspecied_bool_type Class template scoped_ptr, 405 Upgradable Locking (Upgradable Mutex only) lock_upgradable, 48
239
Boost.Interprocess
timed_lock_upgradable, 48 try_lock_upgradable, 48 unlock_upgradable, 48 upgradable_lock Class template upgradable_lock, 343, 479, 479, 480, 480, 481 Using shared memory as a pool of unnamed memory blocks if, 3
V
value_type Building custom indexes, 150 Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template iset_index, 335 Class template iunordered_set_index, 337 Class template node_allocator, 305 Class template offset_ptr, 376 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template shared_ptr, 410 Class template weak_ptr, 420 Struct template at_map_index_aux, 334 vector_type Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template std, 430 Formatting directly in your character vector: vectorstream, 124 version Class template allocator, 289 void_allocator Containers of containers, 117 Struct template managed_shared_ptr, 413 void_pointer Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template message_queue_t, 353 Class template node_allocator, 305 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template rbtree_best_t, 371 Class template segment_manager, 387 Class template segment_manager_base, 384 The memory algorithm, 142 Writing a new shared memory allocation algorithm, 148, 148, 148, 148
W
wait Class bad_alloc, 330 Class interprocess_condition, 436, 437, 437 Class interprocess_condition_any, 438, 438, 439 Class interprocess_semaphore, 442, 443 Class named_condition, 452, 453, 453 Class named_condition_any, 454, 455, 455
240
Boost.Interprocess
Class named_semaphore, 460, 461 wbufferbuf Header < boost/interprocess/streams/bufferstream.hpp >, 422 wbufferstream Formatting directly in your character buffer: bufferstream, 127 Header < boost/interprocess/streams/bufferstream.hpp >, 422 weak_ptr Class template weak_ptr, 409, 409, 420 wxed_managed_shared_memory Common Managed Shared Memory Classes, 67 Header < boost/interprocess/interprocess_fwd.hpp >, 341 What's A Message Queue? data, 62 What's a Sharable and an Upgradable Mutex? lock, 46 while Anonymous mutex example, 35, 35 Direct iostream formatting: vectorstream and bufferstream, 124 Example: Serializing a database through the message queue, 93 Multiple allocation functions, 81 wibufferstream Header < boost/interprocess/streams/bufferstream.hpp >, 422 windows_shared_memory Class windows_shared_memory, 483 wmanaged_external_buffer Header < boost/interprocess/interprocess_fwd.hpp >, 341 Managed External Buffer: Constructing all Boost.Interprocess objects in a user provided buffer, 88 wmanaged_heap_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 Managed Heap Memory: Boost.Interprocess machinery in heap memory, 91 wmanaged_mapped_le Common Managed Mapped Files, 70 Header < boost/interprocess/interprocess_fwd.hpp >, 341 wmanaged_shared_memory Common Managed Shared Memory Classes, 67 Header < boost/interprocess/interprocess_fwd.hpp >, 341 wmanaged_windows_shared_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 wmanaged_xsi_shared_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 wobufferstream Header < boost/interprocess/streams/bufferstream.hpp >, 422 Writing a new shared memory allocation algorithm allocate, 148, 149, 149, 149 deallocate, 148, 149 get_min_size, 148, 149 grow, 148, 149 mutex_family, 148, 148, 148, 148, 149 mutex_type, 148 recursive_mutex_type, 148 void_pointer, 148, 148, 148, 148
X
xsi_key Class xsi_key, 485 xsi_shared_memory Class xsi_shared_memory, 486
241
Boost.Interprocess
Z
zero_free_memory Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 386
Function Index
A
accept_ownership_type Struct accept_ownership_type, 450 adaptive_pool Class template adaptive_pool, 284, 285 adaptive_pool: a process-shared adaptive pool assert, 105 advise Class mapped_region, 368, 370 allocate Class template adaptive_pool, 284, 286 Class template allocator, 289, 290 Class template cached_adaptive_pool, 294, 296 Class template cached_node_allocator, 300, 302 Class template node_allocator, 305, 307 Class template private_adaptive_pool, 311, 313 Class template private_node_allocator, 317, 319 Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 385, 385 Multiple allocation functions, 81, 81 Performance of raw memory allocations, 146, 146 Synchronization guarantees, 74 The segment manager, 143 Writing a new shared memory allocation algorithm, 148, 149, 149, 149 allocate_aligned Class template rbtree_best_t, 371, 373 Class template segment_manager_base, 384, 385, 385 allocate_individual Class template adaptive_pool, 284, 287 Class template allocator, 289, 291 Class template cached_adaptive_pool, 294, 297 Class template cached_node_allocator, 300, 303 Class template node_allocator, 305, 308 Class template private_adaptive_pool, 311, 314 Class template private_node_allocator, 317, 320 allocate_many Class template adaptive_pool, 284, 286, 286 Class template allocator, 289, 291, 291 Class template cached_adaptive_pool, 294, 297, 297 Class template cached_node_allocator, 300, 302, 303 Class template node_allocator, 305, 307, 308 Class template private_adaptive_pool, 311, 314, 314 Class template private_node_allocator, 317, 319, 319 Multiple allocation functions, 81, 81, 81 allocate_one Class template adaptive_pool, 284, 287, 287 Class template allocator, 289, 291, 291 Class template cached_adaptive_pool, 294, 297, 297 Class template cached_node_allocator, 300, 303, 303
242
Boost.Interprocess
Class template node_allocator, 305, 308, 308 Class template private_adaptive_pool, 311, 314, 314 Class template private_node_allocator, 317, 320, 320 Allocating aligned memory portions assert, 79 allocator Class template allocator, 289, 344 Class template segment_manager, 387 Struct template allocator, 392 allocator_holder Class template iunordered_set_index, 337 allocator_type Building custom indexes, 150 Struct template at_map_index_aux, 334 all_memory_deallocated Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 386 Anonymous condition example buffer, 39 lock, 39, 39 Anonymous mutex example lock, 35, 35 while, 35, 35 assert adaptive_pool: a process-shared adaptive pool, 105 Allocating aligned memory portions, 79 cached_adaptive_pool: Avoiding synchronization overhead, 108 cached_node_allocator: caching nodes to avoid overhead, 102 Expand in place memory allocation, 83 Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 Growing managed segments, 77 Mapping Address Independent Pointer: offset_ptr, 29 Move semantics in Interprocess containers, 115 node_allocator: A process-shared segregated storage, 99 private_adaptive_pool: a private adaptive pool, 107 private_node_allocator: a private segregated storage, 100 Shared pointer and weak pointer, 135 Transferring Unlocked Locks, 56 Unique pointer, 139 atomic_func Class template segment_manager, 387, 390 Executing an object function atomically, 76
B
bad_alloc Class bad_alloc, 330, 330 base_t Class template basic_bufferbuf, 423 base_type Building custom indexes, 150 basic_bufferbuf Class template basic_bufferbuf, 349, 423 basic_bufferstream Class template basic_bufferstream, 350, 427 Formatting directly in your character buffer: bufferstream, 127 basic_ibufferstream
243
Boost.Interprocess
Class template basic_ibufferstream, 350, 424 basic_managed_external_buffer Class template basic_managed_external_buffer, 348, 356, 356 basic_managed_heap_memory Class template basic_managed_heap_memory, 349, 357, 357 basic_managed_mapped_le Class template basic_managed_mapped_le, 349, 359 basic_managed_shared_memory Class template basic_managed_shared_memory, 348, 361, 361 basic_managed_windows_shared_memory Class template basic_managed_windows_shared_memory, 348, 364, 364 basic_managed_xsi_shared_memory Class template basic_managed_xsi_shared_memory, 349, 366, 366 basic_obufferstream Class template basic_obufferstream, 350, 425 basic_vectorbuf Class template basic_vectorbuf, 350, 428 basic_vectorstream Class template basic_vectorstream, 351, 432 Formatting directly in your character vector: vectorstream, 124 Be Careful With Iostream Writing ush, 62 begin Class template null_index, 339, 340, 340 Boost unordered containers name, 118 BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR Header < boost/interprocess/offset_ptr.hpp >, 374 Macro BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR, 381, 381, 381 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF Header < boost/interprocess/offset_ptr.hpp >, 374 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF, 381, 381, 381 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER Header < boost/interprocess/offset_ptr.hpp >, 374 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER, 381, 381, 381 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR Header < boost/interprocess/offset_ptr.hpp >, 374 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR, 381, 381, 381 bucket_ptr Class template iunordered_set_index, 337 bucket_traits Class template iunordered_set_index, 337 bucket_type Class template iunordered_set_index, 337 buffer Anonymous condition example, 39 Building custom indexes, 150 Class template basic_bufferbuf, 423, 424, 424 Class template basic_bufferstream, 427, 427, 427 Class template basic_ibufferstream, 424, 425, 425 Class template basic_obufferstream, 425, 426, 426 Formatting directly in your character buffer: bufferstream, 127, 127 Header < boost/interprocess/allocators/allocator.hpp >, 288 Introduction, 66, 66 bufferbuf Header < boost/interprocess/streams/bufferstream.hpp >, 422 bufferstream Formatting directly in your character buffer: bufferstream, 127
244
Boost.Interprocess
Header < boost/interprocess/streams/bufferstream.hpp >, 422 Building custom indexes allocator_type, 150 base_type, 150 buffer, 150 char_type, 150 at_map_index_aux, 150 index_aux, 150 index_t, 150 key_less, 150 key_type, 150, 150 mapped_type, 150, 150 name, 150 reserve, 150, 150 segment_manager, 150 segment_manager_base, 150, 150 shrink_to_t, 150 value_type, 150
C
cached_adaptive_pool Class template cached_adaptive_pool, 294, 295 cached_adaptive_pool: Avoiding synchronization overhead assert, 108 set_max_cached_nodes, 109 cached_node_allocator Class template cached_node_allocator, 300, 301 cached_node_allocator: caching nodes to avoid overhead assert, 102 set_max_cached_nodes, 103 char_ptr Class template message_queue_t, 353 char_type Building custom indexes, 150 Class template basic_bufferbuf, 423 Class template basic_bufferstream, 427 Class template basic_ibufferstream, 424 Class template basic_obufferstream, 425 Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template segment_manager, 387 Class template std, 430 Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 check_sanity Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 386 Class bad_alloc bad_alloc, 330, 330 interprocess_exception, 330 wait, 330 Class le_lock le_lock, 434 lock, 434, 435 lock_sharable, 434, 435 swap, 434, 435 timed_lock, 434, 435
245
Boost.Interprocess
timed_lock_sharable, 434, 435 try_lock, 434, 435 try_lock_sharable, 434, 435 unlock, 434, 435 unlock_sharable, 434, 435 Class le_mapping le_mapping, 331, 331 remove, 331, 332 swap, 331, 332 Class interprocess_condition interprocess_condition, 436, 436 notify_all, 436, 437 notify_one, 436, 437 pred, 437 timed_wait, 436, 437, 437 wait, 436, 437, 437 Class interprocess_condition_any interprocess_condition_any, 438, 438 notify_all, 438, 438 notify_one, 438, 438 pred, 439 timed_wait, 438, 439, 439 wait, 438, 438, 439 Class interprocess_exception interprocess_exception, 329, 329 Class interprocess_mutex interprocess_mutex, 439, 439 lock, 439, 440 timed_lock, 439, 440 try_lock, 439, 440 unlock, 439, 440 Class interprocess_recursive_mutex interprocess_recursive_mutex, 441, 441 lock, 441, 441 timed_lock, 441, 441 try_lock, 441, 441 unlock, 441, 441 Class interprocess_semaphore interprocess_semaphore, 442, 442 post, 442, 442 timed_wait, 442, 443 try_wait, 442, 443 wait, 442, 443 Class interprocess_sharable_mutex interprocess_sharable_mutex, 444, 444 lock, 444, 444 lock_sharable, 444, 445 timed_lock, 444, 445 timed_lock_sharable, 444, 445 try_lock, 444, 444 try_lock_sharable, 444, 445 unlock, 444, 445 unlock_sharable, 444, 445 Class interprocess_upgradable_mutex interprocess_upgradable_mutex, 446, 446 lock, 446, 447 lock_sharable, 446, 447 lock_upgradable, 446, 447
246
Boost.Interprocess
timed_lock, 446, 447 timed_lock_sharable, 446, 447 timed_lock_upgradable, 446, 448 timed_unlock_upgradable_and_lock, 446, 448 try_lock, 446, 447 try_lock_sharable, 446, 447 try_lock_upgradable, 446, 448 try_unlock_sharable_and_lock, 446, 449 try_unlock_sharable_and_lock_upgradable, 446, 449 try_unlock_upgradable_and_lock, 446, 448 unlock, 446, 447 unlock_and_lock_sharable, 446, 448 unlock_and_lock_upgradable, 446, 448 unlock_sharable, 446, 447 unlock_upgradable, 446, 448 unlock_upgradable_and_lock, 446, 448 unlock_upgradable_and_lock_sharable, 446, 448 Class lock_exception interprocess_exception, 330 lock_exception, 330, 330 Class mapped_region advise, 368, 370 ush, 368, 369 get_page_size, 368, 370 mapped_region, 368, 368, 368 shrink_by, 368, 369 swap, 368, 369 Class named_condition named_condition, 452, 452, 453 notify_all, 452, 453 notify_one, 452, 453 pred, 453 remove, 452, 453, 454 timed_wait, 452, 453, 453 wait, 452, 453, 453 Class named_condition_any named_condition_any, 454, 454, 455 notify_all, 454, 455 notify_one, 454, 455 pred, 456 remove, 454, 455, 456 timed_wait, 454, 455, 456 wait, 454, 455, 455 Class named_mutex lock, 456, 457 named_mutex, 456, 456, 457 remove, 456, 457, 457 timed_lock, 456, 457 try_lock, 456, 457 unlock, 456, 457 Class named_recursive_mutex lock, 458, 459 named_recursive_mutex, 458, 458, 458 remove, 458, 459, 459 timed_lock, 458, 459 try_lock, 458, 459 unlock, 458, 459 Class named_semaphore
247
Boost.Interprocess
named_semaphore, 460, 460, 460 post, 460, 461 remove, 460, 460, 461 timed_wait, 460, 461 try_wait, 460, 461 wait, 460, 461 Class named_sharable_mutex lock, 462, 463 lock_sharable, 462, 463 named_sharable_mutex, 462, 462, 462 remove, 462, 462, 464 timed_lock, 462, 463 timed_lock_sharable, 462, 463 try_lock, 462, 463 try_lock_sharable, 462, 463 unlock, 462, 463 unlock_sharable, 462, 463 Class named_upgradable_mutex lock, 465, 466 lock_sharable, 465, 466 lock_upgradable, 465, 467 named_upgradable_mutex, 465, 465, 465 remove, 465, 466, 468 timed_lock, 465, 466 timed_lock_sharable, 465, 466 timed_lock_upgradable, 465, 467 timed_unlock_upgradable_and_lock, 465, 468 try_lock, 465, 466 try_lock_sharable, 465, 466 try_lock_upgradable, 465, 467 try_unlock_sharable_and_lock, 465, 468 try_unlock_sharable_and_lock_upgradable, 465, 468 try_unlock_upgradable_and_lock, 465, 468 unlock, 465, 466 unlock_and_lock_sharable, 465, 467 unlock_and_lock_upgradable, 465, 467 unlock_sharable, 465, 467 unlock_upgradable, 465, 467 unlock_upgradable_and_lock, 465, 467 unlock_upgradable_and_lock_sharable, 465, 467 Class null_mutex lock, 469, 469, 469 lock_sharable, 469, 470, 470 lock_upgradable, 469, 470, 470 null_mutex, 469, 469 timed_lock, 469, 470, 470 timed_lock_sharable, 469, 470, 470 timed_lock_upgradable, 469, 470, 470 timed_unlock_upgradable_and_lock, 469, 471, 471 try_lock, 469, 469, 469 try_lock_sharable, 469, 470, 470 try_lock_upgradable, 469, 470, 470 try_unlock_sharable_and_lock, 469, 471, 471 try_unlock_sharable_and_lock_upgradable, 469, 471, 471 try_unlock_upgradable_and_lock, 469, 471, 471 unlock, 469, 470, 470 unlock_and_lock_sharable, 469, 470, 470 unlock_and_lock_upgradable, 469, 470, 470
248
Boost.Interprocess
unlock_sharable, 469, 470, 470 unlock_upgradable, 469, 470, 470 unlock_upgradable_and_lock, 469, 471, 471 unlock_upgradable_and_lock_sharable, 469, 470, 470 Class permissions permissions, 382 set_default, 382, 382 set_permissions, 382, 382 set_unrestricted, 382, 382 Class remove_le_on_destroy remove_le_on_destroy, 333 Class remove_shared_memory_on_destroy remove_shared_memory_on_destroy, 395 Class shared_memory_object remove, 393, 394, 394 shared_memory_object, 393 swap, 393, 394 truncate, 393, 394 Class template adaptive_pool adaptive_pool, 284, 285 allocate, 284, 286 allocate_individual, 284, 287 allocate_many, 284, 286, 286 allocate_one, 284, 287, 287 const_pointer, 284 const_reference, 284 deallocate, 284, 286, 286, 287 deallocate_free_blocks, 284, 286 deallocate_individual, 284, 287 deallocate_many, 284, 287 deallocate_one, 284, 287, 287, 287, 287 difference_type, 284 other, 284 pointer, 284 rebind, 284 reference, 284 segment_manager, 284 size_type, 284 swap, 284, 287 value_type, 284 void_pointer, 284 Class template allocator allocate, 289, 290 allocate_individual, 289, 291 allocate_many, 289, 291, 291 allocate_one, 289, 291, 291 allocator, 289, 344 construct, 289, 292 const_pointer, 289 const_reference, 289 deallocate, 289, 290, 291, 291 deallocate_individual, 289, 291 deallocate_many, 289, 291 deallocate_one, 289, 291, 291, 291, 291 destroy, 289, 292 difference_type, 289 other, 289 pointer, 289
249
Boost.Interprocess
rebind, 289 reference, 289 segment_manager, 289 size_type, 289 swap, 289, 292 value_type, 289 version, 289 void_pointer, 289 Class template basic_bufferbuf base_t, 423 basic_bufferbuf, 349, 423 buffer, 423, 424, 424 char_type, 423 int_type, 423 off_type, 423 pos_type, 423 traits_type, 423 Class template basic_bufferstream basic_bufferstream, 350, 427 buffer, 427, 427, 427 char_type, 427 int_type, 427 off_type, 427 pos_type, 427 traits_type, 427 Class template basic_ibufferstream basic_ibufferstream, 350, 424 buffer, 424, 425, 425 char_type, 424 int_type, 424 off_type, 424 pos_type, 424 traits_type, 424 Class template basic_managed_external_buffer basic_managed_external_buffer, 348, 356, 356 grow, 356, 357 size_type, 356 swap, 356, 357 Class template basic_managed_heap_memory basic_managed_heap_memory, 349, 357, 357 grow, 357, 358 size_type, 357 swap, 357, 358 Class template basic_managed_mapped_le basic_managed_mapped_le, 349, 359 ush, 359, 360 grow, 359, 360 remove, 360 shrink_to_t, 359, 360 swap, 359, 360 Class template basic_managed_shared_memory basic_managed_shared_memory, 348, 361, 361 grow, 361, 362 remove, 362 shrink_to_t, 361, 363 swap, 361, 362 Class template basic_managed_windows_shared_memory basic_managed_windows_shared_memory, 348, 364, 364
250
Boost.Interprocess
size_type, 364 swap, 364, 365 Class template basic_managed_xsi_shared_memory basic_managed_xsi_shared_memory, 349, 366, 366 remove, 366, 367, 367 size_type, 366 swap, 366, 367 Class template basic_obufferstream basic_obufferstream, 350, 425 buffer, 425, 426, 426 char_type, 425 int_type, 425 off_type, 425 pos_type, 425 traits_type, 425 Class template basic_vectorbuf basic_vectorbuf, 350, 428 char_type, 428 clear, 428, 429, 429 int_type, 428 off_type, 428 pos_type, 428 reserve, 428, 429 swap_vector, 428, 429 traits_type, 428 vector_type, 428 Class template basic_vectorstream basic_vectorstream, 351, 432 char_type, 432 clear, 432, 433, 433 int_type, 432 off_type, 432 pos_type, 432 reserve, 432, 433, 433 swap_vector, 432, 433 traits_type, 432 vector_type, 432 Class template cached_adaptive_pool allocate, 294, 296 allocate_individual, 294, 297 allocate_many, 294, 297, 297 allocate_one, 294, 297, 297 cached_adaptive_pool, 294, 295 construct, 294, 296 const_pointer, 294 const_reference, 294 deallocate, 294, 296, 297, 297 deallocate_free_blocks, 294, 296 deallocate_individual, 294, 297 deallocate_many, 294, 297 deallocate_one, 294, 297, 297, 297, 297 destroy, 294, 296 difference_type, 294 other, 294 pointer, 294 rebind, 294 reference, 294 segment_manager, 294
251
Boost.Interprocess
set_max_cached_nodes, 294, 297 size_type, 294 swap, 294, 298 value_type, 294 void_pointer, 294 Class template cached_node_allocator allocate, 300, 302 allocate_individual, 300, 303 allocate_many, 300, 302, 303 allocate_one, 300, 303, 303 cached_node_allocator, 300, 301 construct, 300, 302 const_pointer, 300 const_reference, 300 deallocate, 300, 302, 302, 303 deallocate_free_blocks, 300, 302 deallocate_individual, 300, 303 deallocate_many, 300, 303 deallocate_one, 300, 303, 303, 303, 303 destroy, 300, 302 difference_type, 300 other, 300 pointer, 300 rebind, 300 reference, 300 segment_manager, 300 set_max_cached_nodes, 300, 303 size_type, 300 swap, 300, 303 value_type, 300 void_pointer, 300 Class template deleter deleter, 396 pointer, 396 Class template enable_shared_from_this enable_shared_from_this, 397 Class template at_map_index reserve, 334, 334 shrink_to_t, 334, 334 Class template intrusive_ptr element_type, 399 get, 399, 400, 400, 400, 400, 400 intrusive_ptr, 352, 399 intrusive_ptr_add_ref, 399, 399, 400, 400 intrusive_ptr_release, 399, 400 pointer, 399 swap, 399, 401 Class template iset_index const_iterator, 335 nd, 335, 336, 336 insert_commit_data, 335 iset_index_aux, 335 iterator, 335 reserve, 335, 335 shrink_to_t, 335, 336 value_type, 335 Class template iunordered_set_index allocator_holder, 337
252
Boost.Interprocess
bucket_ptr, 337 bucket_traits, 337 bucket_type, 337 const_iterator, 337 nd, 337, 338, 338 insert_commit, 337, 338 insert_commit_data, 337 iterator, 337 iunordered_set_index_aux, 337 reserve, 337, 337 shrink_to_t, 337, 337 size_type, 337 value_type, 337 Class template map_index reserve, 338, 339 shrink_to_t, 338, 339 Class template message_queue_t char_ptr, 353 difference_type, 353 get_num_msg, 353, 355 message_queue_t, 352, 353 receive, 353, 354 remove, 353, 354, 355 send, 353, 354 size_type, 353 timed_receive, 353, 355 timed_send, 353, 354 try_receive, 353, 355 try_send, 353, 354 void_pointer, 353 Class template node_allocator allocate, 305, 307 allocate_individual, 305, 308 allocate_many, 305, 307, 308 allocate_one, 305, 308, 308 construct, 305, 307 const_pointer, 305 const_reference, 305 deallocate, 305, 307, 307, 308 deallocate_free_blocks, 305, 307 deallocate_individual, 305, 308 deallocate_many, 305, 308 deallocate_one, 305, 308, 308, 308, 308 destroy, 305, 307 difference_type, 305 node_allocator, 305, 306 other, 305 pointer, 305 rebind, 305 reference, 305 segment_manager, 305 size_type, 305 swap, 305, 308 value_type, 305 void_pointer, 305 Class template null_index begin, 339, 340, 340 const_iterator, 339
253
Boost.Interprocess
end, 339, 340, 340, 340, 340, 340, 340 iterator, 339 null_index, 339, 339, 347 Class template offset_ptr difference_type, 376 element_type, 376 get, 376, 378 iterator_category, 376 offset_ptr, 345, 376, 376, 377, 377, 377, 377, 377, 378 offset_type, 376 other, 376 pointer, 376 pointer_to, 376, 379 rebind, 376 reference, 376 value_type, 376 Class template private_adaptive_pool allocate, 311, 313 allocate_individual, 311, 314 allocate_many, 311, 314, 314 allocate_one, 311, 314, 314 construct, 311, 313 const_pointer, 311 const_reference, 311 deallocate, 311, 313, 314, 314 deallocate_free_blocks, 311, 313 deallocate_individual, 311, 314 deallocate_many, 311, 314 deallocate_one, 311, 314, 314, 314, 314 destroy, 311, 313 difference_type, 311 other, 311 pointer, 311 private_adaptive_pool, 311, 312 rebind, 311 reference, 311 segment_manager, 311 size_type, 311 swap, 311, 314 value_type, 311 void_pointer, 311 Class template private_node_allocator allocate, 317, 319 allocate_individual, 317, 320 allocate_many, 317, 319, 319 allocate_one, 317, 320, 320 construct, 317, 319 const_pointer, 317 const_reference, 317 deallocate, 317, 319, 319, 320 deallocate_free_blocks, 317, 319 deallocate_individual, 317, 320 deallocate_many, 317, 320 deallocate_one, 317, 320, 320, 320, 320 destroy, 317, 319 difference_type, 317 other, 317 pointer, 317
254
Boost.Interprocess
private_node_allocator, 317, 318 rebind, 317 reference, 317 segment_manager, 317 size_type, 317 swap, 317, 320 value_type, 317 void_pointer, 317 Class template rbtree_best_t allocate, 371, 372 allocate_aligned, 371, 373 all_memory_deallocated, 371, 372 check_sanity, 371, 372 deallocate, 371, 372 difference_type, 371 get_min_size, 371, 373 grow, 371, 372 multiallocation_chain, 371 mutex_family, 371 rbtree_best_t, 346, 371, 371 shrink_to_t, 371, 372 size_type, 371 void_pointer, 371 zero_free_memory, 371, 372 Class template scoped_lock lock, 472, 474, 474 lock_exception, 474, 474, 474, 475 mutex_type, 472 release, 472, 475 scoped_lock, 343, 472 swap, 472, 475 timed_lock, 472, 474, 474 timed_unlock_upgradable_and_lock, 474 try_lock, 472, 474, 474 try_unlock_sharable_and_lock, 474 try_unlock_upgradable_and_lock, 473 unlock, 472, 474, 475, 475 unlock_upgradable_and_lock, 473 Class template scoped_ptr deleter_type, 405 element_type, 405 get, 405, 406, 406 pointer, 405 release, 405, 405, 406 reset, 405, 405, 405 scoped_ptr, 351, 405, 405, 405 swap, 405, 406 unspecied_bool_type, 405 Class template segment_manager allocator, 387 atomic_func, 387, 390 char_type, 387 construct, 387, 389, 389 construct_it, 387, 389, 390 const_named_iterator, 387 const_unique_iterator, 387 deleter, 387 destroy, 387, 390, 390
255
Boost.Interprocess
destroy_ptr, 387, 390 difference_type, 387 nd, 387, 388, 389 nd_or_construct, 387, 389, 389 nd_or_construct_it, 387, 389, 390 get_allocator, 387, 391 get_deleter, 387, 391 get_instance_length, 387, 391 get_instance_name, 387, 391 get_instance_type, 387, 391 get_min_size, 387, 391 get_num_named_objects, 387, 390 get_num_unique_objects, 387, 391 memory_algorithm, 387 mutex_family, 387 reserve_named_objects, 387, 390 reserve_unique_objects, 387, 390 segment_manager, 348, 387, 387, 388 segment_manager_base, 387 segment_manager_base_type, 387 shrink_to_t_indexes, 387, 390 size_type, 387 try_atomic_func, 387, 390 type, 387 void_pointer, 387 Class template segment_manager_base allocate, 384, 385, 385 allocate_aligned, 384, 385, 385 all_memory_deallocated, 384, 386 check_sanity, 384, 386 deallocate, 384, 385 get_min_size, 384, 386 grow, 384, 385 memory_algorithm, 384 mutex_family, 384 segment_manager_base, 384 segment_manager_base_type, 384 shrink_to_t, 384, 386 void_pointer, 384 zero_free_memory, 384, 386 Class template sharable_lock lock, 476, 478 lock_exception, 478, 478, 478, 478 lock_sharable, 478 mutex_type, 476 release, 476, 478 sharable_lock, 343, 476, 476, 476, 477, 477 swap, 476, 479 timed_lock, 476, 478 timed_lock_sharable, 478 try_lock, 476, 478 try_lock_sharable, 478 unlock, 476, 478 unlock_and_lock_sharable, 477 unlock_sharable, 477, 478 unlock_upgradable_and_lock_sharable, 477 Class template shared_ptr const_allocator_pointer, 410
256
Boost.Interprocess
const_deleter_pointer, 410 const_reference, 410 element_type, 410 get, 410, 411, 412 pointer, 410 reference, 410 reset, 410, 412, 412, 412 shared_ptr, 352, 410 swap, 410, 413 value_type, 410 Class template simple_seq_t simple_seq_t, 346, 373 size_type, 373 Class template std char_type, 430 clear, 430, 431, 431 int_type, 430 off_type, 430 pos_type, 430 reserve, 430, 431, 431, 432, 432 swap_vector, 430, 431, 431 traits_type, 430 vector_type, 430 Class template unique_ptr deleter_type, 415 element_type, 415 get, 415, 416, 417, 418, 418, 418 get_deleter, 415, 416, 417, 418, 418, 418 pointer, 415 release, 415, 418 reset, 415, 418 swap, 415, 418 unique_ptr, 415, 415, 416, 416 Class template unordered_map_index reserve, 340, 341 shrink_to_t, 340, 341 unordered_map_index_aux, 340 Class template upgradable_lock lock, 479, 481 lock_exception, 481, 481, 481, 481 lock_upgradable, 481 mutex_type, 479 release, 479, 482 swap, 479, 482 timed_lock, 479, 481 timed_lock_upgradable, 481 try_lock, 479, 481 try_lock_upgradable, 481 try_unlock_sharable_and_lock_upgradable, 481 unlock, 479, 481 unlock_upgradable, 481, 481 upgradable_lock, 343, 479, 479, 480, 480, 481 Class template weak_ptr element_type, 420 lock, 420, 421 reset, 420, 421 swap, 420, 422 value_type, 420
257
Boost.Interprocess
weak_ptr, 409, 409, 420 Class windows_shared_memory swap, 483, 484 windows_shared_memory, 483 Class xsi_key xsi_key, 485 Class xsi_shared_memory remove, 486, 487, 487 swap, 486, 487 xsi_shared_memory, 486 clear Class template basic_vectorbuf, 428, 429, 429 Class template basic_vectorstream, 432, 433, 433 Class template std, 430, 431, 431 Common Managed Mapped Files managed_mapped_le, 70 wmanaged_mapped_le, 70 Common Managed Shared Memory Classes xed_managed_shared_memory, 67 managed_shared_memory, 67 wxed_managed_shared_memory, 67 wmanaged_shared_memory, 67 construct Class template allocator, 289, 292 Class template cached_adaptive_pool, 294, 296 Class template cached_node_allocator, 300, 302 Class template node_allocator, 305, 307 Class template private_adaptive_pool, 311, 313 Class template private_node_allocator, 317, 319 Class template segment_manager, 387, 389, 389 Constructing Managed Mapped Files remove, 70 construct_it Class template segment_manager, 387, 389, 390 const_allocator_pointer Class template shared_ptr, 410 const_deleter_pointer Class template shared_ptr, 410 const_iterator Class template iset_index, 335 Class template iunordered_set_index, 337 Class template null_index, 339 const_named_iterator Class template segment_manager, 387 const_pointer Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 const_reference Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305
258
Boost.Interprocess
Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template shared_ptr, 410 const_unique_iterator Class template segment_manager, 387 Containers of containers void_allocator, 117 create_only_t Struct create_only_t, 325 Creating maps in shared memory name, 8 Creating named shared memory objects if, 4 Creating vectors in shared memory if, 6
D
data What's A Message Queue?, 62 deallocate Class template adaptive_pool, 284, 286, 286, 287 Class template allocator, 289, 290, 291, 291 Class template cached_adaptive_pool, 294, 296, 297, 297 Class template cached_node_allocator, 300, 302, 302, 303 Class template node_allocator, 305, 307, 307, 308 Class template private_adaptive_pool, 311, 313, 314, 314 Class template private_node_allocator, 317, 319, 319, 320 Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 385 Performance of raw memory allocations, 146 Writing a new shared memory allocation algorithm, 148, 149 deallocate_free_blocks Class template adaptive_pool, 284, 286 Class template cached_adaptive_pool, 294, 296 Class template cached_node_allocator, 300, 302 Class template node_allocator, 305, 307 Class template private_adaptive_pool, 311, 313 Class template private_node_allocator, 317, 319 deallocate_individual Class template adaptive_pool, 284, 287 Class template allocator, 289, 291 Class template cached_adaptive_pool, 294, 297 Class template cached_node_allocator, 300, 303 Class template node_allocator, 305, 308 Class template private_adaptive_pool, 311, 314 Class template private_node_allocator, 317, 320 deallocate_many Class template adaptive_pool, 284, 287 Class template allocator, 289, 291 Class template cached_adaptive_pool, 294, 297 Class template cached_node_allocator, 300, 303 Class template node_allocator, 305, 308 Class template private_adaptive_pool, 311, 314 Class template private_node_allocator, 317, 320 deallocate_one Class template adaptive_pool, 284, 287, 287, 287, 287 Class template allocator, 289, 291, 291, 291, 291
259
Boost.Interprocess
Class template cached_adaptive_pool, 294, 297, 297, 297, 297 Class template cached_node_allocator, 300, 303, 303, 303, 303 Class template node_allocator, 305, 308, 308, 308, 308 Class template private_adaptive_pool, 311, 314, 314, 314, 314 Class template private_node_allocator, 317, 320, 320, 320, 320 defer_lock_type Struct defer_lock_type, 449 deleter Class template deleter, 396 Class template segment_manager, 387 Struct template deleter, 392 Struct template managed_shared_ptr, 413 deleter_type Class template scoped_ptr, 405 Class template unique_ptr, 415 Shared pointer and weak pointer, 135 Demotions (Upgradable Mutex only) unlock_and_lock_sharable, 49 unlock_and_lock_upgradable, 49 unlock_upgradable_and_lock_sharable, 49 destroy Class template allocator, 289, 292 Class template cached_adaptive_pool, 294, 296 Class template cached_node_allocator, 300, 302 Class template node_allocator, 305, 307 Class template private_adaptive_pool, 311, 313 Class template private_node_allocator, 317, 319 Class template segment_manager, 387, 390, 390 destroy_ptr Class template segment_manager, 387, 390 difference_type Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template message_queue_t, 353 Class template node_allocator, 305 Class template offset_ptr, 376 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template rbtree_best_t, 371 Class template segment_manager, 387 Direct iostream formatting: vectorstream and bufferstream while, 124
E
element_type Class template intrusive_ptr, 399 Class template offset_ptr, 376 Class template scoped_ptr, 405 Class template shared_ptr, 410 Class template unique_ptr, 415 Class template weak_ptr, 420 enable_shared_from_this Class template enable_shared_from_this, 397 end Class template null_index, 339, 340, 340, 340, 340, 340, 340
260
Boost.Interprocess
Example: Serializing a database through the message queue if, 93 while, 93 Exclusive Locking (Sharable & Upgradable Mutexes) lock, 47 timed_lock, 47 try_lock, 47 unlock, 47 Executing an object function atomically atomic_func, 76 Expand in place memory allocation assert, 83
F
File Locking Operations lock, 58 lock_sharable, 58 timed_lock, 58 timed_lock_sharable, 58 try_lock, 58 try_lock_sharable, 58 unlock, 58 unlock_sharable, 58 le_lock Class le_lock, 434 le_mapping Class le_mapping, 331, 331 nd Class template iset_index, 335, 336, 336 Class template iunordered_set_index, 337, 338, 338 Class template segment_manager, 387, 388, 389 Performance of named allocations, 146 nd_or_construct Class template segment_manager, 387, 389, 389 nd_or_construct_it Class template segment_manager, 387, 389, 390 xed_managed_shared_memory Common Managed Shared Memory Classes, 67 Header < boost/interprocess/interprocess_fwd.hpp >, 341 at_map_index_aux Building custom indexes, 150 Struct template at_map_index_aux, 334 ush Be Careful With Iostream Writing, 62 Class mapped_region, 368, 369 Class template basic_managed_mapped_le, 359, 360 for Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 Formatting directly in your character buffer: bufferstream assert, 127 basic_bufferstream, 127 buffer, 127, 127 bufferstream, 127 char_type, 127 for, 127 int_type, 127
261
Boost.Interprocess
off_type, 127 pos_type, 127 traits_type, 127 wbufferstream, 127 Formatting directly in your character vector: vectorstream assert, 124 basic_vectorstream, 124 char_type, 124 for, 124 int_type, 124 off_type, 124 pos_type, 124 reserve, 124 swap_vector, 124, 124 traits_type, 124 vector_type, 124 Function template make_managed_shared_ptr make_managed_shared_ptr, 413, 414 Function template make_managed_unique_ptr make_managed_unique_ptr, 419 Function template make_managed_weak_ptr make_managed_weak_ptr, 422 Function template swap swap, 403, 406 Function template to_raw_pointer to_raw_pointer, 404, 407
G
get Class template intrusive_ptr, 399, 400, 400, 400, 400, 400 Class template offset_ptr, 376, 378 Class template scoped_ptr, 405, 406, 406 Class template shared_ptr, 410, 411, 412 Class template unique_ptr, 415, 416, 417, 418, 418, 418 get_allocator Class template segment_manager, 387, 391 get_deleter Class template segment_manager, 387, 391 Class template unique_ptr, 415, 416, 417, 418, 418, 418 get_instance_length Class template segment_manager, 387, 391 get_instance_name Class template segment_manager, 387, 391 get_instance_type Class template segment_manager, 387, 391 get_min_size Class template rbtree_best_t, 371, 373 Class template segment_manager, 387, 391 Class template segment_manager_base, 384, 386 Writing a new shared memory allocation algorithm, 148, 149 get_num_msg Class template message_queue_t, 353, 355 get_num_named_objects Class template segment_manager, 387, 390 get_num_unique_objects Class template segment_manager, 387, 391 get_page_size
262
Boost.Interprocess
Class mapped_region, 368, 370 Global try_to_lock try_lock, 450 grow Class template basic_managed_external_buffer, 356, 357 Class template basic_managed_heap_memory, 357, 358 Class template basic_managed_mapped_le, 359, 360 Class template basic_managed_shared_memory, 361, 362 Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 385 Managed Heap Memory: Boost.Interprocess machinery in heap memory, 91 Writing a new shared memory allocation algorithm, 148, 149 Growing managed segments assert, 77
H
Header < boost/interprocess/allocators/allocator.hpp > buffer, 288 Header < boost/interprocess/errors.hpp > native_error_t, 328 Header < boost/interprocess/interprocess_fwd.hpp > xed_managed_shared_memory, 341 managed_external_buffer, 341 managed_heap_memory, 341 managed_mapped_le, 341 managed_shared_memory, 341 managed_windows_shared_memory, 341 managed_xsi_shared_memory, 341 message_queue, 341 wxed_managed_shared_memory, 341 wmanaged_external_buffer, 341 wmanaged_heap_memory, 341 wmanaged_mapped_le, 341 wmanaged_shared_memory, 341 wmanaged_windows_shared_memory, 341 wmanaged_xsi_shared_memory, 341 Header < boost/interprocess/offset_ptr.hpp > BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR, 374 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF, 374 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER, 374 BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR, 374 Header < boost/interprocess/smart_ptr/intrusive_ptr.hpp > swap, 397 to_raw_pointer, 397 Header < boost/interprocess/smart_ptr/scoped_ptr.hpp > swap, 404 to_raw_pointer, 404 Header < boost/interprocess/smart_ptr/shared_ptr.hpp > make_managed_shared_ptr, 407 swap, 407 to_raw_pointer, 407 Header < boost/interprocess/smart_ptr/unique_ptr.hpp > make_managed_unique_ptr, 414 swap, 414 Header < boost/interprocess/smart_ptr/weak_ptr.hpp > make_managed_weak_ptr, 419 swap, 419
263
Boost.Interprocess
Header < boost/interprocess/streams/bufferstream.hpp > bufferbuf, 422 bufferstream, 422 ibufferstream, 422 obufferstream, 422 wbufferbuf, 422 wbufferstream, 422 wibufferstream, 422 wobufferstream, 422
I
ibufferstream Header < boost/interprocess/streams/bufferstream.hpp >, 422 if Creating named shared memory objects, 4 Creating vectors in shared memory, 6 Example: Serializing a database through the message queue, 93 Intrusive pointer, 131 Managed External Buffer: Constructing all Boost.Interprocess objects in a user provided buffer, 88 Multiple allocation functions, 81 Opening managed shared memory and mapped les with Copy On Write or Read Only modes, 86 Scoped lock, 34 Scoped pointer, 133 Sharable Lock And Upgradable Lock, 51 Using shared memory as a pool of unnamed memory blocks, 3 index_aux Building custom indexes, 150 index_t Building custom indexes, 150 Struct template at_map_index_aux, 334 insert_commit Class template iunordered_set_index, 337, 338 insert_commit_data Class template iset_index, 335 Class template iunordered_set_index, 337 interprocess_condition Class interprocess_condition, 436, 436 interprocess_condition_any Class interprocess_condition_any, 438, 438 interprocess_exception Class bad_alloc, 330 Class interprocess_exception, 329, 329 Class lock_exception, 330 interprocess_mutex Class interprocess_mutex, 439, 439 interprocess_recursive_mutex Class interprocess_recursive_mutex, 441, 441 interprocess_semaphore Class interprocess_semaphore, 442, 442 interprocess_sharable_mutex Class interprocess_sharable_mutex, 444, 444 interprocess_upgradable_mutex Class interprocess_upgradable_mutex, 446, 446 Introduction buffer, 66, 66 Intrusive pointer if, 131
264
Boost.Interprocess
intrusive_ptr_add_ref, 131, 131 intrusive_ptr_release, 131, 131 segment_manager, 131, 131 intrusive_ptr Class template intrusive_ptr, 352, 399 intrusive_ptr_add_ref Class template intrusive_ptr, 399, 399, 400, 400 Intrusive pointer, 131, 131 intrusive_ptr_release Class template intrusive_ptr, 399, 400 Intrusive pointer, 131, 131 int_type Class template basic_bufferbuf, 423 Class template basic_bufferstream, 427 Class template basic_ibufferstream, 424 Class template basic_obufferstream, 425 Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template std, 430 Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 iset_index_aux Class template iset_index, 335 iterator Class template iset_index, 335 Class template iunordered_set_index, 337 Class template null_index, 339 Multiple allocation functions, 81 iterator_category Class template offset_ptr, 376 iunordered_set_index_aux Class template iunordered_set_index, 337
K
key_less Building custom indexes, 150 Struct template at_map_index_aux, 334 key_type Building custom indexes, 150, 150 Struct template at_map_index_aux, 334
L
lock Anonymous condition example, 39, 39 Anonymous mutex example, 35, 35 Class le_lock, 434, 435 Class interprocess_mutex, 439, 440 Class interprocess_recursive_mutex, 441, 441 Class interprocess_sharable_mutex, 444, 444 Class interprocess_upgradable_mutex, 446, 447 Class named_mutex, 456, 457 Class named_recursive_mutex, 458, 459 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 469, 469 Class template scoped_lock, 472, 474, 474 Class template sharable_lock, 476, 478
265
Boost.Interprocess
Class template upgradable_lock, 479, 481 Class template weak_ptr, 420, 421 Exclusive Locking (Sharable & Upgradable Mutexes), 47 File Locking Operations, 58 Mutex Operations, 32 Named mutex example, 38 Scoped lock, 34 Sharable Lock And Upgradable Lock, 51 What's a Sharable and an Upgradable Mutex?, 46 Lock Transfers Through Move Semantics unlock_and_lock_sharable, 53 lock_exception Class lock_exception, 330, 330 Class template scoped_lock, 474, 474, 474, 475 Class template sharable_lock, 478, 478, 478, 478 Class template upgradable_lock, 481, 481, 481, 481 lock_sharable Class le_lock, 434, 435 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 470, 470 Class template sharable_lock, 478 File Locking Operations, 58 Sharable Lock And Upgradable Lock, 51, 51 Sharable Locking (Sharable & Upgradable Mutexes), 48 lock_upgradable Class interprocess_upgradable_mutex, 446, 447 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template upgradable_lock, 481 Sharable Lock And Upgradable Lock, 51 Upgradable Locking (Upgradable Mutex only), 48
M
Macro BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR, 381, 381, 381 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF, 381, 381, 381 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER, 381, 381, 381 Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR, 381, 381, 381 make_managed_shared_ptr Function template make_managed_shared_ptr, 413, 414 Header < boost/interprocess/smart_ptr/shared_ptr.hpp >, 407 make_managed_unique_ptr Function template make_managed_unique_ptr, 419 Header < boost/interprocess/smart_ptr/unique_ptr.hpp >, 414 make_managed_weak_ptr Function template make_managed_weak_ptr, 422 Header < boost/interprocess/smart_ptr/weak_ptr.hpp >, 419 Managed External Buffer: Constructing all Boost.Interprocess objects in a user provided buffer if, 88 managed_external_buffer, 88 wmanaged_external_buffer, 88
266
Boost.Interprocess
Managed Heap Memory: Boost.Interprocess machinery in heap memory grow, 91 managed_heap_memory, 91 wmanaged_heap_memory, 91 managed_external_buffer Header < boost/interprocess/interprocess_fwd.hpp >, 341 Managed External Buffer: Constructing all Boost.Interprocess objects in a user provided buffer, 88 managed_heap_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 Managed Heap Memory: Boost.Interprocess machinery in heap memory, 91 managed_mapped_le Common Managed Mapped Files, 70 Header < boost/interprocess/interprocess_fwd.hpp >, 341 managed_shared_memory Common Managed Shared Memory Classes, 67 Header < boost/interprocess/interprocess_fwd.hpp >, 341 managed_shared_ptr Struct template managed_shared_ptr, 413 managed_unique_ptr Struct template managed_unique_ptr, 419 managed_weak_ptr Struct template managed_weak_ptr, 422 managed_windows_shared_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 managed_xsi_shared_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 mapped_region Class mapped_region, 368, 368, 368 mapped_type Building custom indexes, 150, 150 Struct template at_map_index_aux, 334 Mapping Address Independent Pointer: offset_ptr assert, 29 memory_algorithm Class template segment_manager, 387 Class template segment_manager_base, 384 message_queue Header < boost/interprocess/interprocess_fwd.hpp >, 341 message_queue_t Class template message_queue_t, 352, 353 Move semantics in Interprocess containers assert, 115 multiallocation_chain Class template rbtree_best_t, 371 Multiple allocation functions, 81 Multiple allocation functions allocate, 81, 81 allocate_many, 81, 81, 81 if, 81 iterator, 81 multiallocation_chain, 81 while, 81 Mutex Operations lock, 32 timed_lock, 32 try_lock, 32 unlock, 32 mutex_family
267
Boost.Interprocess
Class template rbtree_best_t, 371 Class template segment_manager, 387 Class template segment_manager_base, 384 Struct mutex_family, 451 The memory algorithm, 142 Writing a new shared memory allocation algorithm, 148, 148, 148, 148, 149 mutex_type Class template scoped_lock, 472 Class template sharable_lock, 476 Class template upgradable_lock, 479 Struct mutex_family, 451 Struct null_mutex_family, 451 Writing a new shared memory allocation algorithm, 148
N
name Boost unordered containers, 118 Building custom indexes, 150 Creating maps in shared memory, 8 Named mutex example lock, 38 named_condition Class named_condition, 452, 452, 453 named_condition_any Class named_condition_any, 454, 454, 455 named_mutex Class named_mutex, 456, 456, 457 named_recursive_mutex Class named_recursive_mutex, 458, 458, 458 named_semaphore Class named_semaphore, 460, 460, 460 named_sharable_mutex Class named_sharable_mutex, 462, 462, 462 named_upgradable_mutex Class named_upgradable_mutex, 465, 465, 465 native_error_t Header < boost/interprocess/errors.hpp >, 328 node_allocator Class template node_allocator, 305, 306 node_allocator: A process-shared segregated storage assert, 99 notify_all Class interprocess_condition, 436, 437 Class interprocess_condition_any, 438, 438 Class named_condition, 452, 453 Class named_condition_any, 454, 455 notify_one Class interprocess_condition, 436, 437 Class interprocess_condition_any, 438, 438 Class named_condition, 452, 453 Class named_condition_any, 454, 455 null_index Class template null_index, 339, 339, 347 null_mutex Class null_mutex, 469, 469 null_mutex_family Struct null_mutex_family, 451
268
Boost.Interprocess
O
obufferstream Header < boost/interprocess/streams/bufferstream.hpp >, 422 offset_ptr Class template offset_ptr, 345, 376, 376, 377, 377, 377, 377, 377, 378 offset_type Class template offset_ptr, 376 off_type Class template basic_bufferbuf, 423 Class template basic_bufferstream, 427 Class template basic_ibufferstream, 424 Class template basic_obufferstream, 425 Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template std, 430 Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 Opening managed shared memory and mapped les with Copy On Write or Read Only modes if, 86 open_copy_on_write_t Struct open_copy_on_write_t, 326 open_only_t Struct open_only_t, 325 open_or_create_t Struct open_or_create_t, 326 open_read_only_t Struct open_read_only_t, 325 open_read_private_t Struct open_read_private_t, 326 other Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305 Class template offset_ptr, 376 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Struct template rebind, 287, 292, 298, 304, 309, 315, 320, 380
P
Performance of named allocations nd, 146 Performance of raw memory allocations allocate, 146, 146 deallocate, 146 reserve, 146 permissions Class permissions, 382 pointer Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template deleter, 396 Class template intrusive_ptr, 399 Class template node_allocator, 305
269
Boost.Interprocess
Class template offset_ptr, 376 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template scoped_ptr, 405 Class template shared_ptr, 410 Class template unique_ptr, 415 Scoped pointer, 133 pointer_to Class template offset_ptr, 376, 379 post Class interprocess_semaphore, 442, 442 Class named_semaphore, 460, 461 pos_type Class template basic_bufferbuf, 423 Class template basic_bufferstream, 427 Class template basic_ibufferstream, 424 Class template basic_obufferstream, 425 Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template std, 430 Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 pred Class interprocess_condition, 437 Class interprocess_condition_any, 439 Class named_condition, 453 Class named_condition_any, 456 private_adaptive_pool Class template private_adaptive_pool, 311, 312 private_adaptive_pool: a private adaptive pool assert, 107 private_node_allocator Class template private_node_allocator, 317, 318 private_node_allocator: a private segregated storage assert, 100 Promotions (Upgradable Mutex only) timed_unlock_upgradable_and_lock, 50 try_unlock_sharable_and_lock, 50 try_unlock_sharable_and_lock_upgradable, 50 try_unlock_upgradable_and_lock, 50 unlock_upgradable_and_lock, 50
R
rbtree_best_t Class template rbtree_best_t, 346, 371, 371 rebind Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305 Class template offset_ptr, 376 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Struct template rebind, 287, 292, 298, 304, 309, 315, 320, 380 receive Class template message_queue_t, 353, 354
270
Boost.Interprocess
recursive_mutex_type Struct mutex_family, 451 Struct null_mutex_family, 451 Writing a new shared memory allocation algorithm, 148 reference Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305 Class template offset_ptr, 376 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template shared_ptr, 410 release Class template scoped_lock, 472, 475 Class template scoped_ptr, 405, 405, 406 Class template sharable_lock, 476, 478 Class template unique_ptr, 415, 418 Class template upgradable_lock, 479, 482 Scoped pointer, 133, 133 remove Class le_mapping, 331, 332 Class named_condition, 452, 453, 454 Class named_condition_any, 454, 455, 456 Class named_mutex, 456, 457, 457 Class named_recursive_mutex, 458, 459, 459 Class named_semaphore, 460, 460, 461 Class named_sharable_mutex, 462, 462, 464 Class named_upgradable_mutex, 465, 466, 468 Class shared_memory_object, 393, 394, 394 Class template basic_managed_mapped_le, 360 Class template basic_managed_shared_memory, 362 Class template basic_managed_xsi_shared_memory, 366, 367, 367 Class template message_queue_t, 353, 354, 355 Class xsi_shared_memory, 486, 487, 487 Constructing Managed Mapped Files, 70 Removing shared memory, 17 remove_le_on_destroy Class remove_le_on_destroy, 333 remove_shared_memory_on_destroy Class remove_shared_memory_on_destroy, 395 Removing shared memory remove, 17 reserve Building custom indexes, 150, 150 Class template basic_vectorbuf, 428, 429 Class template basic_vectorstream, 432, 433, 433 Class template at_map_index, 334, 334 Class template iset_index, 335, 335 Class template iunordered_set_index, 337, 337 Class template map_index, 338, 339 Class template std, 430, 431, 431, 432, 432 Class template unordered_map_index, 340, 341 Formatting directly in your character vector: vectorstream, 124 Performance of raw memory allocations, 146 reserve_named_objects Class template segment_manager, 387, 390
271
Boost.Interprocess
reserve_unique_objects Class template segment_manager, 387, 390 reset Class template scoped_ptr, 405, 405, 405 Class template shared_ptr, 410, 412, 412, 412 Class template unique_ptr, 415, 418 Class template weak_ptr, 420, 421
S
Scoped lock if, 34 lock, 34 unlock, 34 Scoped Lock and Sharable Lock With File Locking unlock_and_lock_sharable, 60 Scoped pointer if, 133 pointer, 133 release, 133, 133 segment_manager, 133, 133 scoped_lock Class template scoped_lock, 343, 472 scoped_ptr Class template scoped_ptr, 351, 405, 405, 405 segment_manager Building custom indexes, 150 Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template node_allocator, 305 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template segment_manager, 348, 387, 387, 388 Intrusive pointer, 131, 131 Scoped pointer, 133, 133 segment_manager_base Building custom indexes, 150, 150 Class template segment_manager, 387 Class template segment_manager_base, 384 Struct template at_map_index_aux, 334 segment_manager_base_type Class template segment_manager, 387 Class template segment_manager_base, 384 send Class template message_queue_t, 353, 354 set_default Class permissions, 382, 382 set_max_cached_nodes cached_adaptive_pool: Avoiding synchronization overhead, 109 cached_node_allocator: caching nodes to avoid overhead, 103 Class template cached_adaptive_pool, 294, 297 Class template cached_node_allocator, 300, 303 set_permissions Class permissions, 382, 382 set_unrestricted Class permissions, 382, 382
272
Boost.Interprocess
Sharable Lock And Upgradable Lock if, 51 lock, 51 lock_sharable, 51, 51 lock_upgradable, 51 timed_lock_sharable, 51 timed_lock_upgradable, 51 try_lock_sharable, 51 try_lock_upgradable, 51 unlock_sharable, 51, 51 unlock_upgradable, 51 Sharable Locking (Sharable & Upgradable Mutexes) lock_sharable, 48 timed_lock_sharable, 48 try_lock_sharable, 48 unlock_sharable, 48 sharable_lock Class template sharable_lock, 343, 476, 476, 476, 477, 477 Shared pointer and weak pointer assert, 135 deleter_type, 135 shared_memory_object Class shared_memory_object, 393 shared_ptr Class template shared_ptr, 352, 410 shrink_by Class mapped_region, 368, 369 shrink_to_t Building custom indexes, 150 Class template basic_managed_mapped_le, 359, 360 Class template basic_managed_shared_memory, 361, 363 Class template at_map_index, 334, 334 Class template iset_index, 335, 336 Class template iunordered_set_index, 337, 337 Class template map_index, 338, 339 Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 386 Class template unordered_map_index, 340, 341 shrink_to_t_indexes Class template segment_manager, 387, 390 Simple Lock Transfer unlock, 53 unlock_sharable, 53 simple_seq_t Class template simple_seq_t, 346, 373 size_type Class template adaptive_pool, 284 Class template allocator, 289 Class template basic_managed_external_buffer, 356 Class template basic_managed_heap_memory, 357 Class template basic_managed_windows_shared_memory, 364 Class template basic_managed_xsi_shared_memory, 366 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template iunordered_set_index, 337 Class template message_queue_t, 353 Class template node_allocator, 305 Class template private_adaptive_pool, 311
273
Boost.Interprocess
Class template private_node_allocator, 317 Class template rbtree_best_t, 371 Class template segment_manager, 387 Class template simple_seq_t, 373 Struct accept_ownership_type accept_ownership_type, 450 Struct create_only_t create_only_t, 325 Struct defer_lock_type defer_lock_type, 449 Struct mutex_family mutex_family, 451 mutex_type, 451 recursive_mutex_type, 451 Struct null_mutex_family mutex_type, 451 null_mutex_family, 451 recursive_mutex_type, 451 Struct open_copy_on_write_t open_copy_on_write_t, 326 Struct open_only_t open_only_t, 325 Struct open_or_create_t open_or_create_t, 326 Struct open_read_only_t open_read_only_t, 325 Struct open_read_private_t open_read_private_t, 326 Struct template allocator allocator, 392 type, 392 Struct template deleter deleter, 392 type, 392 Struct template at_map_index_aux allocator_type, 334 at_map_index_aux, 334 index_t, 334 key_less, 334 key_type, 334 mapped_type, 334 segment_manager_base, 334 value_type, 334 Struct template managed_shared_ptr deleter, 413 managed_shared_ptr, 413 type, 413 void_allocator, 413 Struct template managed_unique_ptr managed_unique_ptr, 419 type, 419 Struct template managed_weak_ptr managed_weak_ptr, 422 type, 422 Struct template rebind other, 287, 292, 298, 304, 309, 315, 320, 380 rebind, 287, 292, 298, 304, 309, 315, 320, 380 Struct try_to_lock_type
274
Boost.Interprocess
try_to_lock_type, 450 swap Class le_lock, 434, 435 Class le_mapping, 331, 332 Class mapped_region, 368, 369 Class shared_memory_object, 393, 394 Class template adaptive_pool, 284, 287 Class template allocator, 289, 292 Class template basic_managed_external_buffer, 356, 357 Class template basic_managed_heap_memory, 357, 358 Class template basic_managed_mapped_le, 359, 360 Class template basic_managed_shared_memory, 361, 362 Class template basic_managed_windows_shared_memory, 364, 365 Class template basic_managed_xsi_shared_memory, 366, 367 Class template cached_adaptive_pool, 294, 298 Class template cached_node_allocator, 300, 303 Class template intrusive_ptr, 399, 401 Class template node_allocator, 305, 308 Class template private_adaptive_pool, 311, 314 Class template private_node_allocator, 317, 320 Class template scoped_lock, 472, 475 Class template scoped_ptr, 405, 406 Class template sharable_lock, 476, 479 Class template shared_ptr, 410, 413 Class template unique_ptr, 415, 418 Class template upgradable_lock, 479, 482 Class template weak_ptr, 420, 422 Class windows_shared_memory, 483, 484 Class xsi_shared_memory, 486, 487 Function template swap, 403, 406 Header < boost/interprocess/smart_ptr/intrusive_ptr.hpp >, 397 Header < boost/interprocess/smart_ptr/scoped_ptr.hpp >, 404 Header < boost/interprocess/smart_ptr/shared_ptr.hpp >, 407 Header < boost/interprocess/smart_ptr/unique_ptr.hpp >, 414 Header < boost/interprocess/smart_ptr/weak_ptr.hpp >, 419 swap_vector Class template basic_vectorbuf, 428, 429 Class template basic_vectorstream, 432, 433 Class template std, 430, 431, 431 Formatting directly in your character vector: vectorstream, 124, 124 Synchronization guarantees allocate, 74
T
The memory algorithm mutex_family, 142 void_pointer, 142 The segment manager allocate, 143 timed_lock Class le_lock, 434, 435 Class interprocess_mutex, 439, 440 Class interprocess_recursive_mutex, 441, 441 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_mutex, 456, 457 Class named_recursive_mutex, 458, 459
275
Boost.Interprocess
Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 470, 470 Class template scoped_lock, 472, 474, 474 Class template sharable_lock, 476, 478 Class template upgradable_lock, 479, 481 Exclusive Locking (Sharable & Upgradable Mutexes), 47 File Locking Operations, 58 Mutex Operations, 32 timed_lock_sharable Class le_lock, 434, 435 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 470, 470 Class template sharable_lock, 478 File Locking Operations, 58 Sharable Lock And Upgradable Lock, 51 Sharable Locking (Sharable & Upgradable Mutexes), 48 timed_lock_upgradable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template upgradable_lock, 481 Sharable Lock And Upgradable Lock, 51 Upgradable Locking (Upgradable Mutex only), 48 timed_receive Class template message_queue_t, 353, 355 timed_send Class template message_queue_t, 353, 354 timed_unlock_upgradable_and_lock Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 468 Class null_mutex, 469, 471, 471 Class template scoped_lock, 474 Promotions (Upgradable Mutex only), 50 Transfers To Scoped Lock, 55 timed_wait Class interprocess_condition, 436, 437, 437 Class interprocess_condition_any, 438, 439, 439 Class interprocess_semaphore, 442, 443 Class named_condition, 452, 453, 453 Class named_condition_any, 454, 455, 456 Class named_semaphore, 460, 461 to_raw_pointer Function template to_raw_pointer, 404, 407 Header < boost/interprocess/smart_ptr/intrusive_ptr.hpp >, 397 Header < boost/interprocess/smart_ptr/scoped_ptr.hpp >, 404 Header < boost/interprocess/smart_ptr/shared_ptr.hpp >, 407 traits_type Class template basic_bufferbuf, 423 Class template basic_bufferstream, 427 Class template basic_ibufferstream, 424 Class template basic_obufferstream, 425 Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template std, 430
276
Boost.Interprocess
Formatting directly in your character buffer: bufferstream, 127 Formatting directly in your character vector: vectorstream, 124 Transferring Unlocked Locks assert, 56 unlock_and_lock_sharable, 56 Transfers To Scoped Lock timed_unlock_upgradable_and_lock, 55 try_unlock_sharable_and_lock, 55 try_unlock_upgradable_and_lock, 55 unlock_upgradable_and_lock, 55 Transfers To Sharable Lock unlock_and_lock_sharable, 56 unlock_upgradable_and_lock_sharable, 56 Transfers To Upgradable Lock try_unlock_sharable_and_lock_upgradable, 55 unlock_and_lock_upgradable, 55 truncate Class shared_memory_object, 393, 394 try_atomic_func Class template segment_manager, 387, 390 try_lock Class le_lock, 434, 435 Class interprocess_mutex, 439, 440 Class interprocess_recursive_mutex, 441, 441 Class interprocess_sharable_mutex, 444, 444 Class interprocess_upgradable_mutex, 446, 447 Class named_mutex, 456, 457 Class named_recursive_mutex, 458, 459 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 469, 469 Class template scoped_lock, 472, 474, 474 Class template sharable_lock, 476, 478 Class template upgradable_lock, 479, 481 Exclusive Locking (Sharable & Upgradable Mutexes), 47 File Locking Operations, 58 Global try_to_lock, 450 Mutex Operations, 32 try_lock_sharable Class le_lock, 434, 435 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 470, 470 Class template sharable_lock, 478 File Locking Operations, 58 Sharable Lock And Upgradable Lock, 51 Sharable Locking (Sharable & Upgradable Mutexes), 48 try_lock_upgradable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template upgradable_lock, 481 Sharable Lock And Upgradable Lock, 51 Upgradable Locking (Upgradable Mutex only), 48 try_receive Class template message_queue_t, 353, 355
277
Boost.Interprocess
try_send Class template message_queue_t, 353, 354 try_to_lock_type Struct try_to_lock_type, 450 try_unlock_sharable_and_lock Class interprocess_upgradable_mutex, 446, 449 Class named_upgradable_mutex, 465, 468 Class null_mutex, 469, 471, 471 Class template scoped_lock, 474 Promotions (Upgradable Mutex only), 50 Transfers To Scoped Lock, 55 try_unlock_sharable_and_lock_upgradable Class interprocess_upgradable_mutex, 446, 449 Class named_upgradable_mutex, 465, 468 Class null_mutex, 469, 471, 471 Class template upgradable_lock, 481 Promotions (Upgradable Mutex only), 50 Transfers To Upgradable Lock, 55 try_unlock_upgradable_and_lock Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 468 Class null_mutex, 469, 471, 471 Class template scoped_lock, 473 Promotions (Upgradable Mutex only), 50 Transfers To Scoped Lock, 55 try_wait Class interprocess_semaphore, 442, 443 Class named_semaphore, 460, 461 type Class template segment_manager, 387 Struct template allocator, 392 Struct template deleter, 392 Struct template managed_shared_ptr, 413 Struct template managed_unique_ptr, 419 Struct template managed_weak_ptr, 422
U
Unique pointer assert, 139 unique_ptr Class template unique_ptr, 415, 415, 416, 416 unlock Class le_lock, 434, 435 Class interprocess_mutex, 439, 440 Class interprocess_recursive_mutex, 441, 441 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_mutex, 456, 457 Class named_recursive_mutex, 458, 459 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 466 Class null_mutex, 469, 470, 470 Class template scoped_lock, 472, 474, 475, 475 Class template sharable_lock, 476, 478 Class template upgradable_lock, 479, 481 Exclusive Locking (Sharable & Upgradable Mutexes), 47 File Locking Operations, 58
278
Boost.Interprocess
Mutex Operations, 32 Scoped lock, 34 Simple Lock Transfer, 53 unlock_and_lock_sharable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template sharable_lock, 477 Demotions (Upgradable Mutex only), 49 Lock Transfers Through Move Semantics, 53 Scoped Lock and Sharable Lock With File Locking, 60 Transferring Unlocked Locks, 56 Transfers To Sharable Lock, 56 unlock_and_lock_upgradable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Demotions (Upgradable Mutex only), 49 Transfers To Upgradable Lock, 55 unlock_sharable Class le_lock, 434, 435 Class interprocess_sharable_mutex, 444, 445 Class interprocess_upgradable_mutex, 446, 447 Class named_sharable_mutex, 462, 463 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template sharable_lock, 477, 478 File Locking Operations, 58 Sharable Lock And Upgradable Lock, 51, 51 Sharable Locking (Sharable & Upgradable Mutexes), 48 Simple Lock Transfer, 53 unlock_upgradable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template upgradable_lock, 481, 481 Sharable Lock And Upgradable Lock, 51 Upgradable Locking (Upgradable Mutex only), 48 unlock_upgradable_and_lock Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 471, 471 Class template scoped_lock, 473 Promotions (Upgradable Mutex only), 50 Transfers To Scoped Lock, 55 unlock_upgradable_and_lock_sharable Class interprocess_upgradable_mutex, 446, 448 Class named_upgradable_mutex, 465, 467 Class null_mutex, 469, 470, 470 Class template sharable_lock, 477 Demotions (Upgradable Mutex only), 49 Transfers To Sharable Lock, 56 unordered_map_index_aux Class template unordered_map_index, 340 unspecied_bool_type Class template scoped_ptr, 405 Upgradable Locking (Upgradable Mutex only) lock_upgradable, 48
279
Boost.Interprocess
timed_lock_upgradable, 48 try_lock_upgradable, 48 unlock_upgradable, 48 upgradable_lock Class template upgradable_lock, 343, 479, 479, 480, 480, 481 Using shared memory as a pool of unnamed memory blocks if, 3
V
value_type Building custom indexes, 150 Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template iset_index, 335 Class template iunordered_set_index, 337 Class template node_allocator, 305 Class template offset_ptr, 376 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template shared_ptr, 410 Class template weak_ptr, 420 Struct template at_map_index_aux, 334 vector_type Class template basic_vectorbuf, 428 Class template basic_vectorstream, 432 Class template std, 430 Formatting directly in your character vector: vectorstream, 124 version Class template allocator, 289 void_allocator Containers of containers, 117 Struct template managed_shared_ptr, 413 void_pointer Class template adaptive_pool, 284 Class template allocator, 289 Class template cached_adaptive_pool, 294 Class template cached_node_allocator, 300 Class template message_queue_t, 353 Class template node_allocator, 305 Class template private_adaptive_pool, 311 Class template private_node_allocator, 317 Class template rbtree_best_t, 371 Class template segment_manager, 387 Class template segment_manager_base, 384 The memory algorithm, 142 Writing a new shared memory allocation algorithm, 148, 148, 148, 148
W
wait Class bad_alloc, 330 Class interprocess_condition, 436, 437, 437 Class interprocess_condition_any, 438, 438, 439 Class interprocess_semaphore, 442, 443 Class named_condition, 452, 453, 453 Class named_condition_any, 454, 455, 455
280
Boost.Interprocess
Class named_semaphore, 460, 461 wbufferbuf Header < boost/interprocess/streams/bufferstream.hpp >, 422 wbufferstream Formatting directly in your character buffer: bufferstream, 127 Header < boost/interprocess/streams/bufferstream.hpp >, 422 weak_ptr Class template weak_ptr, 409, 409, 420 wxed_managed_shared_memory Common Managed Shared Memory Classes, 67 Header < boost/interprocess/interprocess_fwd.hpp >, 341 What's A Message Queue? data, 62 What's a Sharable and an Upgradable Mutex? lock, 46 while Anonymous mutex example, 35, 35 Direct iostream formatting: vectorstream and bufferstream, 124 Example: Serializing a database through the message queue, 93 Multiple allocation functions, 81 wibufferstream Header < boost/interprocess/streams/bufferstream.hpp >, 422 windows_shared_memory Class windows_shared_memory, 483 wmanaged_external_buffer Header < boost/interprocess/interprocess_fwd.hpp >, 341 Managed External Buffer: Constructing all Boost.Interprocess objects in a user provided buffer, 88 wmanaged_heap_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 Managed Heap Memory: Boost.Interprocess machinery in heap memory, 91 wmanaged_mapped_le Common Managed Mapped Files, 70 Header < boost/interprocess/interprocess_fwd.hpp >, 341 wmanaged_shared_memory Common Managed Shared Memory Classes, 67 Header < boost/interprocess/interprocess_fwd.hpp >, 341 wmanaged_windows_shared_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 wmanaged_xsi_shared_memory Header < boost/interprocess/interprocess_fwd.hpp >, 341 wobufferstream Header < boost/interprocess/streams/bufferstream.hpp >, 422 Writing a new shared memory allocation algorithm allocate, 148, 149, 149, 149 deallocate, 148, 149 get_min_size, 148, 149 grow, 148, 149 mutex_family, 148, 148, 148, 148, 149 mutex_type, 148 recursive_mutex_type, 148 void_pointer, 148, 148, 148, 148
X
xsi_key Class xsi_key, 485 xsi_shared_memory Class xsi_shared_memory, 486
281
Boost.Interprocess
Z
zero_free_memory Class template rbtree_best_t, 371, 372 Class template segment_manager_base, 384, 386
282
Boost.Interprocess
Boost.Interprocess Reference
Header <boost/interprocess/allocators/adaptive_pool.hpp>
Describes adaptive_pool pooled shared memory STL compatible allocator
namespace boost { namespace interprocess { template<typename T, typename SegmentManager, std::size_t NodesPerBlock, std::size_t MaxFreeBlocks, unsigned char OverheadPercent> class adaptive_pool; template<typename T, typename S, std::size_t NodesPerBlock, std::size_t F, unsigned char OP> bool operator==(const adaptive_pool< T, S, NodesPerBlock, F, OP > &, const adaptive_pool< T, S, NodesPerBlock, F, OP > &); template<typename T, typename S, std::size_t NodesPerBlock, std::size_t F, unsigned char OP> bool operator!=(const adaptive_pool< T, S, NodesPerBlock, F, OP > &, const adaptive_pool< T, S, NodesPerBlock, F, OP > &); } }
283
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/allocators/adaptive_pool.hpp> template<typename T, typename SegmentManager, std::size_t NodesPerBlock, std::size_t MaxFreeBlocks, unsigned char OverheadPercent> class adaptive_pool { public: // types typedef implementation_defined::segment_manager segment_manager; typedef segment_manager::void_pointer void_pointer; typedef implementation_defined::pointer pointer; typedef implementation_defined::const_pointer const_pointer; typedef T value_type; typedef unspecified reference; typedef unspecified const_reference; typedef segment_manager::size_type size_type; typedef segment_manager::difference_type difference_type; // member classes/structs/unions template<typename T2> struct rebind { // types typedef adaptive_pool< T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent > oth er; }; // construct/copy/destruct adaptive_pool(segment_manager *); adaptive_pool(const adaptive_pool &); template<typename T2> adaptive_pool(const adaptive_pool< T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, Over headPercent > &); template<typename T2, typename SegmentManager2, std::size_t N2, std::size_t F2, unsigned char OP2> adaptive_pool& operator=(const adaptive_pool< T2, SegmentManager2, N2, F2, OP2 > &); ~adaptive_pool(); // public member functions void * get_node_pool() const; segment_manager * get_segment_manager() const; size_type max_size() const; pointer allocate(size_type, cvoid_pointer = 0); void deallocate(const pointer &, size_type); void deallocate_free_blocks(); pointer address(reference) const; const_pointer address(const_reference) const; size_type size(const pointer &) const; std::pair< pointer, bool > allocation_command(boost::interprocess::allocation_type, size_type, size_type, size_type &, const pointer & = 0); multiallocation_chain allocate_many(size_type, size_type); multiallocation_chain allocate_many(const size_type *, size_type); void deallocate_many(multiallocation_chain); pointer allocate_one(); multiallocation_chain allocate_individual(size_type);
284
Boost.Interprocess
void deallocate_one(const pointer &); void deallocate_individual(multiallocation_chain); // friend functions friend void swap(self_t &, self_t &); };
Description
An STL node allocator that uses a segment manager as memory source. The internal pointer type will of the same type (raw, smart) as "typename SegmentManager::void_pointer" type. This allows placing the allocator in shared memory, memory mapped-les, etc... This node allocator shares a segregated storage between all instances of adaptive_pool with equal sizeof(T) placed in the same segment group. NodesPerBlock is the number of nodes allocated at once when the allocator needs runs out of nodes. MaxFreeBlocks is the maximum number of totally free blocks that the adaptive node pool will hold. The rest of the totally free blocks will be deallocated with the segment manager. OverheadPercent is the (approximated) maximum size overhead (1-20%) of the allocator: (memory usable for nodes / total memory allocated from the segment manager)
adaptive_pool public construct/copy/destruct
1.
adaptive_pool(segment_manager * segment_mngr);
Not assignable from other adaptive_pool Constructor from a segment manager. If not present, constructs a node pool. Increments the reference count of the associated node pool. Can throw boost::interprocess::bad_alloc 2.
adaptive_pool(const adaptive_pool & other);
Copy constructor from other adaptive_pool. Increments the reference count of the associated node pool. Never throws 3.
template<typename T2> adaptive_pool(const adaptive_pool< T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, Over headPercent > & other);
Copy constructor from related adaptive_pool. If not present, constructs a node pool. Increments the reference count of the associated node pool. Can throw boost::interprocess::bad_alloc 4.
template<typename T2, typename SegmentManager2, std::size_t N2, std::size_t F2, unsigned char OP2> adaptive_pool& operator=(const adaptive_pool< T2, SegmentManager2, N2, F2, OP2 > &);
Destructor, removes node_pool_t from memory if its reference count reaches to zero. Never throws
adaptive_pool public member functions
1.
285
Boost.Interprocess
2.
Allocate memory for an array of count elements. Throws boost::interprocess::bad_alloc if there is no enough memory 5.
void deallocate(const pointer & ptr, size_type count);
Returns maximum the number of objects the previously allocated memory pointed by p can hold. This size only works for memory allocated with allocate, allocation_command and allocate_many. 10.
std::pair< pointer, bool > allocation_command(boost::interprocess::allocation_type command, size_type limit_size, size_type preferred_size, size_type & received_size, const pointer & reuse = 0);
11.
Allocates many elements of size elem_size in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. The elements must be deallocated with deallocate(...) 12.
multiallocation_chain allocate_many(const size_type * elem_sizes, size_type n_elements);
Allocates n_elements elements, each one of size elem_sizes[i]in a contiguous block of memory. The elements must be deallocated
286
Boost.Interprocess
13.
Allocates many elements of size elem_size in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. The elements must be deallocated with deallocate(...) 14.
pointer allocate_one();
Allocates just one object. Memory allocated with this function must be deallocated only with deallocate_one(). Throws boost::interprocess::bad_alloc if there is no enough memory 15.
multiallocation_chain allocate_individual(size_type num_elements);
Allocates many elements of size == 1 in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. Memory allocated with this function must be deallocated only with deallocate_one(). 16.
void deallocate_one(const pointer & p);
Deallocates memory previously allocated with allocate_one(). You should never use deallocate_one to deallocate memory allocated with other functions different from allocate_one(). Never throws 17.
void deallocate_individual(multiallocation_chain it);
Allocates many elements of size == 1 in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. Memory allocated with this function must be deallocated only with deallocate_one().
adaptive_pool friend functions
1.
Swaps allocators. Does not throw. If each allocator is placed in a different memory segment, the result is undened.
Synopsis
// In header: <boost/interprocess/allocators/adaptive_pool.hpp>
template<typename T2> struct rebind { // types typedef adaptive_pool< T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent > other; };
Description
Obtains adaptive_pool from adaptive_pool
287
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/allocators/adaptive_pool.hpp>
template<typename T, typename S, std::size_t NodesPerBlock, std::size_t F, unsigned char OP> bool operator==(const adaptive_pool< T, S, NodesPerBlock, F, OP > & alloc1, const adaptive_pool< T, S, NodesPerBlock, F, OP > & alloc2);
Description
Equality test for same type of adaptive_pool
Synopsis
// In header: <boost/interprocess/allocators/adaptive_pool.hpp>
template<typename T, typename S, std::size_t NodesPerBlock, std::size_t F, unsigned char OP> bool operator!=(const adaptive_pool< T, S, NodesPerBlock, F, OP > & alloc1, const adaptive_pool< T, S, NodesPerBlock, F, OP > & alloc2);
Description
Inequality test for same type of adaptive_pool
Header <boost/interprocess/allocators/allocator.hpp>
Describes an allocator that allocates portions of xed size memory buffer (shared memory, mapped le...)
namespace boost { namespace interprocess { template<typename T, typename SegmentManager> class allocator; template<typename T, typename SegmentManager> bool operator==(const allocator< T, SegmentManager > &, const allocator< T, SegmentManager > &); template<typename T, typename SegmentManager> bool operator!=(const allocator< T, SegmentManager > &, const allocator< T, SegmentManager > &); } }
288
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/allocators/allocator.hpp> template<typename T, typename SegmentManager> class allocator { public: // types typedef SegmentManager segment_manager; typedef SegmentManager::void_pointer void_pointer; typedef T value_type; typedef boost::intrusive::pointer_traits< cvoid_ptr >::template rebind_pointer< T >::type pointer; typedef boost::intrusive::pointer_traits< pointer >::template rebind_point er< const T >::type const_pointer; typedef unspecified reference; typedef unspecified const_reference; typedef segment_manager::size_type size_type; typedef segment_manager::difference_type difference_type; typedef boost::interprocess::version_type< allocator, 2 > version; // member classes/structs/unions template<typename T2> struct rebind { // types typedef allocator< T2, SegmentManager > other; }; // construct/copy/destruct allocator(segment_manager *); allocator(const allocator &); template<typename T2> allocator(const allocator< T2, SegmentManager > &); // public member functions segment_manager * get_segment_manager() const; pointer allocate(size_type, cvoid_ptr = 0); void deallocate(const pointer &, size_type); size_type max_size() const; size_type size(const pointer &) const; std::pair< pointer, bool > allocation_command(boost::interprocess::allocation_type, size_type, size_type, size_type &, const pointer & = 0); multiallocation_chain allocate_many(size_type, size_type); multiallocation_chain allocate_many(const size_type *, size_type); void deallocate_many(multiallocation_chain); pointer allocate_one(); multiallocation_chain allocate_individual(size_type); void deallocate_one(const pointer &); void deallocate_individual(multiallocation_chain); pointer address(reference) const; const_pointer address(const_reference) const;
289
Boost.Interprocess
template<typename P> void construct(const pointer &, P &&); void destroy(const pointer &); // friend functions friend void swap(self_t &, self_t &); };
Description
An STL compatible allocator that uses a segment manager as memory source. The internal pointer type will of the same type (raw, smart) as "typename SegmentManager::void_pointer" type. This allows placing the allocator in shared memory, memory mappedles, etc...
allocator public construct/copy/destruct
1.
allocator(segment_manager * segment_mngr);
1.
Allocates memory for an array of count elements. Throws boost::interprocess::bad_alloc if there is no enough memory 3.
void deallocate(const pointer & ptr, size_type);
Returns maximum the number of objects the previously allocated memory pointed by p can hold. This size only works for memory allocated with allocate, allocation_command and allocate_many.
290
Boost.Interprocess
6.
std::pair< pointer, bool > allocation_command(boost::interprocess::allocation_type command, size_type limit_size, size_type preferred_size, size_type & received_size, const pointer & reuse = 0);
7.
Allocates many elements of size elem_size in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. The elements must be deallocated with deallocate(...) 8.
multiallocation_chain allocate_many(const size_type * elem_sizes, size_type n_elements);
Allocates n_elements elements, each one of size elem_sizes[i]in a contiguous block of memory. The elements must be deallocated 9.
void deallocate_many(multiallocation_chain chain);
Allocates many elements of size elem_size in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. The elements must be deallocated with deallocate(...) 10.
pointer allocate_one();
Allocates just one object. Memory allocated with this function must be deallocated only with deallocate_one(). Throws boost::interprocess::bad_alloc if there is no enough memory 11.
multiallocation_chain allocate_individual(size_type num_elements);
Allocates many elements of size == 1 in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. Memory allocated with this function must be deallocated only with deallocate_one(). 12.
void deallocate_one(const pointer & p);
Deallocates memory previously allocated with allocate_one(). You should never use deallocate_one to deallocate memory allocated with other functions different from allocate_one(). Never throws 13.
void deallocate_individual(multiallocation_chain chain);
Allocates many elements of size == 1 in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. Memory allocated with this function must be deallocated only with deallocate_one(). 14.
pointer address(reference value) const;
291
Boost.Interprocess
Constructs an object Throws if T's constructor throws For backwards compatibility with libraries using C++03 allocators 17.
void destroy(const pointer & ptr);
1.
Swap segment manager. Does not throw. If each allocator is placed in different memory segments, the result is undened.
Synopsis
// In header: <boost/interprocess/allocators/allocator.hpp>
template<typename T2> struct rebind { // types typedef allocator< T2, SegmentManager > other; };
Description
Obtains an allocator that allocates objects of type T2
Synopsis
// In header: <boost/interprocess/allocators/allocator.hpp>
template<typename T, typename SegmentManager> bool operator==(const allocator< T, SegmentManager > & alloc1, const allocator< T, SegmentManager > & alloc2);
Description
Equality test for same type of allocator
292
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/allocators/allocator.hpp>
template<typename T, typename SegmentManager> bool operator!=(const allocator< T, SegmentManager > & alloc1, const allocator< T, SegmentManager > & alloc2);
Description
Inequality test for same type of allocator
Header <boost/interprocess/allocators/cached_adaptive_pool.hpp>
Describes cached_adaptive_pool pooled shared memory STL compatible allocator
namespace boost { namespace interprocess { template<typename T, typename SegmentManager, std::size_t NodesPerBlock, std::size_t MaxFreeBlocks, unsigned char OverheadPercent> class cached_adaptive_pool; template<typename T, typename S, std::size_t NodesPerBlock, std::size_t F, std::size_t OP> bool operator==(const cached_adaptive_pool< T, S, NodesPerBlock, F, OP > const cached_adaptive_pool< T, S, NodesPerBlock, F, OP > template<typename T, typename S, std::size_t NodesPerBlock, std::size_t F, std::size_t OP> bool operator!=(const cached_adaptive_pool< T, S, NodesPerBlock, F, OP > const cached_adaptive_pool< T, S, NodesPerBlock, F, OP > } }
&, &);
&, &);
293
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/allocators/cached_adaptive_pool.hpp> template<typename T, typename SegmentManager, std::size_t NodesPerBlock, std::size_t MaxFreeBlocks, unsigned char OverheadPercent> class cached_adaptive_pool { public: // types typedef implementation_defined::segment_manager segment_manager; typedef segment_manager::void_pointer void_pointer; typedef implementation_defined::pointer pointer; typedef implementation_defined::const_pointer const_pointer; typedef T value_type; typedef unspecified reference; typedef unspecified const_reference; typedef segment_manager::size_type size_type; typedef segment_manager::difference_type difference_type; // member classes/structs/unions template<typename T2> struct rebind { // types typedef cached_adaptive_pool< T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPer cent > other; }; // construct/copy/destruct cached_adaptive_pool(segment_manager *); cached_adaptive_pool(const cached_adaptive_pool &); template<typename T2> cached_adaptive_pool(const cached_adaptive_pool< T2, SegmentManager, NodesPerBlock, MaxFreeB locks, OverheadPercent > &); template<typename T2, typename SegmentManager2, std::size_t N2, std::size_t F2, unsigned char OP2> cached_adaptive_pool& operator=(const cached_adaptive_pool< T2, SegmentManager2, N2, F2, OP2 > &); cached_adaptive_pool& operator=(const cached_adaptive_pool &); ~cached_adaptive_pool(); // public member functions node_pool_t * get_node_pool() const; segment_manager * get_segment_manager() const; size_type max_size() const; pointer allocate(size_type, cvoid_pointer = 0); void deallocate(const pointer &, size_type); void deallocate_free_blocks(); pointer address(reference) const; const_pointer address(const_reference) const; void construct(const pointer &, const_reference); void destroy(const pointer &); size_type size(const pointer &) const; std::pair< pointer, bool > allocation_command(boost::interprocess::allocation_type, size_type, size_type, size_type &, const pointer & = 0); multiallocation_chain allocate_many(size_type, size_type); multiallocation_chain allocate_many(const size_type *, size_type); void deallocate_many(multiallocation_chain); pointer allocate_one(); multiallocation_chain allocate_individual(size_type); void deallocate_one(const pointer &); void deallocate_individual(multiallocation_chain);
294
Boost.Interprocess
void set_max_cached_nodes(size_type); size_type get_max_cached_nodes() const; // friend functions friend void swap(self_t &, self_t &); };
Description
An STL node allocator that uses a segment manager as memory source. The internal pointer type will of the same type (raw, smart) as "typename SegmentManager::void_pointer" type. This allows placing the allocator in shared memory, memory mapped-les, etc... This node allocator shares a segregated storage between all instances of cached_adaptive_pool with equal sizeof(T) placed in the same memory segment. But also caches some nodes privately to avoid some synchronization overhead. NodesPerBlock is the minimum number of nodes of nodes allocated at once when the allocator needs runs out of nodes. MaxFreeBlocks is the maximum number of totally free blocks that the adaptive node pool will hold. The rest of the totally free blocks will be deallocated with the segment manager. OverheadPercent is the (approximated) maximum size overhead (1-20%) of the allocator: (memory usable for nodes / total memory allocated from the segment manager)
cached_adaptive_pool public construct/copy/destruct
1.
cached_adaptive_pool(segment_manager * segment_mngr);
Constructor from a segment manager. If not present, constructs a node pool. Increments the reference count of the associated node pool. Can throw boost::interprocess::bad_alloc 2.
cached_adaptive_pool(const cached_adaptive_pool & other);
Copy constructor from other cached_adaptive_pool. Increments the reference count of the associated node pool. Never throws 3.
template<typename T2> cached_adaptive_pool(const cached_adaptive_pool< T2, SegmentManager, NodesPerBlock, MaxFreeB locks, OverheadPercent > & other);
Copy constructor from related cached_adaptive_pool. If not present, constructs a node pool. Increments the reference count of the associated node pool. Can throw boost::interprocess::bad_alloc 4.
template<typename T2, typename SegmentManager2, std::size_t N2, std::size_t F2, unsigned char OP2> cached_adaptive_pool& operator=(const cached_adaptive_pool< T2, SegmentManager2, N2, F2, OP2 > &);
Destructor, removes node_pool_t from memory if its reference count reaches to zero. Never throws
295
Boost.Interprocess
1.
Allocate memory for an array of count elements. Throws boost::interprocess::bad_alloc if there is no enough memory 5.
void deallocate(const pointer & ptr, size_type count);
Returns maximum the number of objects the previously allocated memory pointed by p can hold. This size only works for memory allocated with allocate, allocation_command and allocate_many.
296
Boost.Interprocess
12.
std::pair< pointer, bool > allocation_command(boost::interprocess::allocation_type command, size_type limit_size, size_type preferred_size, size_type & received_size, const pointer & reuse = 0);
13.
Allocates many elements of size elem_size in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. The elements must be deallocated with deallocate(...) 14.
multiallocation_chain allocate_many(const size_type * elem_sizes, size_type n_elements);
Allocates n_elements elements, each one of size elem_sizes[i]in a contiguous block of memory. The elements must be deallocated 15.
void deallocate_many(multiallocation_chain chain);
Allocates many elements of size elem_size in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. The elements must be deallocated with deallocate(...) 16.
pointer allocate_one();
Allocates just one object. Memory allocated with this function must be deallocated only with deallocate_one(). Throws boost::interprocess::bad_alloc if there is no enough memory 17.
multiallocation_chain allocate_individual(size_type num_elements);
Allocates many elements of size == 1 in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. Memory allocated with this function must be deallocated only with deallocate_one(). 18.
void deallocate_one(const pointer & p);
Deallocates memory previously allocated with allocate_one(). You should never use deallocate_one to deallocate memory allocated with other functions different from allocate_one(). Never throws 19.
void deallocate_individual(multiallocation_chain chain);
Allocates many elements of size == 1 in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. Memory allocated with this function must be deallocated only with deallocate_one(). 20.
void set_max_cached_nodes(size_type newmax);
Sets the new max cached nodes value. This can provoke deallocations if "newmax" is less than current cached nodes. Never throws 21.
size_type get_max_cached_nodes() const;
297
Boost.Interprocess
1.
Swaps allocators. Does not throw. If each allocator is placed in a different memory segment, the result is undened.
Synopsis
// In header: <boost/interprocess/allocators/cached_adaptive_pool.hpp>
template<typename T2> struct rebind { // types typedef cached_adaptive_pool< T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPer cent > other; };
Description
Obtains cached_adaptive_pool from cached_adaptive_pool
Synopsis
// In header: <boost/interprocess/allocators/cached_adaptive_pool.hpp>
template<typename T, typename S, std::size_t NodesPerBlock, std::size_t F, std::size_t OP> bool operator==(const cached_adaptive_pool< T, S, NodesPerBlock, F, OP > & alloc1, const cached_adaptive_pool< T, S, NodesPerBlock, F, OP > & alloc2);
Description
Equality test for same type of cached_adaptive_pool
298
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/allocators/cached_adaptive_pool.hpp>
template<typename T, typename S, std::size_t NodesPerBlock, std::size_t F, std::size_t OP> bool operator!=(const cached_adaptive_pool< T, S, NodesPerBlock, F, OP > & alloc1, const cached_adaptive_pool< T, S, NodesPerBlock, F, OP > & alloc2);
Description
Inequality test for same type of cached_adaptive_pool
Header <boost/interprocess/allocators/cached_node_allocator.hpp>
Describes cached_cached_node_allocator pooled shared memory STL compatible allocator
namespace boost { namespace interprocess { template<typename T, typename SegmentManager, std::size_t NodesPerBlock> class cached_node_allocator; template<typename T, typename S, std::size_t NPC> bool operator==(const cached_node_allocator< T, S, NPC > &, const cached_node_allocator< T, S, NPC > &); template<typename T, typename S, std::size_t NPC> bool operator!=(const cached_node_allocator< T, S, NPC > &, const cached_node_allocator< T, S, NPC > &); } }
299
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/allocators/cached_node_allocator.hpp> template<typename T, typename SegmentManager, std::size_t NodesPerBlock> class cached_node_allocator { public: // types typedef implementation_defined::segment_manager segment_manager; typedef segment_manager::void_pointer void_pointer; typedef implementation_defined::pointer pointer; typedef implementation_defined::const_pointer const_pointer; typedef T value_type; typedef unspecified reference; typedef unspecified const_reference; typedef SegmentManager::size_type size_type; typedef SegmentManager::difference_type difference_type; // member classes/structs/unions template<typename T2> struct rebind { // types typedef cached_node_allocator< T2, SegmentManager > other; }; // construct/copy/destruct cached_node_allocator(segment_manager *); cached_node_allocator(const cached_node_allocator &); template<typename T2> cached_node_allocator(const cached_node_allocator< T2, SegmentManager, NodesPerBlock > &); template<typename T2, typename SegmentManager2, std::size_t N2> cached_node_allocator& operator=(const cached_node_allocator< T2, SegmentManager2, N2 > &); cached_node_allocator& operator=(const cached_node_allocator &); ~cached_node_allocator(); // public member functions node_pool_t * get_node_pool() const; segment_manager * get_segment_manager() const; size_type max_size() const; pointer allocate(size_type, cvoid_pointer = 0); void deallocate(const pointer &, size_type); void deallocate_free_blocks(); pointer address(reference) const; const_pointer address(const_reference) const; void construct(const pointer &, const_reference); void destroy(const pointer &); size_type size(const pointer &) const; std::pair< pointer, bool > allocation_command(boost::interprocess::allocation_type, size_type, size_type, size_type &, const pointer & = 0); multiallocation_chain allocate_many(size_type, size_type); multiallocation_chain allocate_many(const size_type *, size_type); void deallocate_many(multiallocation_chain); pointer allocate_one(); multiallocation_chain allocate_individual(size_type); void deallocate_one(const pointer &); void deallocate_individual(multiallocation_chain);
300
Boost.Interprocess
void set_max_cached_nodes(size_type); size_type get_max_cached_nodes() const; // friend functions friend void swap(self_t &, self_t &); };
Description
cached_node_allocator public construct/copy/destruct
1.
cached_node_allocator(segment_manager * segment_mngr);
Constructor from a segment manager. If not present, constructs a node pool. Increments the reference count of the associated node pool. Can throw boost::interprocess::bad_alloc 2.
cached_node_allocator(const cached_node_allocator & other);
Copy constructor from other cached_node_allocator. Increments the reference count of the associated node pool. Never throws 3.
template<typename T2> cached_node_allocator(const cached_node_allocator< T2, SegmentManager, NodesPerBlock > & other);
Copy constructor from related cached_node_allocator. If not present, constructs a node pool. Increments the reference count of the associated node pool. Can throw boost::interprocess::bad_alloc 4.
template<typename T2, typename SegmentManager2, std::size_t N2> cached_node_allocator& operator=(const cached_node_allocator< T2, SegmentManager2, N2 > &);
Destructor, removes node_pool_t from memory if its reference count reaches to zero. Never throws
cached_node_allocator public member functions
1.
301
Boost.Interprocess
3.
Allocate memory for an array of count elements. Throws boost::interprocess::bad_alloc if there is no enough memory 5.
void deallocate(const pointer & ptr, size_type count);
Returns maximum the number of objects the previously allocated memory pointed by p can hold. This size only works for memory allocated with allocate, allocation_command and allocate_many. 12.
std::pair< pointer, bool > allocation_command(boost::interprocess::allocation_type command, size_type limit_size, size_type preferred_size, size_type & received_size, const pointer & reuse = 0);
13.
Allocates many elements of size elem_size in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. The elements must be deallocated with deallocate(...)
302
Boost.Interprocess
14.
Allocates n_elements elements, each one of size elem_sizes[i]in a contiguous block of memory. The elements must be deallocated 15.
void deallocate_many(multiallocation_chain chain);
Allocates many elements of size elem_size in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. The elements must be deallocated with deallocate(...) 16.
pointer allocate_one();
Allocates just one object. Memory allocated with this function must be deallocated only with deallocate_one(). Throws boost::interprocess::bad_alloc if there is no enough memory 17.
multiallocation_chain allocate_individual(size_type num_elements);
Allocates many elements of size == 1 in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. Memory allocated with this function must be deallocated only with deallocate_one(). 18.
void deallocate_one(const pointer & p);
Deallocates memory previously allocated with allocate_one(). You should never use deallocate_one to deallocate memory allocated with other functions different from allocate_one(). Never throws 19.
void deallocate_individual(multiallocation_chain it);
Allocates many elements of size == 1 in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. Memory allocated with this function must be deallocated only with deallocate_one(). 20.
void set_max_cached_nodes(size_type newmax);
Sets the new max cached nodes value. This can provoke deallocations if "newmax" is less than current cached nodes. Never throws 21.
size_type get_max_cached_nodes() const;
1.
Swaps allocators. Does not throw. If each allocator is placed in a different memory segment, the result is undened.
303
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/allocators/cached_node_allocator.hpp>
template<typename T2> struct rebind { // types typedef cached_node_allocator< T2, SegmentManager > other; };
Description
Obtains cached_node_allocator from cached_node_allocator
Synopsis
// In header: <boost/interprocess/allocators/cached_node_allocator.hpp>
template<typename T, typename S, std::size_t NPC> bool operator==(const cached_node_allocator< T, S, NPC > & alloc1, const cached_node_allocator< T, S, NPC > & alloc2);
Description
Equality test for same type of cached_node_allocator
Synopsis
// In header: <boost/interprocess/allocators/cached_node_allocator.hpp>
template<typename T, typename S, std::size_t NPC> bool operator!=(const cached_node_allocator< T, S, NPC > & alloc1, const cached_node_allocator< T, S, NPC > & alloc2);
Description
Inequality test for same type of cached_node_allocator
Header <boost/interprocess/allocators/node_allocator.hpp>
Describes node_allocator pooled shared memory STL compatible allocator
304
Boost.Interprocess
namespace boost { namespace interprocess { template<typename T, typename SegmentManager, std::size_t NodesPerBlock> class node_allocator; template<typename T, typename S, std::size_t NPC> bool operator==(const node_allocator< T, S, NPC > &, const node_allocator< T, S, NPC > &); template<typename T, typename S, std::size_t NPC> bool operator!=(const node_allocator< T, S, NPC > &, const node_allocator< T, S, NPC > &); } }
Synopsis
// In header: <boost/interprocess/allocators/node_allocator.hpp> template<typename T, typename SegmentManager, std::size_t NodesPerBlock> class node_allocator { public: // types typedef implementation_defined::segment_manager segment_manager; typedef segment_manager::void_pointer void_pointer; typedef implementation_defined::pointer pointer; typedef implementation_defined::const_pointer const_pointer; typedef T value_type; typedef unspecified reference; typedef unspecified const_reference; typedef segment_manager::size_type size_type; typedef segment_manager::difference_type difference_type; // member classes/structs/unions template<typename T2> struct rebind { // types typedef node_allocator< T2, SegmentManager, NodesPerBlock > other; }; // construct/copy/destruct node_allocator(segment_manager *); node_allocator(const node_allocator &); template<typename T2> node_allocator(const node_allocator< T2, SegmentManager, NodesPerBlock > &); template<typename T2, typename SegmentManager2, std::size_t N2> node_allocator& operator=(const node_allocator< T2, SegmentManager2, N2 > &); ~node_allocator(); // public member functions void * get_node_pool() const; segment_manager * get_segment_manager() const; size_type max_size() const; pointer allocate(size_type, cvoid_pointer = 0); void deallocate(const pointer &, size_type); void deallocate_free_blocks(); pointer address(reference) const;
305
Boost.Interprocess
const_pointer address(const_reference) const; void construct(const pointer &, const_reference); void destroy(const pointer &); size_type size(const pointer &) const; std::pair< pointer, bool > allocation_command(boost::interprocess::allocation_type, size_type, size_type, size_type &, const pointer & = 0); multiallocation_chain allocate_many(size_type, size_type); multiallocation_chain allocate_many(const size_type *, size_type); void deallocate_many(multiallocation_chain); pointer allocate_one(); multiallocation_chain allocate_individual(size_type); void deallocate_one(const pointer &); void deallocate_individual(multiallocation_chain); // friend functions friend void swap(self_t &, self_t &); };
Description
An STL node allocator that uses a segment manager as memory source. The internal pointer type will of the same type (raw, smart) as "typename SegmentManager::void_pointer" type. This allows placing the allocator in shared memory, memory mapped-les, etc... This node allocator shares a segregated storage between all instances of node_allocator with equal sizeof(T) placed in the same segment group. NodesPerBlock is the number of nodes allocated at once when the allocator needs runs out of nodes
node_allocator public construct/copy/destruct
1.
node_allocator(segment_manager * segment_mngr);
Not assignable from other node_allocator Constructor from a segment manager. If not present, constructs a node pool. Increments the reference count of the associated node pool. Can throw boost::interprocess::bad_alloc 2.
node_allocator(const node_allocator & other);
Copy constructor from other node_allocator. Increments the reference count of the associated node pool. Never throws 3.
template<typename T2> node_allocator(const node_allocator< T2, SegmentManager, NodesPerBlock > & other);
Copy constructor from related node_allocator. If not present, constructs a node pool. Increments the reference count of the associated node pool. Can throw boost::interprocess::bad_alloc 4.
template<typename T2, typename SegmentManager2, std::size_t N2> node_allocator& operator=(const node_allocator< T2, SegmentManager2, N2 > &);
Destructor, removes node_pool_t from memory if its reference count reaches to zero. Never throws
node_allocator public member functions
1.
306
Boost.Interprocess
Allocate memory for an array of count elements. Throws boost::interprocess::bad_alloc if there is no enough memory 5.
void deallocate(const pointer & ptr, size_type count);
Returns maximum the number of objects the previously allocated memory pointed by p can hold. This size only works for memory allocated with allocate, allocation_command and allocate_many. 12.
std::pair< pointer, bool > allocation_command(boost::interprocess::allocation_type command, size_type limit_size, size_type preferred_size, size_type & received_size, const pointer & reuse = 0);
13.
307
Boost.Interprocess
Allocates many elements of size elem_size in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. The elements must be deallocated with deallocate(...) 14.
multiallocation_chain allocate_many(const size_type * elem_sizes, size_type n_elements);
Allocates n_elements elements, each one of size elem_sizes[i]in a contiguous block of memory. The elements must be deallocated 15.
void deallocate_many(multiallocation_chain chain);
Allocates many elements of size elem_size in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. The elements must be deallocated with deallocate(...) 16.
pointer allocate_one();
Allocates just one object. Memory allocated with this function must be deallocated only with deallocate_one(). Throws boost::interprocess::bad_alloc if there is no enough memory 17.
multiallocation_chain allocate_individual(size_type num_elements);
Allocates many elements of size == 1 in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. Memory allocated with this function must be deallocated only with deallocate_one(). 18.
void deallocate_one(const pointer & p);
Deallocates memory previously allocated with allocate_one(). You should never use deallocate_one to deallocate memory allocated with other functions different from allocate_one(). Never throws 19.
void deallocate_individual(multiallocation_chain chain);
Allocates many elements of size == 1 in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. Memory allocated with this function must be deallocated only with deallocate_one().
node_allocator friend functions
1.
Swaps allocators. Does not throw. If each allocator is placed in a different memory segment, the result is undened.
308
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/allocators/node_allocator.hpp>
template<typename T2> struct rebind { // types typedef node_allocator< T2, SegmentManager, NodesPerBlock > other; };
Description
Obtains node_allocator from node_allocator
Synopsis
// In header: <boost/interprocess/allocators/node_allocator.hpp>
template<typename T, typename S, std::size_t NPC> bool operator==(const node_allocator< T, S, NPC > & alloc1, const node_allocator< T, S, NPC > & alloc2);
Description
Equality test for same type of node_allocator
Synopsis
// In header: <boost/interprocess/allocators/node_allocator.hpp>
template<typename T, typename S, std::size_t NPC> bool operator!=(const node_allocator< T, S, NPC > & alloc1, const node_allocator< T, S, NPC > & alloc2);
Description
Inequality test for same type of node_allocator
Header <boost/interprocess/allocators/private_adaptive_pool.hpp>
Describes private_adaptive_pool_base pooled shared memory STL compatible allocator
309
Boost.Interprocess
namespace boost { namespace interprocess { template<typename T, typename SegmentManager, std::size_t NodesPerBlock, std::size_t MaxFreeBlocks, unsigned char OverheadPercent> class private_adaptive_pool; template<typename T, typename S, std::size_t NodesPerBlock, std::size_t F, unsigned char OP> bool operator==(const private_adaptive_pool< T, S, NodesPerBlock, F, OP > const private_adaptive_pool< T, S, NodesPerBlock, F, OP > template<typename T, typename S, std::size_t NodesPerBlock, std::size_t F, unsigned char OP> bool operator!=(const private_adaptive_pool< T, S, NodesPerBlock, F, OP > const private_adaptive_pool< T, S, NodesPerBlock, F, OP > } }
&, &);
&, &);
310
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/allocators/private_adaptive_pool.hpp> template<typename T, typename SegmentManager, std::size_t NodesPerBlock, std::size_t MaxFreeBlocks, unsigned char OverheadPercent> class private_adaptive_pool { public: // types typedef implementation_defined::segment_manager segment_manager; typedef segment_manager::void_pointer void_pointer; typedef implementation_defined::pointer pointer; typedef implementation_defined::const_pointer const_pointer; typedef T value_type; typedef unspecified reference; typedef unspecified const_reference; typedef segment_manager::size_type size_type; typedef segment_manager::difference_type difference_type; // member classes/structs/unions template<typename T2> struct rebind { // types typedef private_adaptive_pool< T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPer cent > other; }; // construct/copy/destruct private_adaptive_pool(segment_manager *); private_adaptive_pool(const private_adaptive_pool &); template<typename T2> private_adaptive_pool(const private_adaptive_pool< T2, SegmentManager, NodesPerBlock, Max FreeBlocks, OverheadPercent > &); template<typename T2, typename SegmentManager2, std::size_t N2, std::size_t F2, unsigned char OP2> private_adaptive_pool& operator=(const private_adaptive_pool< T2, SegmentManager2, N2, F2 > &); private_adaptive_pool& operator=(const private_adaptive_pool &); ~private_adaptive_pool(); // public member functions node_pool_t * get_node_pool() const; segment_manager * get_segment_manager() const; size_type max_size() const; pointer allocate(size_type, cvoid_pointer = 0); void deallocate(const pointer &, size_type); void deallocate_free_blocks(); pointer address(reference) const; const_pointer address(const_reference) const; void construct(const pointer &, const_reference); void destroy(const pointer &); size_type size(const pointer &) const; std::pair< pointer, bool > allocation_command(boost::interprocess::allocation_type, size_type, size_type, size_type &, const pointer & = 0); multiallocation_chain allocate_many(size_type, size_type); multiallocation_chain allocate_many(const size_type *, size_type); void deallocate_many(multiallocation_chain); pointer allocate_one(); multiallocation_chain allocate_individual(size_type);
311
Boost.Interprocess
void deallocate_one(const pointer &); void deallocate_individual(multiallocation_chain); // friend functions friend void swap(self_t &, self_t &); };
Description
An STL node allocator that uses a segment manager as memory source. The internal pointer type will of the same type (raw, smart) as "typename SegmentManager::void_pointer" type. This allows placing the allocator in shared memory, memory mapped-les, etc... This allocator has its own node pool. NodesPerBlock is the minimum number of nodes of nodes allocated at once when the allocator needs runs out of nodes. MaxFreeBlocks is the maximum number of totally free blocks that the adaptive node pool will hold. The rest of the totally free blocks will be deallocated with the segment manager. OverheadPercent is the (approximated) maximum size overhead (1-20%) of the allocator: (memory usable for nodes / total memory allocated from the segment manager)
private_adaptive_pool public construct/copy/destruct
1.
private_adaptive_pool(segment_manager * segment_mngr);
Constructor from a segment manager. If not present, constructs a node pool. Increments the reference count of the associated node pool. Can throw boost::interprocess::bad_alloc 2.
private_adaptive_pool(const private_adaptive_pool & other);
Copy constructor from other private_adaptive_pool. Increments the reference count of the associated node pool. Never throws 3.
template<typename T2> private_adaptive_pool(const private_adaptive_pool< T2, SegmentManager, NodesPerBlock, Max FreeBlocks, OverheadPercent > & other);
Copy constructor from related private_adaptive_pool. If not present, constructs a node pool. Increments the reference count of the associated node pool. Can throw boost::interprocess::bad_alloc 4.
template<typename T2, typename SegmentManager2, std::size_t N2, std::size_t F2, unsigned char OP2> private_adaptive_pool& operator=(const private_adaptive_pool< T2, SegmentManager2, N2, F2 > &);
Destructor, removes node_pool_t from memory if its reference count reaches to zero. Never throws
312
Boost.Interprocess
1.
Allocate memory for an array of count elements. Throws boost::interprocess::bad_alloc if there is no enough memory 5.
void deallocate(const pointer & ptr, size_type count);
Returns maximum the number of objects the previously allocated memory pointed by p can hold. This size only works for memory allocated with allocate, allocation_command and allocate_many.
313
Boost.Interprocess
12.
std::pair< pointer, bool > allocation_command(boost::interprocess::allocation_type command, size_type limit_size, size_type preferred_size, size_type & received_size, const pointer & reuse = 0);
13.
Allocates many elements of size elem_size in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. The elements must be deallocated with deallocate(...) 14.
multiallocation_chain allocate_many(const size_type * elem_sizes, size_type n_elements);
Allocates n_elements elements, each one of size elem_sizes[i]in a contiguous block of memory. The elements must be deallocated 15.
void deallocate_many(multiallocation_chain chain);
Allocates many elements of size elem_size in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. The elements must be deallocated with deallocate(...) 16.
pointer allocate_one();
Allocates just one object. Memory allocated with this function must be deallocated only with deallocate_one(). Throws boost::interprocess::bad_alloc if there is no enough memory 17.
multiallocation_chain allocate_individual(size_type num_elements);
Allocates many elements of size == 1 in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. Memory allocated with this function must be deallocated only with deallocate_one(). 18.
void deallocate_one(const pointer & p);
Deallocates memory previously allocated with allocate_one(). You should never use deallocate_one to deallocate memory allocated with other functions different from allocate_one(). Never throws 19.
void deallocate_individual(multiallocation_chain chain);
Allocates many elements of size == 1 in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. Memory allocated with this function must be deallocated only with deallocate_one().
private_adaptive_pool friend functions
1.
Swaps allocators. Does not throw. If each allocator is placed in a different memory segment, the result is undened.
314
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/allocators/private_adaptive_pool.hpp>
template<typename T2> struct rebind { // types typedef private_adaptive_pool< T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPer cent > other; };
Description
Obtains private_adaptive_pool from private_adaptive_pool
Synopsis
// In header: <boost/interprocess/allocators/private_adaptive_pool.hpp>
template<typename T, typename S, std::size_t NodesPerBlock, std::size_t F, unsigned char OP> bool operator==(const private_adaptive_pool< T, S, NodesPerBlock, F, OP > & alloc1, const private_adaptive_pool< T, S, NodesPerBlock, F, OP > & alloc2);
Description
Equality test for same type of private_adaptive_pool
Synopsis
// In header: <boost/interprocess/allocators/private_adaptive_pool.hpp>
template<typename T, typename S, std::size_t NodesPerBlock, std::size_t F, unsigned char OP> bool operator!=(const private_adaptive_pool< T, S, NodesPerBlock, F, OP > & alloc1, const private_adaptive_pool< T, S, NodesPerBlock, F, OP > & alloc2);
Description
Inequality test for same type of private_adaptive_pool
315
Boost.Interprocess
Header <boost/interprocess/allocators/private_node_allocator.hpp>
Describes private_node_allocator_base pooled shared memory STL compatible allocator
namespace boost { namespace interprocess { template<typename T, typename SegmentManager, std::size_t NodesPerBlock> class private_node_allocator; template<typename T, typename S, std::size_t NodesPerBlock, std::size_t F, unsigned char OP> bool operator==(const private_node_allocator< T, S, NodesPerBlock, F, OP const private_node_allocator< T, S, NodesPerBlock, F, OP template<typename T, typename S, std::size_t NodesPerBlock, std::size_t F, unsigned char OP> bool operator!=(const private_node_allocator< T, S, NodesPerBlock, F, OP const private_node_allocator< T, S, NodesPerBlock, F, OP } }
316
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/allocators/private_node_allocator.hpp> template<typename T, typename SegmentManager, std::size_t NodesPerBlock> class private_node_allocator { public: // types typedef implementation_defined::segment_manager segment_manager; typedef segment_manager::void_pointer void_pointer; typedef implementation_defined::pointer pointer; typedef implementation_defined::const_pointer const_pointer; typedef T value_type; typedef unspecified reference; typedef unspecified const_reference; typedef segment_manager::size_type size_type; typedef segment_manage::difference_type difference_type; // member classes/structs/unions template<typename T2> struct rebind { // types typedef private_node_allocator< T2, SegmentManager, NodesPerBlock > other; }; // construct/copy/destruct private_node_allocator(segment_manager *); private_node_allocator(const private_node_allocator &); template<typename T2> private_node_allocator(const private_node_allocator< T2, SegmentManager, NodesPerBlock > &); template<typename T2, typename SegmentManager2, std::size_t N2> private_node_allocator& operator=(const private_node_allocator< T2, SegmentManager2, N2 > &); private_node_allocator& operator=(const private_node_allocator &); ~private_node_allocator(); // public member functions node_pool_t * get_node_pool() const; segment_manager * get_segment_manager() const; size_type max_size() const; pointer allocate(size_type, cvoid_pointer = 0); void deallocate(const pointer &, size_type); void deallocate_free_blocks(); pointer address(reference) const; const_pointer address(const_reference) const; void construct(const pointer &, const_reference); void destroy(const pointer &); size_type size(const pointer &) const; std::pair< pointer, bool > allocation_command(boost::interprocess::allocation_type, size_type, size_type, size_type &, const pointer & = 0); multiallocation_chain allocate_many(size_type, size_type); multiallocation_chain allocate_many(const size_type *, size_type); void deallocate_many(multiallocation_chain); pointer allocate_one(); multiallocation_chain allocate_individual(size_type); void deallocate_one(const pointer &); void deallocate_individual(multiallocation_chain); // friend functions friend void swap(self_t &, self_t &); };
317
Boost.Interprocess
Description
An STL node allocator that uses a segment manager as memory source. The internal pointer type will of the same type (raw, smart) as "typename SegmentManager::void_pointer" type. This allows placing the allocator in shared memory, memory mapped-les, etc... This allocator has its own node pool. NodesPerBlock is the number of nodes allocated at once when the allocator needs runs out of nodes
private_node_allocator public construct/copy/destruct
1.
private_node_allocator(segment_manager * segment_mngr);
Constructor from a segment manager. If not present, constructs a node pool. Increments the reference count of the associated node pool. Can throw boost::interprocess::bad_alloc 2.
private_node_allocator(const private_node_allocator & other);
Copy constructor from other private_node_allocator. Increments the reference count of the associated node pool. Never throws 3.
template<typename T2> private_node_allocator(const private_node_allocator< T2, SegmentManager, NodesPerBlock > & other);
Copy constructor from related private_node_allocator. If not present, constructs a node pool. Increments the reference count of the associated node pool. Can throw boost::interprocess::bad_alloc 4.
template<typename T2, typename SegmentManager2, std::size_t N2> private_node_allocator& operator=(const private_node_allocator< T2, SegmentManager2, N2 > &);
Destructor, removes node_pool_t from memory if its reference count reaches to zero. Never throws
private_node_allocator public member functions
1.
318
Boost.Interprocess
4.
Allocate memory for an array of count elements. Throws boost::interprocess::bad_alloc if there is no enough memory 5.
void deallocate(const pointer & ptr, size_type count);
Returns maximum the number of objects the previously allocated memory pointed by p can hold. This size only works for memory allocated with allocate, allocation_command and allocate_many. 12.
std::pair< pointer, bool > allocation_command(boost::interprocess::allocation_type command, size_type limit_size, size_type preferred_size, size_type & received_size, const pointer & reuse = 0);
13.
Allocates many elements of size elem_size in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. The elements must be deallocated with deallocate(...) 14.
multiallocation_chain allocate_many(const size_type * elem_sizes, size_type n_elements);
Allocates n_elements elements, each one of size elem_sizes[i]in a contiguous block of memory. The elements must be deallocated
319
Boost.Interprocess
15.
Allocates many elements of size elem_size in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. The elements must be deallocated with deallocate(...) 16.
pointer allocate_one();
Allocates just one object. Memory allocated with this function must be deallocated only with deallocate_one(). Throws boost::interprocess::bad_alloc if there is no enough memory 17.
multiallocation_chain allocate_individual(size_type num_elements);
Allocates many elements of size == 1 in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. Memory allocated with this function must be deallocated only with deallocate_one(). 18.
void deallocate_one(const pointer & p);
Deallocates memory previously allocated with allocate_one(). You should never use deallocate_one to deallocate memory allocated with other functions different from allocate_one(). Never throws 19.
void deallocate_individual(multiallocation_chain chain);
Allocates many elements of size == 1 in a contiguous block of memory. The minimum number to be allocated is min_elements, the preferred and maximum number is preferred_elements. The number of actually allocated elements is will be assigned to received_size. Memory allocated with this function must be deallocated only with deallocate_one().
private_node_allocator friend functions
1.
Swaps allocators. Does not throw. If each allocator is placed in a different memory segment, the result is undened.
Synopsis
// In header: <boost/interprocess/allocators/private_node_allocator.hpp>
template<typename T2> struct rebind { // types typedef private_node_allocator< T2, SegmentManager, NodesPerBlock > other; };
Description
Obtains private_node_allocator from private_node_allocator
320
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/allocators/private_node_allocator.hpp>
template<typename T, typename S, std::size_t NodesPerBlock, std::size_t F, unsigned char OP> bool operator==(const private_node_allocator< T, S, NodesPerBlock, F, OP > & alloc1, const private_node_allocator< T, S, NodesPerBlock, F, OP > & alloc2);
Description
Equality test for same type of private_node_allocator
Synopsis
// In header: <boost/interprocess/allocators/private_node_allocator.hpp>
template<typename T, typename S, std::size_t NodesPerBlock, std::size_t F, unsigned char OP> bool operator!=(const private_node_allocator< T, S, NodesPerBlock, F, OP > & alloc1, const private_node_allocator< T, S, NodesPerBlock, F, OP > & alloc2);
Description
Inequality test for same type of private_node_allocator
Header <boost/interprocess/anonymous_shared_memory.hpp>
Describes a function that creates anonymous shared memory that can be shared between forked processes
namespace boost { namespace interprocess { mapped_region anonymous_shared_memory(std::size_t, void * = 0); } }
Function anonymous_shared_memory
boost::interprocess::anonymous_shared_memory
321
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/anonymous_shared_memory.hpp>
Description
A function that creates an anonymous shared memory segment of size "size". If "address" is passed the function will try to map the segment in that address. Otherwise the operating system will choose the mapping address. The function returns a mapped_region holding that segment or throws interprocess_exception if the function fails.
Header <boost/interprocess/containers/allocation_type.hpp>
Global allocate_new
boost::interprocess::allocate_new
Synopsis
// In header: <boost/interprocess/containers/allocation_type.hpp> static const allocation_type allocate_new;
Global expand_fwd
boost::interprocess::expand_fwd
Synopsis
// In header: <boost/interprocess/containers/allocation_type.hpp> static const allocation_type expand_fwd;
Global expand_bwd
boost::interprocess::expand_bwd
Synopsis
// In header: <boost/interprocess/containers/allocation_type.hpp> static const allocation_type expand_bwd;
Global shrink_in_place
boost::interprocess::shrink_in_place
322
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/containers/allocation_type.hpp> static const allocation_type shrink_in_place;
Global try_shrink_in_place
boost::interprocess::try_shrink_in_place
Synopsis
// In header: <boost/interprocess/containers/allocation_type.hpp> static const allocation_type try_shrink_in_place;
Global nothrow_allocation
boost::interprocess::nothrow_allocation
Synopsis
// In header: <boost/interprocess/containers/allocation_type.hpp> static const allocation_type nothrow_allocation;
Global zero_memory
boost::interprocess::zero_memory
Synopsis
// In header: <boost/interprocess/containers/allocation_type.hpp> static const allocation_type zero_memory;
323
Boost.Interprocess
Header <boost/interprocess/containers/deque.hpp> Header <boost/interprocess/containers/flat_map.hpp> Header <boost/interprocess/containers/flat_set.hpp> Header <boost/interprocess/containers/list.hpp> Header <boost/interprocess/containers/map.hpp> Header <boost/interprocess/containers/pair.hpp> Header <boost/interprocess/containers/set.hpp> Header <boost/interprocess/containers/slist.hpp> Header <boost/interprocess/containers/stable_vector.hpp> Header <boost/interprocess/containers/string.hpp> Header <boost/interprocess/containers/vector.hpp> Header <boost/interprocess/containers/version_type.hpp> Header <boost/interprocess/creation_tags.hpp>
namespace boost { namespace interprocess { struct create_only_t; struct open_only_t; struct open_read_only_t; struct open_read_private_t; struct open_copy_on_write_t; struct open_or_create_t; static static static static static } } const const const const const create_only_t create_only; open_only_t open_only; open_read_only_t open_read_only; open_or_create_t open_or_create; open_copy_on_write_t open_copy_on_write;
Struct create_only_t
boost::interprocess::create_only_t
324
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/creation_tags.hpp>
struct create_only_t { };
Description
Tag to indicate that the resource must be only created
Struct open_only_t
boost::interprocess::open_only_t
Synopsis
// In header: <boost/interprocess/creation_tags.hpp>
struct open_only_t { };
Description
Tag to indicate that the resource must be only opened
Struct open_read_only_t
boost::interprocess::open_read_only_t
Synopsis
// In header: <boost/interprocess/creation_tags.hpp>
struct open_read_only_t { };
Description
Tag to indicate that the resource must be only opened for reading
Struct open_read_private_t
boost::interprocess::open_read_private_t
325
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/creation_tags.hpp>
struct open_read_private_t { };
Description
Tag to indicate that the resource must be only opened privately for reading
Struct open_copy_on_write_t
boost::interprocess::open_copy_on_write_t
Synopsis
// In header: <boost/interprocess/creation_tags.hpp>
struct open_copy_on_write_t { };
Description
Tag to indicate that the resource must be only opened for reading
Struct open_or_create_t
boost::interprocess::open_or_create_t
Synopsis
// In header: <boost/interprocess/creation_tags.hpp>
struct open_or_create_t { };
Description
Tag to indicate that the resource must be created. If already created, it must be opened.
Global create_only
boost::interprocess::create_only
326
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/creation_tags.hpp> static const create_only_t create_only;
Description
Value to indicate that the resource must be only created
Global open_only
boost::interprocess::open_only
Synopsis
// In header: <boost/interprocess/creation_tags.hpp> static const open_only_t open_only;
Description
Value to indicate that the resource must be only opened
Global open_read_only
boost::interprocess::open_read_only
Synopsis
// In header: <boost/interprocess/creation_tags.hpp> static const open_read_only_t open_read_only;
Description
Value to indicate that the resource must be only opened for reading
Global open_or_create
boost::interprocess::open_or_create
Synopsis
// In header: <boost/interprocess/creation_tags.hpp> static const open_or_create_t open_or_create;
Description
Value to indicate that the resource must be created. If already created, it must be opened.
327
Boost.Interprocess
Global open_copy_on_write
boost::interprocess::open_copy_on_write
Synopsis
// In header: <boost/interprocess/creation_tags.hpp> static const open_copy_on_write_t open_copy_on_write;
Description
Value to indicate that the resource must be only opened for reading
Header <boost/interprocess/errors.hpp>
Describes the error numbering of interprocess classes
namespace boost { namespace interprocess { enum error_code_t { no_error = = 0, system_error, other_error, security_error, read_only_error, io_error, path_error, not_found_error, busy_error, already_exists_error, not_empty_error, is_directory_error, out_of_space_error, out_of_memory_error, out_of_resource_error, lock_error, sem_error, mode_error, size_error, corrupted_error, not_such_file_or_directory, invalid_argument, timeout_when_locking_error, timeout_when_waiting_error }; typedef int native_error_t; } }
Header <boost/interprocess/exceptions.hpp>
Describes exceptions thrown by interprocess classes
namespace boost { namespace interprocess { class interprocess_exception; class lock_exception; class bad_alloc; } }
Class interprocess_exception
boost::interprocess::interprocess_exception
328
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/exceptions.hpp>
class interprocess_exception : public exception { public: // construct/copy/destruct interprocess_exception(const char *); interprocess_exception(const error_info &, const char * = 0); ~interprocess_exception(); // public member functions const char * what() const; native_error_t get_native_error() const; error_code_t get_error_code() const; };
Description
This class is the base class of all exceptions thrown by boost::interprocess
interprocess_exception public construct/copy/destruct
1.
2.
3.
~interprocess_exception();
1.
2.
3.
Class lock_exception
boost::interprocess::lock_exception
329
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/exceptions.hpp>
class lock_exception : public boost::interprocess::interprocess_exception { public: // construct/copy/destruct lock_exception(); // public member functions const char * what() const; };
Description
This is the exception thrown by shared interprocess_mutex family when a deadlock situation is detected or when using a interprocess_condition the interprocess_mutex is not locked
lock_exception public construct/copy/destruct
1.
lock_exception();
1.
Class bad_alloc
boost::interprocess::bad_alloc
Synopsis
// In header: <boost/interprocess/exceptions.hpp>
class bad_alloc : public boost::interprocess::interprocess_exception { public: // construct/copy/destruct bad_alloc(); // public member functions const char * what() const; };
Description
This is the exception thrown by named interprocess_semaphore when a deadlock situation is detected or when an error is detected in the post/wait operation This is the exception thrown by synchronization objects when there is an error in a wait() function This exception is thrown when a named object is created in "open_only" mode and the resource was not already created This exception is thrown when a memory request can't be fullled.
330
Boost.Interprocess
1.
bad_alloc();
1.
Header <boost/interprocess/file_mapping.hpp>
Describes le_mapping and mapped region classes
namespace boost { namespace interprocess { class file_mapping; class remove_file_on_destroy; } }
Class file_mapping
boost::interprocess::le_mapping
Synopsis
// In header: <boost/interprocess/file_mapping.hpp>
class file_mapping { public: // construct/copy/destruct file_mapping(); file_mapping(const char *, mode_t); file_mapping(file_mapping &&); file_mapping& operator=(file_mapping &&); ~file_mapping(); // public member functions void swap(file_mapping &); mode_t get_mode() const; mapping_handle_t get_mapping_handle() const; const char * get_name() const; // public static functions static bool remove(const char *); };
Description
A class that wraps a le-mapping that can be used to create mapped regions from the mapped les
file_mapping public construct/copy/destruct
1.
file_mapping();
331
Boost.Interprocess
Opens a le mapping of le "lename", starting in offset "le_offset", and the mapping's size will be "size". The mapping can be opened for read-only "read_only" or read-write "read_write" modes. Throws interprocess_exception on error. 3.
file_mapping(file_mapping && moved);
Moves the ownership of "moved"'s le mapping object to *this. After the call, "moved" does not represent any le mapping object. Does not throw 4.
file_mapping& operator=(file_mapping && moved);
Moves the ownership of "moved"'s le mapping to *this. After the call, "moved" does not represent any le mapping. Does not throw 5.
~file_mapping();
Destroys the le mapping. All mapped regions created from this are still valid. Does not throw
file_mapping public member functions
1.
1.
Removes the le named "lename" even if it's been memory mapped. Returns true on success. The function might fail in some operating systems if the le is being used other processes and no deletion permission was shared.
Class remove_file_on_destroy
boost::interprocess::remove_le_on_destroy
332
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/file_mapping.hpp>
Description
A class that stores the name of a le and tries to remove it in its destructor Useful to remove temporary les in the presence of exceptions
remove_file_on_destroy public construct/copy/destruct
1.
2.
~remove_file_on_destroy();
Header <boost/interprocess/indexes/flat_map_index.hpp>
Describes index adaptor of boost::map container, to use it as name/shared memory index
namespace boost { namespace interprocess { template<typename MapConfig> struct flat_map_index_aux; template<typename MapConfig> class flat_map_index; } }
333
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/indexes/flat_map_index.hpp> template<typename MapConfig> struct flat_map_index_aux { // types typedef MapConfig::key_type typedef MapConfig::mapped_type typedef MapConfig::segment_manager_base typedef std::less< key_type > typedef std::pair< key_type, mapped_type > typedef allocator< value_type,segment_manager_base > typedef flat_map< key_type, mapped_type, key_less, allocator_type > };
Synopsis
// In header: <boost/interprocess/indexes/flat_map_index.hpp> template<typename MapConfig> class flat_map_index : public boost::container::flat_map< MapConfig > { public: // construct/copy/destruct flat_map_index(segment_manager_base *); // public member functions void reserve(typename segment_manager_base::size_type); void shrink_to_fit(); };
Description
Index type based in at_map. Just derives from at_map and denes the interface needed by managed memory segments.
flat_map_index public construct/copy/destruct
1.
flat_map_index(segment_manager_base * segment_mngr);
1.
334
Boost.Interprocess
Header <boost/interprocess/indexes/iset_index.hpp>
Describes index adaptor of boost::intrusive::set container, to use it as name/shared memory index
namespace boost { namespace interprocess { template<typename MapConfig> class iset_index; } }
Synopsis
// In header: <boost/interprocess/indexes/iset_index.hpp> template<typename MapConfig> class iset_index : public iset_index_aux::index_t< MapConfig > { public: // types typedef index_type::iterator iterator; typedef index_type::const_iterator const_iterator; typedef index_type::insert_commit_data insert_commit_data; typedef index_type::value_type value_type; // construct/copy/destruct iset_index(typename MapConfig::segment_manager_base *); // public member functions void reserve(typename MapConfig::segment_manager_base::size_type); void shrink_to_fit(); iterator find(const intrusive_compare_key_type &); const_iterator find(const intrusive_compare_key_type &) const; std::pair< iterator, bool > insert_check(const intrusive_compare_key_type &, insert_commit_data &); };
Description
Index type based in boost::intrusive::set. Just derives from boost::intrusive::set and denes the interface needed by managed memory segments
iset_index public construct/copy/destruct
1.
1.
335
Boost.Interprocess
2.
void shrink_to_fit();
4.
5.
std::pair< iterator, bool > insert_check(const intrusive_compare_key_type & key, insert_commit_data & commit_data);
Header <boost/interprocess/indexes/iunordered_set_index.hpp>
Describes index adaptor of boost::intrusive::unordered_set container, to use it as name/shared memory index
namespace boost { namespace interprocess { template<typename MapConfig> class iunordered_set_index; } }
336
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/indexes/iunordered_set_index.hpp> template<typename MapConfig> class iunordered_set_index : private iunordered_set_index_aux::allocator_holder< MapConfig >, public iunordered_set_index_aux::index_t< MapConfig > { public: // types typedef index_type::iterator iterator; typedef index_type::const_iterator const_iterator; typedef index_type::insert_commit_data insert_commit_data; typedef index_type::value_type value_type; typedef index_type::bucket_ptr bucket_ptr; typedef index_type::bucket_type bucket_type; typedef index_type::bucket_traits bucket_traits; typedef index_type::size_type size_type; // construct/copy/destruct iunordered_set_index(segment_manager_base *); ~iunordered_set_index(); // public member functions void reserve(size_type); void shrink_to_fit(); iterator find(const intrusive_compare_key_type &); const_iterator find(const intrusive_compare_key_type &) const; std::pair< iterator, bool > insert_check(const intrusive_compare_key_type &, insert_commit_data &); iterator insert_commit(value_type &, insert_commit_data &); };
Description
Index type based in boost::intrusive::set. Just derives from boost::intrusive::set and denes the interface needed by managed memory segments
iunordered_set_index public construct/copy/destruct
1.
iunordered_set_index(segment_manager_base * mngr);
1.
337
Boost.Interprocess
3.
4.
5.
std::pair< iterator, bool > insert_check(const intrusive_compare_key_type & key, insert_commit_data & commit_data);
6.
Header <boost/interprocess/indexes/map_index.hpp>
Describes index adaptor of boost::map container, to use it as name/shared memory index
namespace boost { namespace interprocess { template<typename MapConfig> class map_index; } }
Synopsis
// In header: <boost/interprocess/indexes/map_index.hpp> template<typename MapConfig> class map_index : public boost::container::map< MapConfig > { public: // construct/copy/destruct map_index(segment_manager_base *); // public member functions void reserve(typename segment_manager_base::size_type); void shrink_to_fit(); };
Description
Index type based in boost::interprocess::map. Just derives from boost::interprocess::map and denes the interface needed by managed memory segments
map_index public construct/copy/destruct
1.
map_index(segment_manager_base * segment_mngr);
338
Boost.Interprocess
1.
Header <boost/interprocess/indexes/null_index.hpp>
Describes a null index adaptor, so that if we don't want to construct named objects, we can use this null index type to save resources.
namespace boost { namespace interprocess { template<typename MapConfig> class null_index; } }
Synopsis
// In header: <boost/interprocess/indexes/null_index.hpp> template<typename MapConfig> class null_index { public: // types typedef void * iterator; typedef const void * const_iterator; // construct/copy/destruct null_index(segment_manager_base *); // public member functions const_iterator begin() const; iterator begin(); const_iterator end() const; iterator end(); };
Description
Null index type used to save compilation time when named indexes are not needed.
null_index public construct/copy/destruct
1.
null_index(segment_manager_base *);
Empty constructor.
339
Boost.Interprocess
1.
Header <boost/interprocess/indexes/unordered_map_index.hpp>
Describes index adaptor of boost::unordered_map container, to use it as name/shared memory index
namespace boost { namespace interprocess { template<typename MapConfig> class unordered_map_index; } }
Synopsis
// In header: <boost/interprocess/indexes/unordered_map_index.hpp> template<typename MapConfig> class unordered_map_index : public unordered_map_index_aux::index_t< MapConfig > { public: // construct/copy/destruct unordered_map_index(segment_manager_base *); // public member functions void reserve(typename segment_manager_base::size_type); void shrink_to_fit(); };
Description
Index type based in unordered_map. Just derives from unordered_map and denes the interface needed by managed memory segments
340
Boost.Interprocess
1.
unordered_map_index(segment_manager_base * segment_mngr);
1.
Header <boost/interprocess/interprocess_fwd.hpp>
template<typename Mutex> class scoped_lock; template<typename SharableMutex> class sharable_lock; template<typename UpgradableMutex> class upgradable_lock; template<typename T, typename SegmentManager> class allocator; template<typename T, typename SegmentManager, std::size_t NodesPerBlock class node_allocator; template<typename T, typename SegmentManager, std::size_t NodesPerBlock class private_node_allocator; template<typename T, typename SegmentManager, std::size_t NodesPerBlock class cached_node_allocator; template<typename T, typename SegmentManager, std::size_t NodesPerBlock std::size_t MaxFreeBlocks = 2, unsigned char OverheadPercent = class adaptive_pool; template<typename T, typename SegmentManager, std::size_t NodesPerBlock std::size_t MaxFreeBlocks = 2, unsigned char OverheadPercent = class private_adaptive_pool; template<typename T, typename SegmentManager, std::size_t NodesPerBlock std::size_t MaxFreeBlocks = 2, unsigned char OverheadPercent = class cached_adaptive_pool; template<typename T, typename DifferenceType = std::ptrdiff_t, typename OffsetType = std::size_t, std::size_t Alignment = offset_type_alignment> class offset_ptr; template<typename MutexFamily, typename VoidMutex = offset_ptr<void> > class simple_seq_fit; template<typename MutexFamily, typename VoidMutex = offset_ptr<void>, std::size_t MemAlignment = 0> class rbtree_best_fit; template<typename IndexConfig> class flat_map_index; template<typename IndexConfig> class iset_index; template<typename IndexConfig> class iunordered_set_index; template<typename IndexConfig> class map_index; template<typename IndexConfig> class null_index; template<typename IndexConfig> class unordered_map_index; template<typename CharType, typename MemoryAlgorithm, template< class IndexConfig > class IndexType> class segment_manager; template<typename CharType, typename MemoryAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_external_buffer;
341
Boost.Interprocess
template<typename CharType, typename MemoryAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_shared_memory; template<typename CharType, typename MemoryAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_windows_shared_memory; template<typename CharType, typename MemoryAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_xsi_shared_memory; template<typename CharType, typename MemoryAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_heap_memory; template<typename CharType, typename MemoryAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_mapped_file; template<typename CharT, typename CharTraits = std::char_traits<CharT> > class basic_bufferbuf; template<typename CharT, typename CharTraits = std::char_traits<CharT> > class basic_ibufferstream; template<typename CharT, typename CharTraits = std::char_traits<CharT> > class basic_obufferstream; template<typename CharT, typename CharTraits = std::char_traits<CharT> > class basic_bufferstream; template<typename CharVector, typename CharTraits = std::char_traits<typename CharVector::value_type> > class basic_vectorbuf; template<typename CharVector, typename CharTraits = std::char_traits<typename CharVector::value_type> > class basic_ivectorstream; template<typename CharVector, typename CharTraits = std::char_traits<typename CharVector::value_type> > class basic_ovectorstream; template<typename CharVector, typename CharTraits = std::char_traits<typename CharVector::value_type> > class basic_vectorstream; template<typename T, typename Deleter> class scoped_ptr; template<typename T, typename VoidPointer> class intrusive_ptr; template<typename T, typename VoidAllocator, typename Deleter> class shared_ptr; template<typename VoidPointer> class message_queue_t;namespace boost { namespace interprocess { typedef basic_managed_external_buffer< char,rbtree_best_fit< null_mutex_family >,iset_in dex > managed_external_buffer; typedef basic_managed_external_buffer< wchar_t,rbtree_best_fit< null_mutex_family >,iset_in dex > wmanaged_external_buffer; typedef basic_managed_shared_memory< char,rbtree_best_fit< mutex_family >,iset_index > man aged_shared_memory; typedef basic_managed_shared_memory< wchar_t,rbtree_best_fit< mutex_family >,iset_index > wman aged_shared_memory; typedef basic_managed_windows_shared_memory< char,rbtree_best_fit< mutex_family >,iset_in dex > managed_windows_shared_memory; typedef basic_managed_windows_shared_memory< wchar_t,rbtree_best_fit< mutex_family >,iset_in dex > wmanaged_windows_shared_memory; typedef basic_managed_xsi_shared_memory< char,rbtree_best_fit< mutex_family >,iset_index > man aged_xsi_shared_memory; typedef basic_managed_xsi_shared_memory< wchar_t,rbtree_best_fit< mutex_family >,iset_in dex > wmanaged_xsi_shared_memory; typedef basic_managed_shared_memory< char,rbtree_best_fit< mutex_family, void * >,iset_in dex > fixed_managed_shared_memory; typedef basic_managed_shared_memory< wchar_t,rbtree_best_fit< mutex_family, void * >,iset_in dex > wfixed_managed_shared_memory; typedef basic_managed_heap_memory< char,rbtree_best_fit< null_mutex_family >,iset_index > man aged_heap_memory;
342
Boost.Interprocess
typedef basic_managed_heap_memory< wchar_t,rbtree_best_fit< null_mutex_family >,iset_in dex > wmanaged_heap_memory; typedef basic_managed_mapped_file< char,rbtree_best_fit< mutex_family >,iset_index > man aged_mapped_file; typedef basic_managed_mapped_file< wchar_t,rbtree_best_fit< mutex_family >,iset_index > wman aged_mapped_file; typedef message_queue_t< offset_ptr< void > > message_queue; static const std::size_t offset_type_alignment; } }
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename Mutex> class scoped_lock { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename SharableMutex> class sharable_lock { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename UpgradableMutex> class upgradable_lock { };
343
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename T, typename SegmentManager> class allocator { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename T, typename SegmentManager, std::size_t NodesPerBlock = 64> class node_allocator { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename T, typename SegmentManager, std::size_t NodesPerBlock = 64> class private_node_allocator { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename T, typename SegmentManager, std::size_t NodesPerBlock = 64> class cached_node_allocator { };
344
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename T, typename SegmentManager, std::size_t NodesPerBlock = 64, std::size_t MaxFreeBlocks = 2, unsigned char OverheadPercent = 5> class adaptive_pool { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename T, typename SegmentManager, std::size_t NodesPerBlock = 64, std::size_t MaxFreeBlocks = 2, unsigned char OverheadPercent = 5> class private_adaptive_pool { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename T, typename SegmentManager, std::size_t NodesPerBlock = 64, std::size_t MaxFreeBlocks = 2, unsigned char OverheadPercent = 5> class cached_adaptive_pool { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename T, typename DifferenceType = std::ptrdiff_t, typename OffsetType = std::size_t, std::size_t Alignment = offset_type_alignment> class offset_ptr { };
345
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename MutexFamily, typename VoidMutex = offset_ptr<void> > class simple_seq_fit { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename MutexFamily, typename VoidMutex = offset_ptr<void>, std::size_t MemAlignment = 0> class rbtree_best_fit { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename IndexConfig> class flat_map_index { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename IndexConfig> class iset_index { };
346
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename IndexConfig> class iunordered_set_index { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename IndexConfig> class map_index { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename IndexConfig> class null_index { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename IndexConfig> class unordered_map_index { };
347
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename CharType, typename MemoryAlgorithm, template< class IndexConfig > class IndexType> class segment_manager { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename CharType, typename MemoryAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_external_buffer { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename CharType, typename MemoryAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_shared_memory { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename CharType, typename MemoryAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_windows_shared_memory { };
348
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename CharType, typename MemoryAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_xsi_shared_memory { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename CharType, typename MemoryAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_heap_memory { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename CharType, typename MemoryAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_mapped_file { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename CharT, typename CharTraits = std::char_traits<CharT> > class basic_bufferbuf { };
349
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename CharT, typename CharTraits = std::char_traits<CharT> > class basic_ibufferstream { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename CharT, typename CharTraits = std::char_traits<CharT> > class basic_obufferstream { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename CharT, typename CharTraits = std::char_traits<CharT> > class basic_bufferstream { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename CharVector, typename CharTraits = std::char_traits<typename CharVector::value_type> > class basic_vectorbuf { };
350
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename CharVector, typename CharTraits = std::char_traits<typename CharVector::value_type> > class basic_ivectorstream { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename CharVector, typename CharTraits = std::char_traits<typename CharVector::value_type> > class basic_ovectorstream { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename CharVector, typename CharTraits = std::char_traits<typename CharVector::value_type> > class basic_vectorstream { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename T, typename Deleter> class scoped_ptr { };
351
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename T, typename VoidPointer> class intrusive_ptr { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename T, typename VoidAllocator, typename Deleter> class shared_ptr { };
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> template<typename VoidPointer> class message_queue_t { };
Global offset_type_alignment
boost::interprocess::offset_type_alignment
Synopsis
// In header: <boost/interprocess/interprocess_fwd.hpp> static const std::size_t offset_type_alignment;
Header <boost/interprocess/ipc/message_queue.hpp>
Describes an inter-process message queue. This class allows sending messages between processes and allows blocking, non-blocking and timed sending and receiving.
352
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/ipc/message_queue.hpp> template<typename VoidPointer> class message_queue_t { public: // types typedef VoidPointer void_pointer; typedef boost::intrusive::pointer_traits< void_pointer >::template rebind_point er< char >::type char_ptr; typedef boost::intrusive::pointer_traits< char_ptr >::difference_type difference_type; typedef boost::make_unsigned< difference_type >::type size_type; // construct/copy/destruct message_queue_t(create_only_t, const char *, size_type, size_type, const permissions & = permissions()); message_queue_t(open_or_create_t, const char *, size_type, size_type, const permissions & = permissions()); message_queue_t(open_only_t, const char *); ~message_queue_t(); // public member functions void send(const void *, size_type, unsigned int); bool try_send(const void *, size_type, unsigned int); bool timed_send(const void *, size_type, unsigned int, const boost::posix_time::ptime &); void receive(void *, size_type, size_type &, unsigned int &); bool try_receive(void *, size_type, size_type &, unsigned int &); bool timed_receive(void *, size_type, size_type &, unsigned int &, const boost::posix_time::ptime &); size_type get_max_msg() const; size_type get_max_msg_size() const; size_type get_num_msg(); // public static functions static bool remove(const char *); };
Description
A class that allows sending messages between processes.
353
Boost.Interprocess
1.
message_queue_t(create_only_t create_only, const char * name, size_type max_num_msg, size_type max_msg_size, const permissions & perm = permissions());
Creates a process shared message queue with name "name". For this message queue, the maximum number of messages will be "max_num_msg" and the maximum message size will be "max_msg_size". Throws on error and if the queue was previously created. 2.
message_queue_t(open_or_create_t open_or_create, const char * name, size_type max_num_msg, size_type max_msg_size, const permissions & perm = permissions());
Opens or creates a process shared message queue with name "name". If the queue is created, the maximum number of messages will be "max_num_msg" and the maximum message size will be "max_msg_size". If queue was previously created the queue will be opened and "max_num_msg" and "max_msg_size" parameters are ignored. Throws on error. 3.
message_queue_t(open_only_t open_only, const char * name);
Opens a previously created process shared message queue with name "name". If the queue was not previously created or there are no free resources, throws an error. 4.
~message_queue_t();
Destroys *this and indicates that the calling process is nished using the resource. All opened message queues are still valid after destruction. The destructor function will deallocate any system resources allocated by the system for use by this process for this resource. The resource can still be opened again calling the open constructor overload. To erase the message queue from the system use remove().
message_queue_t public member functions
1.
Sends a message stored in buffer "buffer" with size "buffer_size" in the message queue with priority "priority". If the message queue is full the sender is blocked. Throws interprocess_error on error. 2.
bool try_send(const void * buffer, size_type buffer_size, unsigned int priority);
Sends a message stored in buffer "buffer" with size "buffer_size" through the message queue with priority "priority". If the message queue is full the sender is not blocked and returns false, otherwise returns true. Throws interprocess_error on error. 3.
bool timed_send(const void * buffer, size_type buffer_size, unsigned int priority, const boost::posix_time::ptime & abs_time);
Sends a message stored in buffer "buffer" with size "buffer_size" in the message queue with priority "priority". If the message queue is full the sender retries until time "abs_time" is reached. Returns true if the message has been successfully sent. Returns false if timeout is reached. Throws interprocess_error on error. 4.
void receive(void * buffer, size_type buffer_size, size_type & recvd_size, unsigned int & priority);
354
Boost.Interprocess
Receives a message from the message queue. The message is stored in buffer "buffer", which has size "buffer_size". The received message has size "recvd_size" and priority "priority". If the message queue is empty the receiver is blocked. Throws interprocess_error on error. 5.
bool try_receive(void * buffer, size_type buffer_size, size_type & recvd_size, unsigned int & priority);
Receives a message from the message queue. The message is stored in buffer "buffer", which has size "buffer_size". The received message has size "recvd_size" and priority "priority". If the message queue is empty the receiver is not blocked and returns false, otherwise returns true. Throws interprocess_error on error. 6.
bool timed_receive(void * buffer, size_type buffer_size, size_type & recvd_size, unsigned int & priority, const boost::posix_time::ptime & abs_time);
Receives a message from the message queue. The message is stored in buffer "buffer", which has size "buffer_size". The received message has size "recvd_size" and priority "priority". If the message queue is empty the receiver retries until time "abs_time" is reached. Returns true if the message has been successfully sent. Returns false if timeout is reached. Throws interprocess_error on error. 7.
size_type get_max_msg() const;
Returns the maximum number of messages allowed by the queue. The message queue must be opened or created previously. Otherwise, returns 0. Never throws 8.
size_type get_max_msg_size() const;
Returns the maximum size of message allowed by the queue. The message queue must be opened or created previously. Otherwise, returns 0. Never throws 9.
size_type get_num_msg();
1.
Removes the message queue from the system. Returns false on error. Never throws
Header <boost/interprocess/managed_external_buffer.hpp>
Describes a named user memory allocation user class.
namespace boost { namespace interprocess { template<typename CharType, typename AllocationAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_external_buffer; } }
355
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/managed_external_buffer.hpp> template<typename CharType, typename AllocationAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_external_buffer { public: // types typedef base_t::size_type size_type; // construct/copy/destruct basic_managed_external_buffer(); basic_managed_external_buffer(create_only_t, void *, size_type); basic_managed_external_buffer(open_only_t, void *, size_type); basic_managed_external_buffer(basic_managed_external_buffer &&); basic_managed_external_buffer& operator=(basic_managed_external_buffer &&); // public member functions void grow(size_type); void swap(basic_managed_external_buffer &); };
Description
A basic user memory named object creation class. Inherits all basic functionality from basic_managed_memory_impl<CharType, AllocationAlgorithm, IndexType>
basic_managed_external_buffer public construct/copy/destruct
1.
basic_managed_external_buffer();
Moves the ownership of "moved"'s managed memory to *this. Does not throw. 5.
basic_managed_external_buffer& operator=(basic_managed_external_buffer && moved);
Moves the ownership of "moved"'s managed memory to *this. Does not throw.
356
Boost.Interprocess
1.
2.
Swaps the ownership of the managed heap memories managed by *this and other. Never throws.
Header <boost/interprocess/managed_heap_memory.hpp>
Describes a named heap memory allocation user class.
namespace boost { namespace interprocess { template<typename CharType, typename AllocationAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_heap_memory; } }
Synopsis
// In header: <boost/interprocess/managed_heap_memory.hpp> template<typename CharType, typename AllocationAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_heap_memory { public: // types typedef base_t::size_type size_type; // construct/copy/destruct basic_managed_heap_memory(); basic_managed_heap_memory(size_type); basic_managed_heap_memory(basic_managed_heap_memory &&); basic_managed_heap_memory& operator=(basic_managed_heap_memory &&); ~basic_managed_heap_memory(); // public member functions bool grow(size_type); void swap(basic_managed_heap_memory &); };
Description
A basic heap memory named object creation class. Initializes the heap memory segment. Inherits all basic functionality from basic_managed_memory_impl<CharType, AllocationAlgorithm, IndexType>
basic_managed_heap_memory public construct/copy/destruct
1.
basic_managed_heap_memory();
357
Boost.Interprocess
Creates heap memory and initializes the segment manager. This can throw. 3.
basic_managed_heap_memory(basic_managed_heap_memory && moved);
Moves the ownership of "moved"'s managed memory to *this. Does not throw. 4.
basic_managed_heap_memory& operator=(basic_managed_heap_memory && moved);
Moves the ownership of "moved"'s managed memory to *this. Does not throw. 5.
~basic_managed_heap_memory();
Destructor. Liberates the heap memory holding the managed data. Never throws.
basic_managed_heap_memory public member functions
1.
Tries to resize internal heap memory so that we have room for more objects. WARNING: If memory is reallocated, all the objects will be binary-copied to the new buffer. To be able to use this function, all pointers constructed in this buffer must be offset pointers. Otherwise, the result is undened. Returns true if the growth has been successful, so you will have some extra bytes to allocate new objects. If returns false, the heap allocation has failed. 2.
void swap(basic_managed_heap_memory & other);
Swaps the ownership of the managed heap memories managed by *this and other. Never throws.
Header <boost/interprocess/managed_mapped_file.hpp>
namespace boost { namespace interprocess { template<typename CharType, typename AllocationAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_mapped_file; } }
358
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/managed_mapped_file.hpp> template<typename CharType, typename AllocationAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_mapped_file { public: // construct/copy/destruct basic_managed_mapped_file(); basic_managed_mapped_file(create_only_t, const char *, size_type, const void * = 0, const permissions & = permissions()); basic_managed_mapped_file(open_or_create_t, const char *, size_type, const void * = 0, const permissions & = permissions()); basic_managed_mapped_file(open_only_t, const char *, const void * = 0); basic_managed_mapped_file(open_copy_on_write_t, const char *, const void * = 0); basic_managed_mapped_file(open_read_only_t, const char *, const void * = 0); basic_managed_mapped_file(basic_managed_mapped_file &&); basic_managed_mapped_file& operator=(basic_managed_mapped_file &&); ~basic_managed_mapped_file(); // public member functions void swap(basic_managed_mapped_file &); bool flush(); // public static functions static bool grow(const char *, size_type); static bool shrink_to_fit(const char *); };
Description
A basic mapped le named object creation class. Initializes the mapped le. Inherits all basic functionality from basic_managed_memory_impl<CharType, AllocationAlgorithm, IndexType>
basic_managed_mapped_file public construct/copy/destruct
1.
basic_managed_mapped_file();
Creates mapped le and creates and places the segment manager. This can throw. 2.
basic_managed_mapped_file(create_only_t create_only, const char * name, size_type size, const void * addr = 0, const permissions & perm = permissions());
Creates mapped le and creates and places the segment manager. This can throw. 3.
basic_managed_mapped_file(open_or_create_t open_or_create, const char * name, size_type size, const void * addr = 0, const permissions & perm = permissions());
Creates mapped le and creates and places the segment manager if segment was not created. If segment was created it connects to the segment. This can throw.
359
Boost.Interprocess
4.
Connects to a created mapped le and its segment manager. This can throw. 5.
basic_managed_mapped_file(open_copy_on_write_t, const char * name, const void * addr = 0);
Connects to a created mapped le and its segment manager in copy_on_write mode. This can throw. 6.
basic_managed_mapped_file(open_read_only_t, const char * name, const void * addr = 0);
Connects to a created mapped le and its segment manager in read-only mode. This can throw. 7.
basic_managed_mapped_file(basic_managed_mapped_file && moved);
Moves the ownership of "moved"'s managed memory to *this. Does not throw 8.
basic_managed_mapped_file& operator=(basic_managed_mapped_file && moved);
Moves the ownership of "moved"'s managed memory to *this. Does not throw 9.
~basic_managed_mapped_file();
Destroys *this and indicates that the calling process is nished using the resource. The destructor function will deallocate any system resources allocated by the system for use by this process for this resource. The resource can still be opened again calling the open constructor overload. To erase the resource from the system use remove().
basic_managed_mapped_file public member functions
1.
Swaps the ownership of the managed mapped memories managed by *this and other. Never throws. 2.
bool flush();
1.
Tries to resize mapped le so that we have room for more objects. This function is not synchronized so no other thread or process should be reading or writing the le 2.
static bool shrink_to_fit(const char * filename);
Tries to resize mapped le to minimized the size of the le. This function is not synchronized so no other thread or process should be reading or writing the le
360
Boost.Interprocess
Header <boost/interprocess/managed_shared_memory.hpp>
namespace boost { namespace interprocess { template<typename CharType, typename AllocationAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_shared_memory; } }
Synopsis
// In header: <boost/interprocess/managed_shared_memory.hpp> template<typename CharType, typename AllocationAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_shared_memory { public: // construct/copy/destruct basic_managed_shared_memory(); basic_managed_shared_memory(create_only_t, const char *, size_type, const void * = 0, const permissions & = permissions()); basic_managed_shared_memory(open_or_create_t, const char *, size_type, const void * = 0, const permissions & = permissions()); basic_managed_shared_memory(open_copy_on_write_t, const char *, const void * = 0); basic_managed_shared_memory(open_read_only_t, const char *, const void * = 0); basic_managed_shared_memory(open_only_t, const char *, const void * = 0); basic_managed_shared_memory(basic_managed_shared_memory &&); basic_managed_shared_memory& operator=(basic_managed_shared_memory &&); ~basic_managed_shared_memory(); // public member functions void swap(basic_managed_shared_memory &); // public static functions static bool grow(const char *, size_type); static bool shrink_to_fit(const char *); };
Description
A basic shared memory named object creation class. Initializes the shared memory segment. Inherits all basic functionality from basic_managed_memory_impl<CharType, AllocationAlgorithm, IndexType>
basic_managed_shared_memory public construct/copy/destruct
1.
basic_managed_shared_memory();
361
Boost.Interprocess
2.
basic_managed_shared_memory(create_only_t create_only, const char * name, size_type size, const void * addr = 0, const permissions & perm = permissions());
Creates shared memory and creates and places the segment manager. This can throw. 3.
basic_managed_shared_memory(open_or_create_t open_or_create, const char * name, size_type size, const void * addr = 0, const permissions & perm = permissions());
Creates shared memory and creates and places the segment manager if segment was not created. If segment was created it connects to the segment. This can throw. 4.
basic_managed_shared_memory(open_copy_on_write_t, const char * name, const void * addr = 0);
Connects to a created shared memory and its segment manager. in copy_on_write mode. This can throw. 5.
basic_managed_shared_memory(open_read_only_t, const char * name, const void * addr = 0);
Connects to a created shared memory and its segment manager. in read-only mode. This can throw. 6.
basic_managed_shared_memory(open_only_t open_only, const char * name, const void * addr = 0);
Connects to a created shared memory and its segment manager. This can throw. 7.
basic_managed_shared_memory(basic_managed_shared_memory && moved);
Moves the ownership of "moved"'s managed memory to *this. Does not throw 8.
basic_managed_shared_memory& operator=(basic_managed_shared_memory && moved);
Moves the ownership of "moved"'s managed memory to *this. Does not throw 9.
~basic_managed_shared_memory();
Destroys *this and indicates that the calling process is nished using the resource. The destructor function will deallocate any system resources allocated by the system for use by this process for this resource. The resource can still be opened again calling the open constructor overload. To erase the resource from the system use remove().
basic_managed_shared_memory public member functions
1.
Swaps the ownership of the managed shared memories managed by *this and other. Never throws.
basic_managed_shared_memory public static functions
1.
362
Boost.Interprocess
Tries to resize the managed shared memory object so that we have room for more objects. This function is not synchronized so no other thread or process should be reading or writing the le 2.
static bool shrink_to_fit(const char * shmname);
Tries to resize the managed shared memory to minimized the size of the le. This function is not synchronized so no other thread or process should be reading or writing the le
Header <boost/interprocess/managed_windows_shared_memory.hpp>
namespace boost { namespace interprocess { template<typename CharType, typename AllocationAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_windows_shared_memory; } }
363
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/managed_windows_shared_memory.hpp> template<typename CharType, typename AllocationAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_windows_shared_memory { public: // types typedef base_t::size_type size_type; // construct/copy/destruct basic_managed_windows_shared_memory(); basic_managed_windows_shared_memory(create_only_t, const char *, size_type, const void * = 0, const permissions & = permissions()); basic_managed_windows_shared_memory(open_or_create_t, const char *, size_type, const void * = 0, const permissions & = permissions()); basic_managed_windows_shared_memory(open_only_t, const char *, const void * = 0); basic_managed_windows_shared_memory(open_copy_on_write_t, const char *, const void * = 0); basic_managed_windows_shared_memory(open_read_only_t, const char *, const void * = 0); basic_managed_windows_shared_memory(basic_managed_windows_shared_memory &&); basic_managed_windows_shared_memory& operator=(basic_managed_windows_shared_memory &&); ~basic_managed_windows_shared_memory(); // public member functions void swap(basic_managed_windows_shared_memory &); };
Description
A basic managed windows shared memory creation class. Initializes the shared memory segment. Inherits all basic functionality from basic_managed_memory_impl<CharType, AllocationAlgorithm, IndexType> Unlike basic_managed_shared_memory, it has no kernel persistence and the shared memory is destroyed when all processes destroy all their windows_shared_memory objects and mapped regions for the same shared memory or the processes end/crash. Warning: basic_managed_windows_shared_memory and basic_managed_shared_memory can't communicate between them.
basic_managed_windows_shared_memory public construct/copy/destruct
1.
basic_managed_windows_shared_memory();
Creates shared memory and creates and places the segment manager. This can throw.
364
Boost.Interprocess
3.
basic_managed_windows_shared_memory(open_or_create_t open_or_create, const char * name, size_type size, const void * addr = 0, const permissions & perm = permissions());
Creates shared memory and creates and places the segment manager if segment was not created. If segment was created it connects to the segment. This can throw. 4.
basic_managed_windows_shared_memory(open_only_t open_only, const char * name, const void * addr = 0);
Connects to a created shared memory and its segment manager. This can throw. 5.
basic_managed_windows_shared_memory(open_copy_on_write_t, const char * name, const void * addr = 0);
Connects to a created shared memory and its segment manager in copy_on_write mode. This can throw. 6.
basic_managed_windows_shared_memory(open_read_only_t, const char * name, const void * addr = 0);
Connects to a created shared memory and its segment manager in read-only mode. This can throw. 7.
basic_managed_windows_shared_memory(basic_managed_windows_shared_memory && moved);
Moves the ownership of "moved"'s managed memory to *this. Does not throw 8.
basic_managed_windows_shared_memory& operator=(basic_managed_windows_shared_memory && moved);
Moves the ownership of "moved"'s managed memory to *this. Does not throw 9.
~basic_managed_windows_shared_memory();
Destroys *this and indicates that the calling process is nished using the resource. All mapped regions are still valid after destruction. When all mapped regions and basic_managed_windows_shared_memory objects referring the shared memory are destroyed, the operating system will destroy the shared memory.
basic_managed_windows_shared_memory public member functions
1.
Swaps the ownership of the managed mapped memories managed by *this and other. Never throws.
Header <boost/interprocess/managed_xsi_shared_memory.hpp>
namespace boost { namespace interprocess { template<typename CharType, typename AllocationAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_xsi_shared_memory; } }
365
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/managed_xsi_shared_memory.hpp> template<typename CharType, typename AllocationAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_xsi_shared_memory { public: // types typedef base_t::size_type size_type; // construct/copy/destruct basic_managed_xsi_shared_memory(); basic_managed_xsi_shared_memory(create_only_t, const xsi_key &, std::size_t, const void * = 0, const permissions & = permissions()); basic_managed_xsi_shared_memory(open_or_create_t, const xsi_key &, std::size_t, const void * = 0, const permissions & = permissions()); basic_managed_xsi_shared_memory(open_read_only_t, const xsi_key &, const void * = 0); basic_managed_xsi_shared_memory(open_only_t, const xsi_key &, const void * = 0); basic_managed_xsi_shared_memory(basic_managed_xsi_shared_memory &&); basic_managed_xsi_shared_memory& operator=(basic_managed_xsi_shared_memory &&); ~basic_managed_xsi_shared_memory(); // public member functions void swap(basic_managed_xsi_shared_memory &); int get_shmid() const; // public static functions static bool remove(int); };
Description
A basic X/Open System Interface (XSI) shared memory named object creation class. Initializes the shared memory segment. Inherits all basic functionality from basic_managed_memory_impl<CharType, AllocationAlgorithm, IndexType>
basic_managed_xsi_shared_memory public construct/copy/destruct
1.
basic_managed_xsi_shared_memory();
Creates shared memory and creates and places the segment manager. This can throw.
366
Boost.Interprocess
3.
basic_managed_xsi_shared_memory(open_or_create_t open_or_create, const xsi_key & key, std::size_t size, const void * addr = 0, const permissions & perm = permissions());
Creates shared memory and creates and places the segment manager if segment was not created. If segment was created it connects to the segment. This can throw. 4.
basic_managed_xsi_shared_memory(open_read_only_t, const xsi_key & key, const void * addr = 0);
Connects to a created shared memory and its segment manager. in read-only mode. This can throw. 5.
basic_managed_xsi_shared_memory(open_only_t open_only, const xsi_key & key, const void * addr = 0);
Connects to a created shared memory and its segment manager. This can throw. 6.
basic_managed_xsi_shared_memory(basic_managed_xsi_shared_memory && moved);
Moves the ownership of "moved"'s managed memory to *this. Does not throw 7.
basic_managed_xsi_shared_memory& operator=(basic_managed_xsi_shared_memory && moved);
Moves the ownership of "moved"'s managed memory to *this. Does not throw 8.
~basic_managed_xsi_shared_memory();
Destroys *this and indicates that the calling process is nished using the resource. The destructor function will deallocate any system resources allocated by the system for use by this process for this resource. The resource can still be opened again calling the open constructor overload. To erase the resource from the system use remove().
basic_managed_xsi_shared_memory public member functions
1.
Swaps the ownership of the managed shared memories managed by *this and other. Never throws. 2.
int get_shmid() const;
1.
Erases a XSI shared memory object identied by shmid from the system. Returns false on error. Never throws
Header <boost/interprocess/mapped_region.hpp>
Describes mapped region class
367
Boost.Interprocess
Class mapped_region
boost::interprocess::mapped_region
Synopsis
// In header: <boost/interprocess/mapped_region.hpp>
class mapped_region { public: enum advice_types; // construct/copy/destruct template<typename MemoryMappable> mapped_region(const MemoryMappable &, mode_t, offset_t = 0, std::size_t = 0, const void * = 0); mapped_region(); mapped_region(mapped_region &&); mapped_region& operator=(mapped_region &&); ~mapped_region(); // public member functions void swap(mapped_region &); std::size_t get_size() const; void * get_address() const; mode_t get_mode() const; bool flush(std::size_t = 0, std::size_t = 0, bool = true); bool shrink_by(std::size_t, bool = true); bool advise(advice_types); // public static functions static std::size_t get_page_size(); };
Description
The mapped_region class represents a portion or region created from a memory_mappable object. The OS can map a region bigger than the requested one, as region must be multiple of the page size, but mapped_region will always refer to the region specied by the user.
mapped_region public construct/copy/destruct
1.
template<typename MemoryMappable> mapped_region(const MemoryMappable & mapping, mode_t mode, offset_t offset = 0, std::size_t size = 0, const void * address = 0);
Creates a mapping region of the mapped memory "mapping", starting in offset "offset", and the mapping's size will be "size". The mapping can be opened for read only, read-write or copy-on-write. If an address is specied, both the offset and the address must be multiples of the page size.
368
Boost.Interprocess
The OS could allocate more pages than size/page_size(), but get_address() will always return the address passed in this function (if not null) and get_size() will return the specied size. 2.
mapped_region();
Default constructor. Address will be 0 (nullptr). Size will be 0. Does not throw 3.
mapped_region(mapped_region && other);
Move constructor. *this will be constructed taking ownership of "other"'s region and "other" will be left in default constructor state. 4.
mapped_region& operator=(mapped_region && other);
Move assignment. If *this owns a memory mapped region, it will be destroyed and it will take ownership of "other"'s memory mapped region. 5.
~mapped_region();
1.
Returns the mode of the mapping used to construct the mapped region. Never throws. 5.
bool flush(std::size_t mapping_offset = 0, std::size_t numbytes = 0, bool async = true);
Flushes to the disk a byte range within the mapped memory. If 'async' is true, the function will return before ushing operation is completed If 'async' is false, function will return once data has been written into the underlying device (i.e., in mapped les OS cached information is written to disk). Never throws. Returns false if operation could not be performed. 6.
bool shrink_by(std::size_t bytes, bool from_back = true);
Shrinks current mapped region. If after shrinking there is no longer need for a previously mapped memory page, accessing that page can trigger a segmentation fault. Depending on the OS, this operation might fail (XSI shared memory), it can decommit storage and free a portion of the virtual address space (e.g.POSIX) or this function can release some physical memory wihout freeing any virtual address space(Windows). Returns true on success. Never throws.
369
Boost.Interprocess
7.
Advises the implementation on the expected behavior of the application with respect to the data in the region. The implementation may use this information to optimize handling of the region data. This function has no effect on the semantics of access to memory in the region, although it may affect the performance of access. If the advise type is not known to the implementation, the function returns false. True otherwise.
mapped_region public static functions
1.
Returns the size of the page. This size is the minimum memory that will be used by the system when mapping a memory mappable source and will restrict the address and the offset to map.
Type advice_types
boost::interprocess::mapped_region::advice_types
Synopsis
// In header: <boost/interprocess/mapped_region.hpp>
Description
This enum species region usage behaviors that an application can specify to the mapped region implementation.
advice_normal advice_sequential
Species that the application has no advice to give on its behavior with respect to the region. It is the default characteristic if no advice is given for a range of memory. Species that the application expects to access the region sequentially from lower addresses to higher addresses. The implementation can lower the priority of preceding pages within the region once a page have been accessed. Species that the application expects to access the region in a random order, and prefetching is likely not advantageous. Species that the application expects to access the region in the near future. The implementation can prefetch pages of the region. Species that the application expects that it will not access the region in the near future. The implementation can unload pages within the range to save system resources.
Header <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
Describes a best-t algorithm based in an intrusive red-black tree used to allocate objects in shared memory. This class is intended as a base class for single segment and multi-segment implementations.
namespace boost { namespace interprocess { template<typename MutexFamily, typename VoidPointer, std::size_t MemAlignment> class rbtree_best_fit; } }
370
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/mem_algo/rbtree_best_fit.hpp> template<typename MutexFamily, typename VoidPointer, std::size_t MemAlignment> class rbtree_best_fit { public: // types typedef MutexFamily mutex_family; // Shared mutex family used for the rest of the Interprocess framework. typedef VoidPointer void_pointer; // Pointer type to be used with the rest of the Interprocess framework. typedef unspecified multiallocation_chain; typedef boost::intrusive::pointer_traits< char_ptr >::difference_type difference_type; typedef boost::make_unsigned< difference_type >::type size_type; // construct/copy/destruct rbtree_best_fit(size_type, size_type); ~rbtree_best_fit(); // public member functions void * allocate(size_type); void deallocate(void *); size_type get_size() const; size_type get_free_memory() const; void zero_free_memory(); void grow(size_type); void shrink_to_fit(); bool all_memory_deallocated(); bool check_sanity(); template<typename T> std::pair< T *, bool > allocation_command(boost::interprocess::allocation_type, size_type, size_type, size_type &, T * = 0); std::pair< void *, bool > raw_allocation_command(boost::interprocess::allocation_type, size_type, size_type, size_type &, void * = 0, size_type = 1); size_type size(const void *) const; void * allocate_aligned(size_type, size_type); // public static functions static size_type get_min_size(size_type); // public data members static const size_type PayloadPerAllocation; };
Description
This class implements an algorithm that stores the free nodes in a red-black tree to have logarithmic search/insert times.
rbtree_best_fit public construct/copy/destruct
1.
371
Boost.Interprocess
Constructor. "size" is the total size of the managed memory segment, "extra_hdr_bytes" indicates the extra bytes beginning in the sizeof(rbtree_best_t) offset that the allocator should not use at all. 2.
~rbtree_best_fit();
Destructor.
rbtree_best_fit public member functions
1.
Initializes to zero all the memory that's not in use. This function is normally used for security reasons. 6.
void grow(size_type extra_size);
372
Boost.Interprocess
11.
std::pair< void *, bool > raw_allocation_command(boost::interprocess::allocation_type command, size_type limit_object, size_type preferred_object, size_type & received_object, void * reuse_ptr = 0, size_type sizeof_object = 1);
12.
Returns the size of the buffer previously allocated pointed by ptr. 13.
void * allocate_aligned(size_type nbytes, size_type alignment);
Allocates aligned bytes, returns 0 if there is not more memory. Alignment must be power of 2
rbtree_best_fit public static functions
1.
Header <boost/interprocess/mem_algo/simple_seq_fit.hpp>
Describes sequential t algorithm used to allocate objects in shared memory.
namespace boost { namespace interprocess { template<typename MutexFamily, typename VoidPointer> class simple_seq_fit; } }
Synopsis
// In header: <boost/interprocess/mem_algo/simple_seq_fit.hpp> template<typename MutexFamily, typename VoidPointer> class simple_seq_fit { public: // types typedef base_t::size_type size_type; // construct/copy/destruct simple_seq_fit(size_type, size_type); };
Description
This class implements the simple sequential t algorithm with a simply linked list of free buffers.
373
Boost.Interprocess
1.
Constructor. "size" is the total size of the managed memory segment, "extra_hdr_bytes" indicates the extra bytes beginning in the sizeof(simple_seq_t) offset that the allocator should not use at all.
Header <boost/interprocess/offset_ptr.hpp>
Describes a smart pointer that stores the offset between this pointer and target pointee, called offset_ptr.
template<typename T> struct has_trivial_constructor; template<typename T> struct has_trivial_destructor;namespace boost { namespace interprocess { template<typename PointedType, typename DifferenceType, typename OffsetType, std::size_t OffsetAlignment> class offset_ptr; template<typename E, typename T, typename W, typename X, typename Y, std::size_t Z> std::basic_ostream< E, T > & operator<<(std::basic_ostream< E, T > &, offset_ptr< W, X, Y, Z > const &); template<typename E, typename T, typename W, typename X, typename Y, std::size_t Z> std::basic_istream< E, T > & operator>>(std::basic_istream< E, T > &, offset_ptr< W, X, Y, Z > &); // Simulation of static_cast between pointers. Never throws. template<typename T1, typename P1, typename O1, std::size_t A1, typename T2, typename P2, typename O2, std::size_t A2> boost::interprocess::offset_ptr< T1, P1, O1, A1 > static_pointer_cast(const boost::interprocess::offset_ptr< T2, P2, O2, A2 > & r); // Simulation of const_cast between pointers. Never throws. template<typename T1, typename P1, typename O1, std::size_t A1, typename T2, typename P2, typename O2, std::size_t A2> boost::interprocess::offset_ptr< T1, P1, O1, A1 > const_pointer_cast(const boost::interprocess::offset_ptr< T2, P2, O2, A2 > & r); // Simulation of dynamic_cast between pointers. Never throws. template<typename T1, typename P1, typename O1, std::size_t A1, typename T2, typename P2, typename O2, std::size_t A2> boost::interprocess::offset_ptr< T1, P1, O1, A1 > dynamic_pointer_cast(const boost::interprocess::offset_ptr< T2, P2, O2, A2 > & r); // Simulation of reinterpret_cast between pointers. Never throws. template<typename T1, typename P1, typename O1, std::size_t A1, typename T2, typename P2, typename O2, std::size_t A2> boost::interprocess::offset_ptr< T1, P1, O1, A1 > reinterpret_pointer_cast(const boost::interprocess::offset_ptr< T2, P2, O2, A2 > & r); } }
374
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/offset_ptr.hpp> template<typename T> struct has_trivial_constructor { };
Synopsis
// In header: <boost/interprocess/offset_ptr.hpp> template<typename T> struct has_trivial_destructor { };
375
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/offset_ptr.hpp> template<typename PointedType, typename DifferenceType, typename OffsetType, std::size_t OffsetAlignment> class offset_ptr { public: // types typedef PointedType element_type; typedef PointedType * pointer; typedef unspecified reference; typedef unspecified value_type; typedef DifferenceType difference_type; typedef std::random_access_iterator_tag iterator_category; typedef OffsetType offset_type; // member classes/structs/unions template<typename U> struct rebind { // types typedef offset_ptr< U, DifferenceType, OffsetType, OffsetAlignment > other; }; // construct/copy/destruct offset_ptr(); offset_ptr(pointer); template<typename T> offset_ptr(T *, unspecified = 0); offset_ptr(const offset_ptr &); template<typename T2> offset_ptr(const offset_ptr< T2, DifferenceType, OffsetType, OffsetAlignment > &); template<typename T2, typename P2, typename O2, std::size_t A2> offset_ptr(const offset_ptr< T2, P2, O2, A2 > &, unspecified); template<typename T2, typename P2, typename O2, std::size_t A2> offset_ptr(const offset_ptr< T2, P2, O2, A2 > &, unspecified); template<typename T2, typename P2, typename O2, std::size_t A2> offset_ptr(const offset_ptr< T2, P2, O2, A2 > &, unspecified); template<typename T2, typename P2, typename O2, std::size_t A2> offset_ptr(const offset_ptr< T2, P2, O2, A2 > &, unspecified); offset_ptr& operator=(pointer); offset_ptr& operator=(const offset_ptr &); template<typename T2> offset_ptr& operator=(const offset_ptr< T2, DifferenceType, OffsetType, OffsetAlignment > &); // public member functions pointer get() const; offset_type get_offset() const; pointer operator->() const; reference operator*() const; reference operator[](difference_type) const; offset_ptr & operator+=(difference_type); offset_ptr & operator-=(difference_type); offset_ptr & operator++(void); offset_ptr operator++(int); offset_ptr & operator--(void); offset_ptr operator--(int); operator unspecified_bool_type() const; bool operator!() const; // public static functions static offset_ptr pointer_to(reference);
376
Boost.Interprocess
// friend functions friend offset_ptr operator+(difference_type, offset_ptr); friend offset_ptr operator+(offset_ptr, difference_type); friend offset_ptr operator-(offset_ptr, difference_type); friend offset_ptr operator-(difference_type, offset_ptr); friend difference_type operator-(const offset_ptr &, const offset_ptr &); };
Description
A smart pointer that stores the offset between between the pointer and the the object it points. This allows offset allows special properties, since the pointer is independent from the address address of the pointee, if the pointer and the pointee are still separated by the same offset. This feature converts offset_ptr in a smart pointer that can be placed in shared memory and memory mapped les mapped in different addresses in every process.
offset_ptr public construct/copy/destruct
1.
offset_ptr();
Constructor from raw pointer (allows "0" pointer conversion). Never throws. 3.
template<typename T> offset_ptr(T * ptr, unspecified = 0);
Constructor from other offset_ptr. If pointers of pointee types are convertible, offset_ptrs will be convertibles. Never throws. 6.
template<typename T2, typename P2, typename O2, std::size_t A2> offset_ptr(const offset_ptr< T2, P2, O2, A2 > & r, unspecified);
377
Boost.Interprocess
9.
template<typename T2, typename P2, typename O2, std::size_t A2> offset_ptr(const offset_ptr< T2, P2, O2, A2 > & r, unspecified);
Assignment from related offset_ptr. If pointers of pointee types are assignable, offset_ptrs will be assignable. Never throws.
offset_ptr public member functions
1.
3.
7.
8.
378
Boost.Interprocess
9.
offset_ptr operator++(int);
Not operator. Not needed in theory, but improves portability. Never throws
offset_ptr public static functions
1.
1.
3.
4.
5.
friend difference_type operator-(const offset_ptr & pt, const offset_ptr & pt2); offset_ptr - offset_ptr operation
379
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/offset_ptr.hpp>
template<typename U> struct rebind { // types typedef offset_ptr< U, DifferenceType, OffsetType, OffsetAlignment > other; };
Description
Compatibility with pointer_traits
Synopsis
// In header: <boost/interprocess/offset_ptr.hpp>
template<typename E, typename T, typename W, typename X, typename Y, std::size_t Z> std::basic_ostream< E, T > & operator<<(std::basic_ostream< E, T > & os, offset_ptr< W, X, Y, Z > const & p);
Description
operator<< for offset ptr
Synopsis
// In header: <boost/interprocess/offset_ptr.hpp>
template<typename E, typename T, typename W, typename X, typename Y, std::size_t Z> std::basic_istream< E, T > & operator>>(std::basic_istream< E, T > & is, offset_ptr< W, X, Y, Z > & p);
Description
operator>> for offset ptr
380
Boost.Interprocess
Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR
BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR
Synopsis
// In header: <boost/interprocess/offset_ptr.hpp> BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR
Macro BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR
BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR
Synopsis
// In header: <boost/interprocess/offset_ptr.hpp> BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR
Macro BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF
BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF
Synopsis
// In header: <boost/interprocess/offset_ptr.hpp> BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF
M a c r o BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER
BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER
Synopsis
// In header: <boost/interprocess/offset_ptr.hpp> BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER
Header <boost/interprocess/permissions.hpp>
Describes permissions class
namespace boost { namespace interprocess { class permissions; } }
381
Boost.Interprocess
Class permissions
boost::interprocess::permissions
Synopsis
// In header: <boost/interprocess/permissions.hpp>
class permissions { public: // construct/copy/destruct permissions(os_permissions_type); permissions(); // public member functions void set_default(); void set_unrestricted(); void set_permissions(os_permissions_type); os_permissions_type get_permissions() const; };
Description
The permissions class represents permissions to be set to shared memory or les, that can be constructed form usual permission representations: a SECURITY_ATTRIBUTES pointer in windows or ORed rwx chmod integer in UNIX.
permissions public construct/copy/destruct
1.
permissions(os_permissions_type type);
Constructs a default permissions object: A null security attributes pointer for windows or 0644 for UNIX.
permissions public member functions
1.
void set_default();
Sets permissions to default values: A null security attributes pointer for windows or 0644 for UNIX. 2.
void set_unrestricted();
Sets permissions to unrestricted access: A null DACL for windows or 0666 for UNIX. 3.
void set_permissions(os_permissions_type perm);
382
Boost.Interprocess
Header <boost/interprocess/segment_manager.hpp>
Describes the object placed in a memory segment that provides named object allocation capabilities for single-segment and multisegment allocations.
namespace boost { namespace interprocess { template<typename MemoryAlgorithm> class segment_manager_base; template<typename CharType, typename MemoryAlgorithm, template< class IndexConfig > class IndexType> class segment_manager; } }
383
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/segment_manager.hpp> template<typename MemoryAlgorithm> class segment_manager_base : private MemoryAlgorithm { public: // types typedef segment_manager_base< MemoryAlgorithm > segment_manager_base_type; typedef MemoryAlgorithm::void_pointer void_pointer; typedef MemoryAlgorithm::mutex_family mutex_family; typedef MemoryAlgorithm memory_algorithm; // construct/copy/destruct segment_manager_base(size_type, size_type); // public member functions size_type get_size() const; size_type get_free_memory() const; void * allocate(size_type, std::nothrow_t); void * allocate(size_type); void * allocate_aligned(size_type, size_type, std::nothrow_t); void * allocate_aligned(size_type, size_type); template<typename T> std::pair< T *, bool > allocation_command(boost::interprocess::allocation_type, size_type, size_type, size_type &, T * = 0); std::pair< void *, bool > raw_allocation_command(boost::interprocess::allocation_type, size_type, size_type, size_type &, void * = 0, size_type = 1); void deallocate(void *); void grow(size_type); void shrink_to_fit(); bool all_memory_deallocated(); bool check_sanity(); void zero_free_memory(); size_type size(const void *) const; // public static functions static size_type get_min_size(size_type); // public data members static const size_type PayloadPerAllocation; };
Description
This object is the public base class of segment manager. This class only depends on the memory allocation algorithm and implements all the allocation features not related to named or unique objects. Storing a reference to segment_manager forces the holder class to be dependent on index types and character types. When such dependence is not desirable and only anonymous and raw allocations are needed, segment_manager_base is the correct answer.
segment_manager_base public construct/copy/destruct
1.
Constructor of the segment_manager_base "size" is the size of the memory segment where the basic segment manager is being constructed.
384
Boost.Interprocess
"reserved_bytes" is the number of bytes after the end of the memory algorithm object itself that the memory algorithm will exclude from dynamic allocation Can throw
segment_manager_base public member functions
1.
Allocates nbytes bytes. This function is only used in single-segment management. Never throws 4.
void * allocate(size_type nbytes);
Allocates nbytes bytes. This function is only used in single-segment management. Never throws 6.
void * allocate_aligned(size_type nbytes, size_type alignment);
Allocates nbytes bytes. This function is only used in single-segment management. Throws bad_alloc when fails 7.
template<typename T> std::pair< T *, bool > allocation_command(boost::interprocess::allocation_type command, size_type limit_size, size_type preferred_size, size_type & received_size, T * reuse_ptr = 0);
8.
std::pair< void *, bool > raw_allocation_command(boost::interprocess::allocation_type command, size_type limit_objects, size_type preferred_objects, size_type & received_objects, void * reuse_ptr = 0, size_type sizeof_object = 1);
9.
Increases managed memory in extra_size bytes more. This only works with single-segment management.
385
Boost.Interprocess
11.
void shrink_to_fit();
Decreases managed memory to the minimum. This only works with single-segment management. 12.
bool all_memory_deallocated();
Returns the result of "all_memory_deallocated()" function of the used memory algorithm 13.
bool check_sanity();
Returns the result of "check_sanity()" function of the used memory algorithm 14.
void zero_free_memory();
Writes to zero free memory (memory not yet allocated) of the memory algorithm 15.
size_type size(const void * ptr) const;
1.
1.
This constant indicates the payload size associated with each allocation of the memory algorithm
386
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/segment_manager.hpp> template<typename CharType, typename MemoryAlgorithm, template< class IndexConfig > class IndexType> class segment_manager : public boost::interprocess::segment_manager_base< MemoryAlgorithm > { public: // types typedef MemoryAlgorithm memory_al gorithm; typedef Base::void_pointer void_pointer; typedef Base::size_type size_type; typedef Base::difference_type differ ence_type; typedef CharType char_type; typedef segment_manager_base< MemoryAlgorithm > seg ment_manager_base_type; typedef Base::mutex_family mu tex_family; typedef transform_iterator< typename named_index_t::const_iterator, named_transform > const_named_iterator; typedef transform_iterator< typename unique_index_t::const_iterator, unique_trans form > const_unique_iterator; // member classes/structs/unions template<typename T> struct allocator { // types typedef boost::interprocess::allocator< T, segment_manager > type; }; template<typename T> struct deleter { // types typedef boost::interprocess::deleter< T, segment_manager > type; }; // construct/copy/destruct explicit segment_manager(size_type); // public member functions template<typename T> std::pair< T *, size_type > find(const CharType *); template<typename T> std::pair< T *, size_type > find(unspecified); template<typename T> std::pair< T *, size_type > find_no_lock(const CharType *); template<typename T> std::pair< T *, size_type > find_no_lock(unspecified); template<typename T> construct_proxy< T >::type construct(char_ptr_holder_t); template<typename T> construct_proxy< T >::type find_or_construct(char_ptr_holder_t); template<typename T> construct_proxy< T >::type construct(char_ptr_holder_t, std::nothrow_t); template<typename T> construct_proxy< T >::type find_or_construct(char_ptr_holder_t, std::nothrow_t); template<typename T> construct_iter_proxy< T >::type construct_it(char_ptr_holder_t); template<typename T>
387
Boost.Interprocess
construct_iter_proxy< T >::type find_or_construct_it(char_ptr_holder_t); template<typename T> construct_iter_proxy< T >::type construct_it(char_ptr_holder_t, std::nothrow_t); template<typename T> construct_iter_proxy< T >::type find_or_construct_it(char_ptr_holder_t, std::nothrow_t); template<typename Func> *void atomic_func(Func &); template<typename Func> bool try_atomic_func(Func &); template<typename T> bool destroy(unspecified); template<typename T> bool destroy(const CharType *); template<typename T> void destroy_ptr(const T *); void reserve_named_objects(size_type); void reserve_unique_objects(size_type); void shrink_to_fit_indexes(); size_type get_num_named_objects(); size_type get_num_unique_objects(); const_named_iterator named_begin() const; const_named_iterator named_end() const; const_unique_iterator unique_begin() const; const_unique_iterator unique_end() const; template<typename T> allocator< T >::type get_allocator(); template<typename T> deleter< T >::type get_deleter(); // public static functions template<typename T> static const CharType * get_instance_name(const T *); template<typename T> static size_type get_instance_length(const T *); template<typename T> static instance_type get_instance_type(const T *); static size_type get_min_size(); // public data members static const size_type PayloadPerAllocation; };
Description
This object is placed in the beginning of memory segment and implements the allocation (named or anonymous) of portions of the segment. This object contains two indexes that maintain an association between a name and a portion of the segment. The rst index contains the mappings for normal named objects using the char type specied in the template parameter. The second index contains the association for unique instances. The key will be the const char * returned from type_info.name() function for the unique type to be constructed. segment_manager<CharType, MemoryAlgorithm, IndexType> inherits publicly from segment_manager_base<MemoryAlgorithm> and inherits from it many public functions related to anonymous object and raw memory allocation. See segment_manager_base reference to know about those functions.
segment_manager public construct/copy/destruct
1.
Constructor of the segment manager "size" is the size of the memory segment where the segment manager is being constructed. Can throw
segment_manager public member functions
1.
388
Boost.Interprocess
Tries to nd a previous named allocation. Returns the address and the object count. On failure the rst member of the returned pair is 0. 2.
template<typename T> std::pair< T *, size_type > find(unspecified name);
Tries to nd a previous unique allocation. Returns the address and the object count. On failure the rst member of the returned pair is 0. 3.
template<typename T> std::pair< T *, size_type > find_no_lock(const CharType * name);
Tries to nd a previous named allocation. Returns the address and the object count. On failure the rst member of the returned pair is 0. This search is not mutex-protected! 4.
template<typename T> std::pair< T *, size_type > find_no_lock(unspecified name);
Tries to nd a previous unique allocation. Returns the address and the object count. On failure the rst member of the returned pair is 0. This search is not mutex-protected! 5.
template<typename T> construct_proxy< T >::type construct(char_ptr_holder_t name);
389
Boost.Interprocess
11.
Calls object function blocking recursive interprocess_mutex and guarantees that no new named_alloc or destroy will be executed by any process while executing the object function call 14.
template<typename Func> bool try_atomic_func(Func & f);
Tries to calls a functor guaranteeing that no new construction, search or destruction will be executed by any process while executing the object function call. If the atomic function can't be immediatelly executed because the internal mutex is already locked, returns false. If the functor throws, this function throws. 15.
template<typename T> bool destroy(unspecified);
Destroys a previously created unique instance. Returns false if the object was not present. 16.
template<typename T> bool destroy(const CharType * name);
Destroys the named object with the given name. Returns false if that object can't be found. 17.
template<typename T> void destroy_ptr(const T * p);
Preallocates needed index resources to optimize the creation of "num" named objects in the managed memory segment. Can throw boost::interprocess::bad_alloc if there is no enough memory. 19.
void reserve_unique_objects(size_type num);
Preallocates needed index resources to optimize the creation of "num" unique objects in the managed memory segment. Can throw boost::interprocess::bad_alloc if there is no enough memory. 20.
void shrink_to_fit_indexes();
Calls shrink_to_t in both named and unique object indexes to try to free unused memory from those indexes. 21.
size_type get_num_named_objects();
390
Boost.Interprocess
Returns a constant iterator to the beginning of the information about the named allocations performed in this segment manager 24.
const_named_iterator named_end() const;
Returns a constant iterator to the end of the information about the named allocations performed in this segment manager 25.
const_unique_iterator unique_begin() const;
Returns a constant iterator to the beginning of the information about the unique allocations performed in this segment manager 26.
const_unique_iterator unique_end() const;
Returns a constant iterator to the end of the information about the unique allocations performed in this segment manager 27.
template<typename T> allocator< T >::type get_allocator();
Returns an instance of the default allocator for type T initialized that allocates memory from this segment manager. 28.
template<typename T> deleter< T >::type get_deleter();
Returns an instance of the default allocator for type T initialized that allocates memory from this segment manager.
segment_manager public static functions
1.
Returns the name of an object created with construct/nd_or_construct functions. Does not throw 2.
template<typename T> static size_type get_instance_length(const T * ptr);
Returns the length of an object created with construct/nd_or_construct functions. Does not throw. 3.
template<typename T> static instance_type get_instance_type(const T * ptr);
Returns is the the name of an object created with construct/nd_or_construct functions. Does not throw 4.
static size_type get_min_size();
391
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/segment_manager.hpp>
template<typename T> struct allocator { // types typedef boost::interprocess::allocator< T, segment_manager > type; };
Description
This is the default allocator to allocate types T from this managed segment
Synopsis
// In header: <boost/interprocess/segment_manager.hpp>
template<typename T> struct deleter { // types typedef boost::interprocess::deleter< T, segment_manager > type; };
Description
This is the default deleter to delete types T from this managed segment.
Header <boost/interprocess/shared_memory_object.hpp>
Describes a shared memory object management class.
namespace boost { namespace interprocess { class shared_memory_object; class remove_shared_memory_on_destroy; } }
Class shared_memory_object
boost::interprocess::shared_memory_object
392
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/shared_memory_object.hpp>
class shared_memory_object { public: // construct/copy/destruct shared_memory_object(); shared_memory_object(create_only_t, const char *, mode_t, const permissions & = permissions()); shared_memory_object(open_or_create_t, const char *, mode_t, const permissions & = permissions()); shared_memory_object(open_only_t, const char *, mode_t); shared_memory_object(shared_memory_object &&); shared_memory_object& operator=(shared_memory_object &&); ~shared_memory_object(); // public member functions void swap(shared_memory_object &); void truncate(offset_t); const char * get_name() const; bool get_size(offset_t &) const; mode_t get_mode() const; mapping_handle_t get_mapping_handle() const; // public static functions static bool remove(const char *); };
Description
A class that wraps a shared memory mapping that can be used to create mapped regions from the mapped les
shared_memory_object public construct/copy/destruct
1.
shared_memory_object();
Creates a shared memory object with name "name" and mode "mode", with the access mode "mode" If the le previously exists, throws an error. 3.
shared_memory_object(open_or_create_t, const char * name, mode_t mode, const permissions & perm = permissions());
Tries to create a shared memory object with name "name" and mode "mode", with the access mode "mode". If the le previously exists, it tries to open it with mode "mode". Otherwise throws an error. 4.
shared_memory_object(open_only_t, const char * name, mode_t mode);
Tries to open a shared memory object with name "name", with the access mode "mode". If the le does not previously exist, it throws an error.
393
Boost.Interprocess
5.
Moves the ownership of "moved"'s shared memory object to *this. After the call, "moved" does not represent any shared memory object. Does not throw 6.
shared_memory_object& operator=(shared_memory_object && moved);
Moves the ownership of "moved"'s shared memory to *this. After the call, "moved" does not represent any shared memory. Does not throw 7.
~shared_memory_object();
Destroys *this and indicates that the calling process is nished using the resource. All mapped regions are still valid after destruction. The destructor function will deallocate any system resources allocated by the system for use by this process for this resource. The resource can still be opened again calling the open constructor overload. To erase the resource from the system use remove().
shared_memory_object public member functions
1.
Returns true if the size of the shared memory object can be obtained and writes the size in the passed reference 5.
mode_t get_mode() const;
1.
Erases a shared memory object from the system. Returns false on error. Never throws
Class remove_shared_memory_on_destroy
boost::interprocess::remove_shared_memory_on_destroy
394
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/shared_memory_object.hpp>
Description
A class that stores the name of a shared memory and calls shared_memory_object::remove(name) in its destructor Useful to remove temporary shared memory objects in the presence of exceptions
remove_shared_memory_on_destroy public construct/copy/destruct
1.
2.
~remove_shared_memory_on_destroy();
Header <boost/interprocess/smart_ptr/deleter.hpp>
Describes the functor to delete objects from the segment.
namespace boost { namespace interprocess { template<typename T, typename SegmentManager> class deleter; } }
395
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/smart_ptr/deleter.hpp> template<typename T, typename SegmentManager> class deleter { public: // types typedef boost::intrusive::pointer_traits< typename SegmentManager::void_pointer >::template re bind_pointer< T >::type pointer; // construct/copy/destruct deleter(segment_manager_pointer); // public member functions void operator()(const pointer &); };
Description
A deleter that uses the segment manager's destroy_ptr function to destroy the passed pointer resource. This deleter is used
deleter public construct/copy/destruct
1.
deleter(segment_manager_pointer pmngr);
1.
Header <boost/interprocess/smart_ptr/enable_shared_from_this.hpp>
Describes an utility to form a shared pointer from this
namespace boost { namespace interprocess { template<typename T, typename A, typename D> class enable_shared_from_this; } }
396
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/smart_ptr/enable_shared_from_this.hpp> template<typename T, typename A, typename D> class enable_shared_from_this { public: // public member functions shared_ptr< T, A, D > shared_from_this(); shared_ptr< T const, A, D > shared_from_this() const; };
Description
This class is used as a base class that allows a shared_ptr to the current object to be obtained from within a member function. enable_shared_from_this denes two member functions called shared_from_this that return a shared_ptr<T> and shared_ptr<T const>, depending on constness, to this.
enable_shared_from_this public member functions
1.
2.
Header <boost/interprocess/smart_ptr/intrusive_ptr.hpp>
Describes an intrusive ownership pointer.
397
Boost.Interprocess
namespace boost { namespace interprocess { template<typename T, typename VoidPointer> class intrusive_ptr; template<typename T, typename U, typename VP> bool operator==(intrusive_ptr< T, VP > const &, intrusive_ptr< U, VP > const &); template<typename T, typename U, typename VP> bool operator!=(intrusive_ptr< T, VP > const &, intrusive_ptr< U, VP > const &); template<typename T, typename VP> bool operator==(intrusive_ptr< T, VP > const &, const typename intrusive_ptr< T, VP >::pointer template<typename T, typename VP> bool operator!=(intrusive_ptr< T, VP > const &, const typename intrusive_ptr< T, VP >::pointer template<typename T, typename VP> bool operator==(const typename intrusive_ptr< T, VP >::pointer intrusive_ptr< T, VP > const &); template<typename T, typename VP> bool operator!=(const typename intrusive_ptr< T, VP >::pointer intrusive_ptr< T, VP > const &); template<typename T, typename VP> bool operator<(intrusive_ptr< T, VP > const &, intrusive_ptr< T, VP > const &); template<typename T, typename VP> void swap(intrusive_ptr< T, VP > &, intrusive_ptr< T, VP > &); template<typename E, typename T, typename Y, typename VP> std::basic_ostream< E, T > & operator<<(std::basic_ostream< E, T > & os, intrusive_ptr< Y, VP > const & p); template<typename T, typename VP> boost::interprocess::intrusive_ptr< T, VP >::pointer to_raw_pointer(intrusive_ptr< T, VP >); } }
&);
&); &,
&,
398
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/smart_ptr/intrusive_ptr.hpp> template<typename T, typename VoidPointer> class intrusive_ptr { public: // types typedef boost::intrusive::pointer_traits< VoidPointer >::template rebind_pointer< T >::type point er; // Provides the type of the internal stored pointer. typedef T element_type; // Provides the type of the stored pointer. // construct/copy/destruct intrusive_ptr(); intrusive_ptr(const pointer &, bool = true); intrusive_ptr(intrusive_ptr const &); template<typename U> intrusive_ptr(intrusive_ptr< U, VP > const &); intrusive_ptr& operator=(intrusive_ptr const &); template<typename U> intrusive_ptr& operator=(intrusive_ptr< U, VP > const &); intrusive_ptr& operator=(pointer); ~intrusive_ptr(); // public member functions pointer & get(); const pointer & get() const; T & operator*() const; const pointer & operator->() const; pointer & operator->(); operator unspecified_bool_type() const; bool operator!() const; void swap(intrusive_ptr &); };
Description
The intrusive_ptr class template stores a pointer to an object with an embedded reference count. intrusive_ptr is parameterized on T (the type of the object pointed to) and VoidPointer(a void pointer type that denes the type of pointer that intrusive_ptr will store). intrusive_ptr<T, void *> denes a class with a T* member whereas intrusive_ptr<T, offset_ptr<void> > denes a class with a offset_ptr<T> member. Relies on unqualied calls to: void intrusive_ptr_add_ref(T * p); void intrusive_ptr_release(T * p); with (p != 0) The object is responsible for destroying itself.
intrusive_ptr public construct/copy/destruct
1.
intrusive_ptr();
Constructor. Copies pointer and if "p" is not zero and "add_ref" is true calls intrusive_ptr_add_ref(to_raw_pointer(p)). Does not throw
399
Boost.Interprocess
3.
Copy constructor. Copies the internal pointer and if "p" is not zero calls intrusive_ptr_add_ref(to_raw_pointer(p)). Does not throw 4.
template<typename U> intrusive_ptr(intrusive_ptr< U, VP > const & rhs);
Constructor from related. Copies the internal pointer and if "p" is not zero calls intrusive_ptr_add_ref(to_raw_pointer(p)). Does not throw 5.
intrusive_ptr& operator=(intrusive_ptr const & rhs);
1.
400
Boost.Interprocess
Exchanges the contents of the two smart pointers. Does not throw
Synopsis
// In header: <boost/interprocess/smart_ptr/intrusive_ptr.hpp>
template<typename T, typename U, typename VP> bool operator==(intrusive_ptr< T, VP > const & a, intrusive_ptr< U, VP > const & b);
Description
Returns a.get() == b.get(). Does not throw
Synopsis
// In header: <boost/interprocess/smart_ptr/intrusive_ptr.hpp>
template<typename T, typename U, typename VP> bool operator!=(intrusive_ptr< T, VP > const & a, intrusive_ptr< U, VP > const & b);
Description
Returns a.get() != b.get(). Does not throw
401
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/smart_ptr/intrusive_ptr.hpp>
template<typename T, typename VP> bool operator==(intrusive_ptr< T, VP > const & a, const typename intrusive_ptr< T, VP >::pointer & b);
Description
Returns a.get() == b. Does not throw
Synopsis
// In header: <boost/interprocess/smart_ptr/intrusive_ptr.hpp>
template<typename T, typename VP> bool operator!=(intrusive_ptr< T, VP > const & a, const typename intrusive_ptr< T, VP >::pointer & b);
Description
Returns a.get() != b. Does not throw
Synopsis
// In header: <boost/interprocess/smart_ptr/intrusive_ptr.hpp>
template<typename T, typename VP> bool operator==(const typename intrusive_ptr< T, VP >::pointer & a, intrusive_ptr< T, VP > const & b);
Description
Returns a == b.get(). Does not throw
402
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/smart_ptr/intrusive_ptr.hpp>
template<typename T, typename VP> bool operator!=(const typename intrusive_ptr< T, VP >::pointer & a, intrusive_ptr< T, VP > const & b);
Description
Returns a != b.get(). Does not throw
Synopsis
// In header: <boost/interprocess/smart_ptr/intrusive_ptr.hpp>
template<typename T, typename VP> bool operator<(intrusive_ptr< T, VP > const & a, intrusive_ptr< T, VP > const & b);
Description
Returns a.get() < b.get(). Does not throw
Synopsis
// In header: <boost/interprocess/smart_ptr/intrusive_ptr.hpp>
template<typename T, typename VP> void swap(intrusive_ptr< T, VP > & lhs, intrusive_ptr< T, VP > & rhs);
Description
Exchanges the contents of the two intrusive_ptrs. Does not throw
403
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/smart_ptr/intrusive_ptr.hpp>
Description
Returns p.get(). Does not throw
Header <boost/interprocess/smart_ptr/scoped_ptr.hpp>
Describes the smart pointer scoped_ptr
namespace boost { namespace interprocess { template<typename T, typename Deleter> class scoped_ptr; template<typename T, typename D> void swap(scoped_ptr< T, D > &, scoped_ptr< T, D > &); template<typename T, typename D> scoped_ptr< T, D >::pointer to_raw_pointer(scoped_ptr< T, D > const &); } }
404
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/smart_ptr/scoped_ptr.hpp> template<typename T, typename Deleter> class scoped_ptr : private Deleter { public: // types typedef T element_type; typedef Deleter deleter_type; typedef unspecified pointer; typedef pointer this_type::* unspecified_bool_type; // construct/copy/destruct explicit scoped_ptr(const pointer & = 0, const Deleter & = Deleter()); ~scoped_ptr(); // public member functions void reset(const pointer & = 0); void reset(const pointer &, const Deleter &); pointer release(); reference operator*() const; pointer & operator->(); const pointer & operator->() const; pointer & get(); const pointer & get() const; operator unspecified_bool_type() const; bool operator!() const; void swap(scoped_ptr &); };
Description
scoped_ptr stores a pointer to a dynamically allocated object. The object pointed to is guaranteed to be deleted, either on destruction of the scoped_ptr, or via an explicit reset. The user can avoid this deletion using release(). scoped_ptr is parameterized on T (the type of the object pointed to) and Deleter (the functor to be executed to delete the internal pointer). The internal pointer will be of the same pointer type as typename Deleter::pointer type (that is, if typename Deleter::pointer is offset_ptr<void>, the internal pointer will be offset_ptr<T>).
scoped_ptr public construct/copy/destruct
1.
Constructs a scoped_ptr, storing a copy of p(which can be 0) and d. Does not throw. 2.
~scoped_ptr();
If the stored pointer is not 0, destroys the object pointed to by the stored pointer. calling the operator() of the stored deleter. Never throws
scoped_ptr public member functions
1.
Deletes the object pointed to by the stored pointer and then stores a copy of p. Never throws 2.
void reset(const pointer & p, const Deleter & d);
405
Boost.Interprocess
Deletes the object pointed to by the stored pointer and then stores a copy of p and a copy of d. 3.
pointer release();
Assigns internal pointer as 0 and returns previous pointer. This will avoid deletion on destructor 4.
reference operator*() const;
Returns a reference to the object pointed to by the stored pointer. Never throws. 5.
pointer & operator->();
Exchanges the internal pointer and deleter with other scoped_ptr Never throws.
Synopsis
// In header: <boost/interprocess/smart_ptr/scoped_ptr.hpp>
template<typename T, typename D> void swap(scoped_ptr< T, D > & a, scoped_ptr< T, D > & b);
406
Boost.Interprocess
Description
Exchanges the internal pointer and deleter with other scoped_ptr Never throws.
Synopsis
// In header: <boost/interprocess/smart_ptr/scoped_ptr.hpp>
template<typename T, typename D> scoped_ptr< T, D >::pointer to_raw_pointer(scoped_ptr< T, D > const & p);
Description
Returns a copy of the stored pointer Never throws
Header <boost/interprocess/smart_ptr/shared_ptr.hpp>
Describes the smart pointer shared_ptr
407
Boost.Interprocess
template<typename T, typename VoidAllocator, typename Deleter> class weak_ptr; template<typename T, typename VoidAllocator, typename Deleter> class weak_ptr;namespace boost { namespace interprocess { template<typename T, typename VoidAllocator, typename Deleter> class shared_ptr; template<typename T, typename ManagedMemory> struct managed_shared_ptr; template<typename T, typename VoidAllocator, typename Deleter, typename U, typename VoidAllocator2, typename Deleter2> bool operator==(shared_ptr< T, VoidAllocator, Deleter > const & a, shared_ptr< U, VoidAllocator2, Deleter2 > const & b); template<typename T, typename VoidAllocator, typename Deleter, typename U, typename VoidAllocator2, typename Deleter2> bool operator!=(shared_ptr< T, VoidAllocator, Deleter > const & a, shared_ptr< U, VoidAllocator2, Deleter2 > const & b); template<typename T, typename VoidAllocator, typename Deleter, typename U, typename VoidAllocator2, typename Deleter2> bool operator<(shared_ptr< T, VoidAllocator, Deleter > const & a, shared_ptr< U, VoidAllocator2, Deleter2 > const & b); template<typename T, typename VoidAllocator, typename Deleter> void swap(shared_ptr< T, VoidAllocator, Deleter > & a, shared_ptr< T, VoidAllocator, Deleter > & b); template<typename T, typename VoidAllocator, typename Deleter, typename U> shared_ptr< T, VoidAllocator, Deleter > static_pointer_cast(shared_ptr< U, VoidAllocator, Deleter > const & r); template<typename T, typename VoidAllocator, typename Deleter, typename U> shared_ptr< T, VoidAllocator, Deleter > const_pointer_cast(shared_ptr< U, VoidAllocator, Deleter > const & r); template<typename T, typename VoidAllocator, typename Deleter, typename U> shared_ptr< T, VoidAllocator, Deleter > dynamic_pointer_cast(shared_ptr< U, VoidAllocator, Deleter > const & r); template<typename T, typename VoidAllocator, typename Deleter> T * to_raw_pointer(shared_ptr< T, VoidAllocator, Deleter > const & p); template<typename E, typename T, typename Y, typename VoidAllocator, typename Deleter> std::basic_ostream< E, T > & operator<<(std::basic_ostream< E, T > & os, shared_ptr< Y, VoidAllocator, Deleter > const & p); template<typename T, typename ManagedMemory> managed_shared_ptr< T, ManagedMemory >::type make_managed_shared_ptr(T *, ManagedMemory &); template<typename T, typename ManagedMemory> managed_shared_ptr< T, ManagedMemory >::type make_managed_shared_ptr(T *, ManagedMemory &, std::nothrow_t); } }
408
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/smart_ptr/shared_ptr.hpp> template<typename T, typename VoidAllocator, typename Deleter> class weak_ptr { };
Synopsis
// In header: <boost/interprocess/smart_ptr/shared_ptr.hpp> template<typename T, typename VoidAllocator, typename Deleter> class weak_ptr { };
409
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/smart_ptr/shared_ptr.hpp> template<typename T, typename VoidAllocator, typename Deleter> class shared_ptr { public: // types typedef T element_type; typedef T value_type; typedef boost::intrusive::pointer_traits< typename VoidAllocator::pointer >::template re bind_pointer< T >::type pointer; typedef unspecified reference; typedef unspecified const_reference; typedef boost::intrusive::pointer_traits< typename VoidAllocator::pointer >::template re bind_pointer< const Deleter >::type const_deleter_pointer; typedef boost::intrusive::pointer_traits< typename VoidAllocator::pointer >::template re bind_pointer< const VoidAllocator >::type const_allocator_pointer; // construct/copy/destruct shared_ptr(); explicit shared_ptr(const pointer &, const VoidAllocator & = VoidAllocator(), const Deleter & = Deleter()); shared_ptr(const shared_ptr &); shared_ptr(const shared_ptr &, const pointer &); template<typename Y> shared_ptr(shared_ptr< Y, VoidAllocator, Deleter > const &); template<typename Y> explicit shared_ptr(weak_ptr< Y, VoidAllocator, Deleter > const &); explicit shared_ptr(shared_ptr &&); template<typename Y> shared_ptr& operator=(shared_ptr< Y, VoidAllocator, Deleter > const &); shared_ptr& operator=(BOOST_COPY_ASSIGN_REF(shared_ptr)); shared_ptr& operator=(shared_ptr &&); // public member functions void reset(); template<typename Pointer> void reset(const Pointer &, const VoidAllocator & = VoidAllocator(), const Deleter & = Deleter()); template<typename Y> void reset(shared_ptr< Y, VoidAllocator, Deleter > const &, const pointer &); reference operator*() const; pointer operator->() const; pointer get() const; bool operator!() const; bool unique() const; long use_count() const; void swap(shared_ptr< T, VoidAllocator, Deleter > &); };
Description
shared_ptr stores a pointer to a dynamically allocated object. The object pointed to is guaranteed to be deleted when the last shared_ptr pointing to it is destroyed or reset.
410
Boost.Interprocess
shared_ptr is parameterized on T (the type of the object pointed to), VoidAllocator (the void allocator to be used to allocate the auxiliary data) and Deleter (the deleter whose operator() will be used to delete the object. The internal pointer will be of the same pointer type as typename VoidAllocator::pointer type (that is, if typename VoidAllocator::pointer is offset_ptr<void>, the internal pointer will be offset_ptr<T>). Because the implementation uses reference counting, cycles of shared_ptr instances will not be reclaimed. For example, if main() holds a shared_ptr to A, which directly or indirectly holds a shared_ptr back to A, A's use count will be 2. Destruction of the original shared_ptr will leave A dangling with a use count of 1. Use weak_ptr to "break cycles."
shared_ptr public construct/copy/destruct
1.
shared_ptr();
Constructs a shared_ptr that owns the pointer p. Auxiliary data will be allocated with a copy of a and the object will be deleted with a copy of d. Requirements: Deleter and A's copy constructor must not throw. 3.
shared_ptr(const shared_ptr & r);
Copy constructs a shared_ptr. If r is empty, constructs an empty shared_ptr. Otherwise, constructs a shared_ptr that shares ownership with r. Never throws. 4.
shared_ptr(const shared_ptr & other, const pointer & p);
Constructs a shared_ptr that shares ownership with other and stores p. Postconditions: get() == p && use_count() == r.use_count(). Throws: nothing. 5.
template<typename Y> shared_ptr(shared_ptr< Y, VoidAllocator, Deleter > const & r);
If r is empty, constructs an empty shared_ptr. Otherwise, constructs a shared_ptr that shares ownership with r. Never throws. 6.
template<typename Y> explicit shared_ptr(weak_ptr< Y, VoidAllocator, Deleter > const & r);
Constructs a shared_ptr that shares ownership with r and stores a copy of the pointer stored in r. 7.
explicit shared_ptr(shared_ptr && other);
Move-Constructs a shared_ptr that takes ownership of other resource and other is put in default-constructed state. Throws: nothing. 8.
template<typename Y> shared_ptr& operator=(shared_ptr< Y, VoidAllocator, Deleter > const & r);
411
Boost.Interprocess
9.
1.
void reset();
4.
Returns the number of shared_ptr objects, *this included, that share ownership with *this, or an unspecied nonnegative value when *this is empty. use_count() is not necessarily efcient. Use only for debugging and testing purposes, not for production code.
412
Boost.Interprocess
10.
Synopsis
// In header: <boost/interprocess/smart_ptr/shared_ptr.hpp> template<typename T, typename ManagedMemory> struct managed_shared_ptr { // types typedef ManagedMemory::template allocator< void >::type void_allocator; typedef ManagedMemory::template deleter< T >::type deleter; typedef shared_ptr< T, void_allocator, deleter > type; };
Description
Returns the type of a shared pointer of type T with the allocator boost::interprocess::allocator allocator and boost::interprocess::deleter deleter that can be constructed in the given managed segment type.
Synopsis
// In header: <boost/interprocess/smart_ptr/shared_ptr.hpp>
template<typename T, typename ManagedMemory> managed_shared_ptr< T, ManagedMemory >::type make_managed_shared_ptr(T * constructed_object, ManagedMemory & managed_memory);
Description
Returns an instance of a shared pointer constructed with the default allocator and deleter from a pointer of type T that has been allocated in the passed managed segment
413
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/smart_ptr/shared_ptr.hpp>
template<typename T, typename ManagedMemory> managed_shared_ptr< T, ManagedMemory >::type make_managed_shared_ptr(T * constructed_object, ManagedMemory & managed_memory, std::nothrow_t);
Description
Returns an instance of a shared pointer constructed with the default allocator and deleter from a pointer of type T that has been allocated in the passed managed segment. Does not throw, return null shared pointer in error.
Header <boost/interprocess/smart_ptr/unique_ptr.hpp>
Describes the smart pointer unique_ptr
namespace boost { namespace interprocess { template<typename T, typename D> class unique_ptr; template<typename T, typename ManagedMemory> struct managed_unique_ptr; template<typename T, typename D> void swap(unique_ptr< T, D > & x, unique_ptr< T, D > & y); template<typename T1, typename D1, typename T2, typename D2> bool operator==(const unique_ptr< T1, D1 > & x, const unique_ptr< T2, D2 > & y); template<typename T1, typename D1, typename T2, typename D2> bool operator!=(const unique_ptr< T1, D1 > & x, const unique_ptr< T2, D2 > & y); template<typename T1, typename D1, typename T2, typename D2> bool operator<(const unique_ptr< T1, D1 > & x, const unique_ptr< T2, D2 > & y); template<typename T1, typename D1, typename T2, typename D2> bool operator<=(const unique_ptr< T1, D1 > & x, const unique_ptr< T2, D2 > & y); template<typename T1, typename D1, typename T2, typename D2> bool operator>(const unique_ptr< T1, D1 > & x, const unique_ptr< T2, D2 > & y); template<typename T1, typename D1, typename T2, typename D2> bool operator>=(const unique_ptr< T1, D1 > & x, const unique_ptr< T2, D2 > & y); template<typename T, typename ManagedMemory> managed_unique_ptr< T, ManagedMemory >::type make_managed_unique_ptr(T *, ManagedMemory &); } }
414
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/smart_ptr/unique_ptr.hpp> template<typename T, typename D> class unique_ptr { public: // types typedef T element_type; typedef D deleter_type; typedef unspecified pointer; // construct/copy/destruct unique_ptr(); explicit unique_ptr(pointer); unique_ptr(pointer, unspecified); unique_ptr(unique_ptr &&); template<typename U, typename E> unique_ptr(unique_ptr &&, unspecified = nat()); unique_ptr& operator=(unique_ptr &&); template<typename U, typename E> unique_ptr& operator=(unique_ptr &&); unique_ptr& operator=(int nat::*); ~unique_ptr(); // public member functions unspecified operator*() const; pointer operator->() const; pointer get() const; deleter_reference get_deleter(); deleter_const_reference get_deleter() const; operator int nat::*() const; pointer release(); void reset(pointer = 0); void swap(unique_ptr &); };
Description
Template unique_ptr stores a pointer to an object and deletes that object using the associated deleter when it is itself destroyed (such as when leaving block scope. The unique_ptr provides a semantics of strict ownership. A unique_ptr owns the object it holds a pointer to. A unique_ptr is not CopyConstructible, nor CopyAssignable, however it is MoveConstructible and Move-Assignable. The uses of unique_ptr include providing exception safety for dynamically allocated memory, passing ownership of dynamically allocated memory to a function, and returning dynamically allocated memory from a function A client-supplied template argument D must be a function pointer or functor for which, given a value d of type D and a pointer ptr to a type T*, the expression d(ptr) is valid and has the effect of deallocating the pointer as appropriate for that deleter. D may also be an lvalue-reference to a deleter. If the deleter D maintains state, it is intended that this state stay with the associated pointer as ownership is transferred from unique_ptr to unique_ptr. The deleter state need never be copied, only moved or swapped as pointer ownership is moved around. That is, the deleter need only be MoveConstructible, MoveAssignable, and Swappable, and need not be CopyConstructible (unless copied into the unique_ptr) nor CopyAssignable.
unique_ptr public construct/copy/destruct
1.
unique_ptr();
415
Boost.Interprocess
Requires: D must be default constructible, and that construction must not throw an exception. D must not be a reference type. Effects: Constructs a unique_ptr which owns nothing. Postconditions: get() == 0. get_deleter() returns a reference to a default constructed deleter D. Throws: nothing. 2.
explicit unique_ptr(pointer p);
Requires: The expression D()(p) must be well formed. The default constructor of D must not throw an exception. D must not be a reference type. Effects: Constructs a unique_ptr which owns p. Postconditions: get() == p. get_deleter() returns a reference to a default constructed deleter D. Throws: nothing. 3.
unique_ptr(pointer p, unspecified d);
Requires: The expression d(p) must be well formed. Postconditions: get() == p. get_deleter() returns a reference to the internally stored deleter. If D is a reference type then get_deleter() returns a reference to the lvalue d. Throws: nothing. 4.
unique_ptr(unique_ptr && u);
Requires: If the deleter is not a reference type, construction of the deleter D from an lvalue D must not throw an exception. Effects: Constructs a unique_ptr which owns the pointer which u owns (if any). If the deleter is not a reference type, it is move constructed from u's deleter, otherwise the reference is copy constructed from u's deleter. After the construction, u no longer owns a pointer. [ Note: The deleter constructor can be implemented with boost::forward<D>. -end note ] Postconditions: get() == value u.get() had before the construction. get_deleter() returns a reference to the internally stored deleter which was constructed from u.get_deleter(). If D is a reference type then get_- deleter() and u.get_deleter() both reference the same lvalue deleter. Throws: nothing. 5.
template<typename U, typename E> unique_ptr(unique_ptr && u, unspecified = nat());
Requires: If D is not a reference type, construction of the deleter D from an rvalue of type E must be well formed and not throw an exception. If D is a reference type, then E must be the same type as D (diagnostic required). unique_ptr<U, E>::pointer must be implicitly convertible to pointer. Effects: Constructs a unique_ptr which owns the pointer which u owns (if any). If the deleter is not a reference type, it is move constructed from u's deleter, otherwise the reference is copy constructed from u's deleter. After the construction, u no longer owns a pointer.
416
Boost.Interprocess
postconditions get() == value u.get() had before the construction, modulo any required offset adjustments resulting from the cast from U* to T*. get_deleter() returns a reference to the internally stored deleter which was constructed from u.get_deleter(). Throws: nothing. 6.
unique_ptr& operator=(unique_ptr && u);
Requires: Assignment of the deleter D from an rvalue D must not throw an exception. Effects: reset(u.release()) followed by a move assignment from u's deleter to this deleter. Postconditions: This unique_ptr now owns the pointer which u owned, and u no longer owns it. Returns: *this. Throws: nothing. 7.
template<typename U, typename E> unique_ptr& operator=(unique_ptr && u);
Requires: Assignment of the deleter D from an rvalue D must not throw an exception. U* must be implicitly convertible to T*. Effects: reset(u.release()) followed by a move assignment from u's deleter to this deleter. If either D or E is a reference type, then the referenced lvalue deleter participates in the move assignment. Postconditions: This unique_ptr now owns the pointer which u owned, and u no longer owns it. Returns: *this. Throws: nothing. 8.
unique_ptr& operator=(int nat::*);
Assigns from the literal 0 or NULL. Effects: reset(). Postcondition: get() == 0 Returns: *this. Throws: nothing. 9.
~unique_ptr();
1.
417
Boost.Interprocess
Returns: An unspecied value that, when used in boolean contexts, is equivalent to get() != 0. Throws: nothing. 7.
pointer release();
Postcondition: get() == 0. Returns: The value get() had at the start of the call to release. Throws: nothing. 8.
void reset(pointer p = 0);
Effects: If p == get() there are no effects. Otherwise get_deleter()(get()). Postconditions: get() == p. Throws: nothing. 9.
void swap(unique_ptr & u);
Requires: The deleter D is Swappable and will not throw an exception under swap. Effects: The stored pointers of this and u are exchanged. The stored deleters are swapped (unqualied). Throws: nothing.
418
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/smart_ptr/unique_ptr.hpp> template<typename T, typename ManagedMemory> struct managed_unique_ptr { // types typedef unique_ptr< T, typename ManagedMemory::template deleter< T >::type > type; };
Description
Returns the type of a unique pointer of type T with boost::interprocess::deleter deleter that can be constructed in the given managed segment type.
Synopsis
// In header: <boost/interprocess/smart_ptr/unique_ptr.hpp>
template<typename T, typename ManagedMemory> managed_unique_ptr< T, ManagedMemory >::type make_managed_unique_ptr(T * constructed_object, ManagedMemory & managed_memory);
Description
Returns an instance of a unique pointer constructed with boost::interproces::deleter from a pointer of type T that has been allocated in the passed managed segment
Header <boost/interprocess/smart_ptr/weak_ptr.hpp>
Describes the smart pointer weak_ptr.
namespace boost { namespace interprocess { template<typename T, typename A, typename D> class weak_ptr; template<typename T, typename ManagedMemory> struct managed_weak_ptr; template<typename T, typename A, typename D, typename U, typename A2, typename D2> bool operator<(weak_ptr< T, A, D > const & a, weak_ptr< U, A2, D2 > const & b); template<typename T, typename A, typename D> void swap(weak_ptr< T, A, D > & a, weak_ptr< T, A, D > & b); template<typename T, typename ManagedMemory> managed_weak_ptr< T, ManagedMemory >::type make_managed_weak_ptr(T *, ManagedMemory &); } }
419
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/smart_ptr/weak_ptr.hpp> template<typename T, typename A, typename D> class weak_ptr { public: // types typedef T element_type; typedef T value_type; // construct/copy/destruct weak_ptr(); template<typename Y> weak_ptr(weak_ptr< Y, A, D > const &); template<typename Y> weak_ptr(shared_ptr< Y, A, D > const &); template<typename Y> weak_ptr& operator=(weak_ptr< Y, A, D > const &); template<typename Y> weak_ptr& operator=(shared_ptr< Y, A, D > const &); // public member functions shared_ptr< T, A, D > lock() const; long use_count() const; bool expired() const; void reset(); void swap(this_type &); };
Description
The weak_ptr class template stores a "weak reference" to an object that's already managed by a shared_ptr. To access the object, a weak_ptr can be converted to a shared_ptr using the shared_ptr constructor or the member function lock. When the last shared_ptr to the object goes away and the object is deleted, the attempt to obtain a shared_ptr from the weak_ptr instances that refer to the deleted object will fail: the constructor will throw an exception of type bad_weak_ptr, and weak_ptr::lock will return an empty shared_ptr. Every weak_ptr meets the CopyConstructible and Assignable requirements of the C++ Standard Library, and so can be used in standard library containers. Comparison operators are supplied so that weak_ptr works with the standard library's associative containers. weak_ptr operations never throw exceptions. The class template is parameterized on T, the type of the object pointed to.
weak_ptr public construct/copy/destruct
1.
weak_ptr();
Effects: If r is empty, constructs an empty weak_ptr; otherwise, constructs a weak_ptr that shares ownership with r as if by storing a copy of the pointer stored in r. Postconditions: use_count() == r.use_count().
420
Boost.Interprocess
Throws: nothing. 3.
template<typename Y> weak_ptr(shared_ptr< Y, A, D > const & r);
Effects: If r is empty, constructs an empty weak_ptr; otherwise, constructs a weak_ptr that shares ownership with r as if by storing a copy of the pointer stored in r. Postconditions: use_count() == r.use_count(). Throws: nothing. 4.
template<typename Y> weak_ptr& operator=(weak_ptr< Y, A, D > const & r);
Effects: Equivalent to weak_ptr(r).swap(*this). Throws: nothing. Notes: The implementation is free to meet the effects (and the implied guarantees) via different means, without creating a temporary. 5.
template<typename Y> weak_ptr& operator=(shared_ptr< Y, A, D > const & r);
Effects: Equivalent to weak_ptr(r).swap(*this). Throws: nothing. Notes: The implementation is free to meet the effects (and the implied guarantees) via different means, without creating a temporary.
weak_ptr public member functions
1.
Returns: 0 if *this is empty; otherwise, the number of shared_ptr objects that share ownership with *this. Throws: nothing. Notes: use_count() is not necessarily efcient. Use only for debugging and testing purposes, not for production code. 3.
bool expired() const;
Returns: Returns: use_count() == 0. Throws: nothing. Notes: expired() may be faster than use_count(). 4.
void reset();
421
Boost.Interprocess
5.
Effects: Exchanges the contents of the two smart pointers. Throws: nothing.
Synopsis
// In header: <boost/interprocess/smart_ptr/weak_ptr.hpp> template<typename T, typename ManagedMemory> struct managed_weak_ptr { // types typedef weak_ptr< T, typename ManagedMemory::template allocator< void >::type, typename Man agedMemory::template deleter< T >::type > type; };
Description
Returns the type of a weak pointer of type T with the allocator boost::interprocess::allocator allocator and boost::interprocess::deleter deleter that can be constructed in the given managed segment type.
Synopsis
// In header: <boost/interprocess/smart_ptr/weak_ptr.hpp>
template<typename T, typename ManagedMemory> managed_weak_ptr< T, ManagedMemory >::type make_managed_weak_ptr(T * constructed_object, ManagedMemory & managed_memory);
Description
Returns an instance of a weak pointer constructed with the default allocator and deleter from a pointer of type T that has been allocated in the passed managed segment
Header <boost/interprocess/streams/bufferstream.hpp>
This le denes basic_bufferbuf, basic_ibufferstream, basic_obufferstream, and basic_bufferstream classes. These classes represent streamsbufs and streams whose sources or destinations are xed size character buffers.
422
Boost.Interprocess
namespace boost { namespace interprocess { template<typename CharT, template<typename CharT, template<typename CharT, template<typename CharT, typedef typedef typedef typedef typedef typedef typedef typedef } }
basic_bufferbuf< char > bufferbuf; basic_bufferstream< char > bufferstream; basic_ibufferstream< char > ibufferstream; basic_obufferstream< char > obufferstream; basic_bufferbuf< wchar_t > wbufferbuf; basic_bufferstream< wchar_t > wbufferstream; basic_ibufferstream< wchar_t > wibufferstream; basic_obufferstream< wchar_t > wobufferstream;
Synopsis
// In header: <boost/interprocess/streams/bufferstream.hpp> template<typename CharT, typename CharTraits> class basic_bufferbuf : public std::basic_streambuf< CharT, CharTraits > { public: // types typedef CharT char_type; typedef CharTraits::int_type int_type; typedef CharTraits::pos_type pos_type; typedef CharTraits::off_type off_type; typedef CharTraits traits_type; typedef std::basic_streambuf< char_type, traits_type > base_t; // construct/copy/destruct explicit basic_bufferbuf(std::ios_base::openmode = std::ios_base::in|std::ios_base::out); explicit basic_bufferbuf(CharT *, std::size_t, std::ios_base::openmode = std::ios_base::in|std::ios_base::out); ~basic_bufferbuf(); // public member functions std::pair< CharT *, std::size_t > buffer() const; void buffer(CharT *, std::size_t); };
Description
A streambuf class that controls the transmission of elements to and from a basic_xbufferstream. The elements are transmitted from a to a xed size buffer
basic_bufferbuf public construct/copy/destruct
1.
423
Boost.Interprocess
2.
1.
Returns the pointer and size of the internal buffer. Does not throw. 2.
void buffer(CharT * buffer, std::size_t length);
Synopsis
// In header: <boost/interprocess/streams/bufferstream.hpp> template<typename CharT, typename CharTraits> class basic_ibufferstream : public std::basic_istream< CharT, CharTraits > { public: // types typedef std::basic_ios< CharT, CharTraits >::char_type char_type; typedef std::basic_ios< char_type, CharTraits >::int_type int_type; typedef std::basic_ios< char_type, CharTraits >::pos_type pos_type; typedef std::basic_ios< char_type, CharTraits >::off_type off_type; typedef std::basic_ios< char_type, CharTraits >::traits_type traits_type; // construct/copy/destruct basic_ibufferstream(std::ios_base::openmode = std::ios_base::in); basic_ibufferstream(const CharT *, std::size_t, std::ios_base::openmode = std::ios_base::in); ~basic_ibufferstream(); // public member functions basic_bufferbuf< CharT, CharTraits > * rdbuf() const; std::pair< const CharT *, std::size_t > buffer() const; void buffer(const CharT *, std::size_t); };
Description
A basic_istream class that uses a xed size character buffer as its formatting buffer.
basic_ibufferstream public construct/copy/destruct
1.
424
Boost.Interprocess
1.
Returns the pointer and size of the internal buffer. Does not throw. 3.
void buffer(const CharT * buffer, std::size_t length);
Sets the underlying buffer to a new value. Resets stream position. Does not throw.
Synopsis
// In header: <boost/interprocess/streams/bufferstream.hpp> template<typename CharT, typename CharTraits> class basic_obufferstream : public std::basic_ostream< CharT, CharTraits > { public: // types typedef std::basic_ios< CharT, CharTraits >::char_type char_type; typedef std::basic_ios< char_type, CharTraits >::int_type int_type; typedef std::basic_ios< char_type, CharTraits >::pos_type pos_type; typedef std::basic_ios< char_type, CharTraits >::off_type off_type; typedef std::basic_ios< char_type, CharTraits >::traits_type traits_type; // construct/copy/destruct basic_obufferstream(std::ios_base::openmode = std::ios_base::out); basic_obufferstream(CharT *, std::size_t, std::ios_base::openmode = std::ios_base::out); ~basic_obufferstream(); // public member functions basic_bufferbuf< CharT, CharTraits > * rdbuf() const; std::pair< CharT *, std::size_t > buffer() const; void buffer(CharT *, std::size_t); };
425
Boost.Interprocess
Description
A basic_ostream class that uses a xed size character buffer as its formatting buffer.
basic_obufferstream public construct/copy/destruct
1.
1.
Returns the pointer and size of the internal buffer. Does not throw. 3.
void buffer(CharT * buffer, std::size_t length);
Sets the underlying buffer to a new value. Resets stream position. Does not throw.
426
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/streams/bufferstream.hpp> template<typename CharT, typename CharTraits> class basic_bufferstream : public std::basic_iostream< CharT, CharTraits > { public: // types typedef std::basic_ios< CharT, CharTraits >::char_type char_type; typedef std::basic_ios< char_type, CharTraits >::int_type int_type; typedef std::basic_ios< char_type, CharTraits >::pos_type pos_type; typedef std::basic_ios< char_type, CharTraits >::off_type off_type; typedef std::basic_ios< char_type, CharTraits >::traits_type traits_type; // construct/copy/destruct basic_bufferstream(std::ios_base::openmode = std::ios_base::in|std::ios_base::out); basic_bufferstream(CharT *, std::size_t, std::ios_base::openmode = std::ios_base::in|std::ios_base::out); ~basic_bufferstream(); // public member functions basic_bufferbuf< CharT, CharTraits > * rdbuf() const; std::pair< CharT *, std::size_t > buffer() const; void buffer(CharT *, std::size_t); };
Description
A basic_iostream class that uses a xed size character buffer as its formatting buffer.
basic_bufferstream public construct/copy/destruct
1.
1.
Returns the pointer and size of the internal buffer. Does not throw. 3.
void buffer(CharT * buffer, std::size_t length);
427
Boost.Interprocess
Sets the underlying buffer to a new value. Resets stream position. Does not throw.
Header <boost/interprocess/streams/vectorstream.hpp>
This le denes basic_vectorbuf, basic_ivectorstream, basic_ovectorstream, and basic_vectorstreamclasses. These classes represent streamsbufs and streams whose sources or destinations are STL-like vectors that can be swapped with external vectors to avoid unnecessary allocations/copies.
namespace boost { namespace interprocess { template<typename CharVector, typename CharTraits> class basic_vectorbuf; template<typename CharVector, typename CharTraits> class std; template<typename CharVector, typename CharTraits> class basic_vectorstream; } }
Synopsis
// In header: <boost/interprocess/streams/vectorstream.hpp> template<typename CharVector, typename CharTraits> class basic_vectorbuf : public std::basic_streambuf< CharVector::value_type, CharTraits > { public: // types typedef CharVector vector_type; typedef CharVector::value_type char_type; typedef CharTraits::int_type int_type; typedef CharTraits::pos_type pos_type; typedef CharTraits::off_type off_type; typedef CharTraits traits_type; // construct/copy/destruct explicit basic_vectorbuf(std::ios_base::openmode = std::ios_base::in|std::ios_base::out); template<typename VectorParameter> explicit basic_vectorbuf(const VectorParameter &, std::ios_base::openmode = std::ios_base::in|std::ios_base::out); ~basic_vectorbuf(); // public member functions void swap_vector(vector_type &); const vector_type & vector() const; void reserve(typename vector_type::size_type); void clear(); };
Description
A streambuf class that controls the transmission of elements to and from a basic_ivectorstream, basic_ovectorstream or basic_vectorstream. It holds a character vector specied by CharVector template parameter as its formatting buffer. The vector must have contiguous storage, like std::vector, boost::interprocess::vector or boost::interprocess::basic_string
428
Boost.Interprocess
1.
1.
Swaps the underlying vector with the passed vector. This function resets the read/write position in the stream. Does not throw. 2.
const vector_type & vector() const;
Preallocates memory from the internal vector. Resets the stream to the rst position. Throws if the internals vector's memory allocation throws. 4.
void clear();
Calls clear() method of the internal vector. Resets the stream to the rst position.
429
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/streams/vectorstream.hpp> template<typename CharVector, typename CharTraits> class std : private std::basic_ostream< CharVector::value_type, CharTraits >, private std::basic_istream< CharVector::value_type, CharTraits > { public: // types typedef CharVector typedef std::basic_ios< typename CharVector::value_type, CharTraits >::char_type typedef std::basic_ios< char_type, CharTraits >::int_type typedef std::basic_ios< char_type, CharTraits >::pos_type typedef std::basic_ios< char_type, CharTraits >::off_type typedef std::basic_ios< char_type, CharTraits >::traits_type typedef CharVector typedef std::basic_ios< typename CharVector::value_type, CharTraits >::char_type typedef std::basic_ios< char_type, CharTraits >::int_type typedef std::basic_ios< char_type, CharTraits >::pos_type typedef std::basic_ios< char_type, CharTraits >::off_type typedef std::basic_ios< char_type, CharTraits >::traits_type // public member functions basic_ivectorstream(std::ios_base::openmode = std::ios_base::in); template<typename VectorParameter> basic_ivectorstream(const VectorParameter &, std::ios_base::openmode = std::ios_base::in); ~basic_ivectorstream(); basic_vectorbuf< CharVector, CharTraits > * rdbuf() const; void swap_vector(vector_type &); const vector_type & vector() const; void reserve(typename vector_type::size_type); void clear(); basic_ovectorstream(std::ios_base::openmode = std::ios_base::out); template<typename VectorParameter> basic_ovectorstream(const VectorParameter &, std::ios_base::openmode = std::ios_base::out); ~basic_ovectorstream(); basic_vectorbuf< CharVector, CharTraits > * rdbuf() const; void swap_vector(vector_type &); const vector_type & vector() const; void reserve(typename vector_type::size_type); };
vector_type; char_type; int_type; pos_type; off_type; traits_type; vector_type; char_type; int_type; pos_type; off_type; traits_type;
Description
A basic_istream class that holds a character vector specied by CharVector template parameter as its formatting buffer. The vector must have contiguous storage, like std::vector, boost::interprocess::vector or boost::interprocess::basic_string A basic_ostream class that holds a character vector specied by CharVector template parameter as its formatting buffer. The vector must have contiguous storage, like std::vector, boost::interprocess::vector or boost::interprocess::basic_string
std public member functions
1.
430
Boost.Interprocess
2.
4.
Swaps the underlying vector with the passed vector. This function resets the read position in the stream. Does not throw. 6.
const vector_type & vector() const;
Calls reserve() method of the internal vector. Resets the stream to the rst position. Throws if the internals vector's reserve throws. 8.
void clear();
Calls clear() method of the internal vector. Resets the stream to the rst position. 9.
basic_ovectorstream(std::ios_base::openmode mode = std::ios_base::out);
12.
Swaps the underlying vector with the passed vector. This function resets the write position in the stream. Does not throw.
431
Boost.Interprocess
14.
Returns a const reference to the internal vector. Does not throw. 15.
void reserve(typename vector_type::size_type size);
Calls reserve() method of the internal vector. Resets the stream to the rst position. Throws if the internals vector's reserve throws.
Synopsis
// In header: <boost/interprocess/streams/vectorstream.hpp> template<typename CharVector, typename CharTraits> class basic_vectorstream : public std::basic_iostream< CharVector::value_type, CharTraits > { public: // types typedef CharVector vector_type; typedef std::basic_ios< typename CharVector::value_type, CharTraits >::char_type char_type; typedef std::basic_ios< char_type, CharTraits >::int_type int_type; typedef std::basic_ios< char_type, CharTraits >::pos_type pos_type; typedef std::basic_ios< char_type, CharTraits >::off_type off_type; typedef std::basic_ios< char_type, CharTraits >::traits_type traits_type; // construct/copy/destruct basic_vectorstream(std::ios_base::openmode = std::ios_base::in|std::ios_base::out); template<typename VectorParameter> basic_vectorstream(const VectorParameter &, std::ios_base::openmode = std::ios_base::in|std::ios_base::out); ~basic_vectorstream(); // public member functions basic_vectorbuf< CharVector, CharTraits > * rdbuf() const; void swap_vector(vector_type &); const vector_type & vector() const; void reserve(typename vector_type::size_type); void clear(); };
Description
A basic_iostream class that holds a character vector specied by CharVector template parameter as its formatting buffer. The vector must have contiguous storage, like std::vector, boost::interprocess::vector or boost::interprocess::basic_string
basic_vectorstream public construct/copy/destruct
1.
432
Boost.Interprocess
2.
1.
2.
Swaps the underlying vector with the passed vector. This function resets the read/write position in the stream. Does not throw. 3.
const vector_type & vector() const;
Calls reserve() method of the internal vector. Resets the stream to the rst position. Throws if the internals vector's reserve throws. 5.
void clear();
Calls clear() method of the internal vector. Resets the stream to the rst position.
Header <boost/interprocess/sync/file_lock.hpp>
Describes a class that wraps le locking capabilities.
namespace boost { namespace interprocess { class file_lock; } }
Class file_lock
boost::interprocess::le_lock
433
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/sync/file_lock.hpp>
class file_lock { public: // construct/copy/destruct file_lock(); file_lock(const char *); file_lock(file_lock &&); file_lock& operator=(file_lock &&); ~file_lock(); // public member functions void swap(file_lock &); void lock(); bool try_lock(); bool timed_lock(const boost::posix_time::ptime &); void unlock(); void lock_sharable(); bool try_lock_sharable(); bool timed_lock_sharable(const boost::posix_time::ptime &); void unlock_sharable(); };
Description
A le lock, is a mutual exclusion utility similar to a mutex using a le. A le lock has sharable and exclusive locking capabilities and can be used with scoped_lock and sharable_lock classes. A le lock can't guarantee synchronization between threads of the same process so just use le locks to synchronize threads from different processes.
file_lock public construct/copy/destruct
1.
file_lock();
Opens a le lock. Throws interprocess_exception if the le does not exist or there are no operating system resources. 3.
file_lock(file_lock && moved);
Moves the ownership of "moved"'s le mapping object to *this. After the call, "moved" does not represent any le mapping object. Does not throw 4.
file_lock& operator=(file_lock && moved);
Moves the ownership of "moved"'s le mapping to *this. After the call, "moved" does not represent any le mapping. Does not throw 5.
~file_lock();
434
Boost.Interprocess
1.
Effects: The calling thread tries to obtain exclusive ownership of the mutex, and if another thread has exclusive, or sharable ownership of the mutex, it waits until it can obtain the ownership. Throws: interprocess_exception on error. 3.
bool try_lock();
Effects: The calling thread tries to acquire exclusive ownership of the mutex without waiting. If no other thread has exclusive, or sharable ownership of the mutex this succeeds. Returns: If it can acquire exclusive ownership immediately returns true. If it has to wait, returns false. Throws: interprocess_exception on error. 4.
bool timed_lock(const boost::posix_time::ptime & abs_time);
Effects: The calling thread tries to acquire exclusive ownership of the mutex waiting if necessary until no other thread has exclusive, or sharable ownership of the mutex or abs_time is reached. Returns: If acquires exclusive ownership, returns true. Otherwise returns false. Throws: interprocess_exception on error. 5.
void unlock();
Precondition: The thread must have exclusive ownership of the mutex. Effects: The calling thread releases the exclusive ownership of the mutex. Throws: An exception derived from interprocess_exception on error. 6.
void lock_sharable();
Effects: The calling thread tries to obtain sharable ownership of the mutex, and if another thread has exclusive ownership of the mutex, waits until it can obtain the ownership. Throws: interprocess_exception on error. 7.
bool try_lock_sharable();
Effects: The calling thread tries to acquire sharable ownership of the mutex without waiting. If no other thread has exclusive ownership of the mutex this succeeds. Returns: If it can acquire sharable ownership immediately returns true. If it has to wait, returns false. Throws: interprocess_exception on error. 8.
bool timed_lock_sharable(const boost::posix_time::ptime & abs_time);
Effects: The calling thread tries to acquire sharable ownership of the mutex waiting if necessary until no other thread has exclusive ownership of the mutex or abs_time is reached. Returns: If acquires sharable ownership, returns true. Otherwise returns false. Throws: interprocess_exception on error. 9.
void unlock_sharable();
Precondition: The thread must have sharable ownership of the mutex. Effects: The calling thread releases the sharable ownership of the mutex. Throws: An exception derived from interprocess_exception on error.
435
Boost.Interprocess
Header <boost/interprocess/sync/interprocess_condition.hpp>
Describes process-shared variables interprocess_condition class
namespace boost { namespace interprocess { class interprocess_condition; } namespace posix_time { } }
Class interprocess_condition
boost::interprocess::interprocess_condition
Synopsis
// In header: <boost/interprocess/sync/interprocess_condition.hpp>
class interprocess_condition { public: // construct/copy/destruct interprocess_condition(); ~interprocess_condition(); // public member functions void notify_one(); void notify_all(); template<typename L> void wait(L &); template<typename L, typename Pr> void wait(L &, Pr); template<typename L> bool timed_wait(L &, const boost::posix_time::ptime &); template<typename L, typename Pr> bool timed_wait(L &, const boost::posix_time::ptime &, Pr); };
Description
This class is a condition variable that can be placed in shared memory or memory mapped les. Destroys the object of type std::condition_variable_any Unlike std::condition_variable in C++11, it is NOT safe to invoke the destructor if all threads have been only notied. It is required that they have exited their respective wait functions.
interprocess_condition public construct/copy/destruct
1.
interprocess_condition();
436
Boost.Interprocess
1.
void notify_one();
If there is a thread waiting on *this, change that thread's state to ready. Otherwise there is no effect. 2.
void notify_all();
Change the state of all threads waiting on *this to ready. If there are no waiting threads, notify_all() has no effect. 3.
template<typename L> void wait(L & lock);
Releases the lock on the interprocess_mutex object associated with lock, blocks the current thread of execution until readied by a call to this->notify_one() or this->notify_all(), and then reacquires the lock. 4.
template<typename L, typename Pr> void wait(L & lock, Pr pred);
Releases the lock on the interprocess_mutex object associated with lock, blocks the current thread of execution until readied by a call to this->notify_one() or this->notify_all(), or until time abs_time is reached, and then reacquires the lock. Returns: false if time abs_time is reached, otherwise true. 6.
template<typename L, typename Pr> bool timed_wait(L & lock, const boost::posix_time::ptime & abs_time, Pr pred);
The same as: while (!pred()) { if (!timed_wait(lock, abs_time)) return pred(); } return true;
Header <boost/interprocess/sync/interprocess_condition_any.hpp>
Describes process-shared variables interprocess_condition_any class
namespace boost { namespace interprocess { class interprocess_condition_any; } namespace posix_time { } }
Class interprocess_condition_any
boost::interprocess::interprocess_condition_any
437
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/sync/interprocess_condition_any.hpp>
class interprocess_condition_any { public: // construct/copy/destruct interprocess_condition_any(); ~interprocess_condition_any(); // public member functions void notify_one(); void notify_all(); template<typename L> void wait(L &); template<typename L, typename Pr> void wait(L &, Pr); template<typename L> bool timed_wait(L &, const boost::posix_time::ptime &); template<typename L, typename Pr> bool timed_wait(L &, const boost::posix_time::ptime &, Pr); };
Description
This class is a condition variable that can be placed in shared memory or memory mapped les. The interprocess_condition_any class is a generalization of interprocess_condition. Whereas interprocess_condition works only on Locks with mutex_type == interprocess_mutex interprocess_condition_any can operate on any user-dened lock that meets the BasicLockable requirements (lock()/unlock() member functions). Unlike std::condition_variable_any in C++11, it is NOT safe to invoke the destructor if all threads have been only notied. It is required that they have exited their respective wait functions.
interprocess_condition_any public construct/copy/destruct
1.
interprocess_condition_any();
1.
void notify_one();
If there is a thread waiting on *this, change that thread's state to ready. Otherwise there is no effect. 2.
void notify_all();
Change the state of all threads waiting on *this to ready. If there are no waiting threads, notify_all() has no effect. 3.
template<typename L> void wait(L & lock);
Releases the lock on the interprocess_mutex object associated with lock, blocks the current thread of execution until readied by a call to this->notify_one() or this->notify_all(), and then reacquires the lock.
438
Boost.Interprocess
4.
Releases the lock on the interprocess_mutex object associated with lock, blocks the current thread of execution until readied by a call to this->notify_one() or this->notify_all(), or until time abs_time is reached, and then reacquires the lock. Returns: false if time abs_time is reached, otherwise true. 6.
template<typename L, typename Pr> bool timed_wait(L & lock, const boost::posix_time::ptime & abs_time, Pr pred);
The same as: while (!pred()) { if (!timed_wait(lock, abs_time)) return pred(); } return true;
Header <boost/interprocess/sync/interprocess_mutex.hpp>
Describes a mutex class that can be placed in memory shared by several processes.
namespace boost { namespace interprocess { class interprocess_mutex; } }
Class interprocess_mutex
boost::interprocess::interprocess_mutex
Synopsis
// In header: <boost/interprocess/sync/interprocess_mutex.hpp>
class interprocess_mutex { public: // construct/copy/destruct interprocess_mutex(); ~interprocess_mutex(); // public member functions void lock(); bool try_lock(); bool timed_lock(const boost::posix_time::ptime &); void unlock(); };
Description
Wraps a interprocess_mutex that can be placed in shared memory and can be shared between processes. Allows timed lock tries
439
Boost.Interprocess
1.
interprocess_mutex();
Destructor. If any process uses the mutex after the destructor is called the result is undened. Does not throw.
interprocess_mutex public member functions
1.
void lock();
Effects: The calling thread tries to obtain ownership of the mutex, and if another thread has ownership of the mutex, it waits until it can obtain the ownership. If a thread takes ownership of the mutex the mutex must be unlocked by the same mutex. Throws: interprocess_exception on error. 2.
bool try_lock();
Effects: The calling thread tries to obtain ownership of the mutex, and if another thread has ownership of the mutex returns immediately. Returns: If the thread acquires ownership of the mutex, returns true, if the another thread has ownership of the mutex, returns false. Throws: interprocess_exception on error. 3.
bool timed_lock(const boost::posix_time::ptime & abs_time);
Effects: The calling thread will try to obtain exclusive ownership of the mutex if it can do so in until the specied time is reached. If the mutex supports recursive locking, the mutex must be unlocked the same number of times it is locked. Returns: If the thread acquires ownership of the mutex, returns true, if the timeout expires returns false. Throws: interprocess_exception on error. 4.
void unlock();
Effects: The calling thread releases the exclusive ownership of the mutex. Throws: interprocess_exception on error.
Header <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
Describes interprocess_recursive_mutex and shared_recursive_try_mutex classes
namespace boost { namespace interprocess { class interprocess_recursive_mutex; } }
Class interprocess_recursive_mutex
boost::interprocess::interprocess_recursive_mutex
440
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
class interprocess_recursive_mutex { public: // construct/copy/destruct interprocess_recursive_mutex(); ~interprocess_recursive_mutex(); // public member functions void lock(); bool try_lock(); bool timed_lock(const boost::posix_time::ptime &); void unlock(); };
Description
Wraps a interprocess_mutex that can be placed in shared memory and can be shared between processes. Allows several locking calls by the same process. Allows timed lock tries
interprocess_recursive_mutex public construct/copy/destruct
1.
interprocess_recursive_mutex();
Destructor. If any process uses the mutex after the destructor is called the result is undened. Does not throw.
interprocess_recursive_mutex public member functions
1.
void lock();
Effects: The calling thread tries to obtain ownership of the mutex, and if another thread has ownership of the mutex, it waits until it can obtain the ownership. If a thread takes ownership of the mutex the mutex must be unlocked by the same mutex. The mutex must be unlocked the same number of times it is locked. Throws: interprocess_exception on error. 2.
bool try_lock();
Tries to lock the interprocess_mutex, returns false when interprocess_mutex is already locked, returns true when success. The mutex must be unlocked the same number of times it is locked. Throws: interprocess_exception if a severe error is found 3.
bool timed_lock(const boost::posix_time::ptime & abs_time);
Tries to lock the interprocess_mutex, if interprocess_mutex can't be locked before abs_time time, returns false. The mutex must be unlocked the same number of times it is locked. Throws: interprocess_exception if a severe error is found 4.
void unlock();
441
Boost.Interprocess
Effects: The calling thread releases the exclusive ownership of the mutex. If the mutex supports recursive locking, the mutex must be unlocked the same number of times it is locked. Throws: interprocess_exception on error.
Header <boost/interprocess/sync/interprocess_semaphore.hpp>
Describes a interprocess_semaphore class for inter-process synchronization
namespace boost { namespace interprocess { class interprocess_semaphore; } }
Class interprocess_semaphore
boost::interprocess::interprocess_semaphore
Synopsis
// In header: <boost/interprocess/sync/interprocess_semaphore.hpp>
class interprocess_semaphore { public: // construct/copy/destruct interprocess_semaphore(unsigned int); ~interprocess_semaphore(); // public member functions void post(); void wait(); bool try_wait(); bool timed_wait(const boost::posix_time::ptime &); };
Description
Wraps a interprocess_semaphore that can be placed in shared memory and can be shared between processes. Allows timed lock tries
interprocess_semaphore public construct/copy/destruct
1.
Creates a interprocess_semaphore with the given initial count. interprocess_exception if there is an error. 2.
~interprocess_semaphore();
1.
void post();
442
Boost.Interprocess
Increments the interprocess_semaphore count. If there are processes/threads blocked waiting for the interprocess_semaphore, then one of these processes will return successfully from its wait function. If there is an error an interprocess_exception exception is thrown. 2.
void wait();
Decrements the interprocess_semaphore. If the interprocess_semaphore value is not greater than zero, then the calling process/thread blocks until it can decrement the counter. If there is an error an interprocess_exception exception is thrown. 3.
bool try_wait();
Decrements the interprocess_semaphore if the interprocess_semaphore's value is greater than zero and returns true. If the value is not greater than zero returns false. If there is an error an interprocess_exception exception is thrown. 4.
bool timed_wait(const boost::posix_time::ptime & abs_time);
Decrements the interprocess_semaphore if the interprocess_semaphore's value is greater than zero and returns true. Otherwise, waits for the interprocess_semaphore to the posted or the timeout expires. If the timeout expires, the function returns false. If the interprocess_semaphore is posted the function returns true. If there is an error throws sem_exception
Header <boost/interprocess/sync/interprocess_sharable_mutex.hpp>
Describes interprocess_sharable_mutex class
namespace boost { namespace interprocess { class interprocess_sharable_mutex; } }
Class interprocess_sharable_mutex
boost::interprocess::interprocess_sharable_mutex
443
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/sync/interprocess_sharable_mutex.hpp>
class interprocess_sharable_mutex { public: // construct/copy/destruct interprocess_sharable_mutex(const interprocess_sharable_mutex &); interprocess_sharable_mutex(); interprocess_sharable_mutex& operator=(const interprocess_sharable_mutex &); ~interprocess_sharable_mutex(); // public member functions void lock(); bool try_lock(); bool timed_lock(const boost::posix_time::ptime &); void unlock(); void lock_sharable(); bool try_lock_sharable(); bool timed_lock_sharable(const boost::posix_time::ptime &); void unlock_sharable(); };
Description
Wraps a interprocess_sharable_mutex that can be placed in shared memory and can be shared between processes. Allows timed lock tries
interprocess_sharable_mutex public construct/copy/destruct
1.
2.
interprocess_sharable_mutex();
4.
~interprocess_sharable_mutex();
1.
void lock();
Effects: The calling thread tries to obtain exclusive ownership of the mutex, and if another thread has exclusive or sharable ownership of the mutex, it waits until it can obtain the ownership. Throws: interprocess_exception on error. 2.
bool try_lock();
444
Boost.Interprocess
Effects: The calling thread tries to acquire exclusive ownership of the mutex without waiting. If no other thread has exclusive or sharable ownership of the mutex this succeeds. Returns: If it can acquire exclusive ownership immediately returns true. If it has to wait, returns false. Throws: interprocess_exception on error. 3.
bool timed_lock(const boost::posix_time::ptime & abs_time);
Effects: The calling thread tries to acquire exclusive ownership of the mutex waiting if necessary until no other thread has exclusive or sharable ownership of the mutex or abs_time is reached. Returns: If acquires exclusive ownership, returns true. Otherwise returns false. Throws: interprocess_exception on error. 4.
void unlock();
Precondition: The thread must have exclusive ownership of the mutex. Effects: The calling thread releases the exclusive ownership of the mutex. Throws: An exception derived from interprocess_exception on error. 5.
void lock_sharable();
Effects: The calling thread tries to obtain sharable ownership of the mutex, and if another thread has exclusive ownership of the mutex, waits until it can obtain the ownership. Throws: interprocess_exception on error. 6.
bool try_lock_sharable();
Effects: The calling thread tries to acquire sharable ownership of the mutex without waiting. If no other thread has exclusive ownership of the mutex this succeeds. Returns: If it can acquire sharable ownership immediately returns true. If it has to wait, returns false. Throws: interprocess_exception on error. 7.
bool timed_lock_sharable(const boost::posix_time::ptime & abs_time);
Effects: The calling thread tries to acquire sharable ownership of the mutex waiting if necessary until no other thread has exclusive ownership of the mutex or abs_time is reached. Returns: If acquires sharable ownership, returns true. Otherwise returns false. Throws: interprocess_exception on error. 8.
void unlock_sharable();
Precondition: The thread must have sharable ownership of the mutex. Effects: The calling thread releases the sharable ownership of the mutex. Throws: An exception derived from interprocess_exception on error.
Header <boost/interprocess/sync/interprocess_upgradable_mutex.hpp>
Describes interprocess_upgradable_mutex class
namespace boost { namespace interprocess { class interprocess_upgradable_mutex; } }
Class interprocess_upgradable_mutex
boost::interprocess::interprocess_upgradable_mutex
445
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/sync/interprocess_upgradable_mutex.hpp>
class interprocess_upgradable_mutex { public: // construct/copy/destruct interprocess_upgradable_mutex(const interprocess_upgradable_mutex &); interprocess_upgradable_mutex(); interprocess_upgradable_mutex& operator=(const interprocess_upgradable_mutex &); ~interprocess_upgradable_mutex(); // public member functions void lock(); bool try_lock(); bool timed_lock(const boost::posix_time::ptime &); void unlock(); void lock_sharable(); bool try_lock_sharable(); bool timed_lock_sharable(const boost::posix_time::ptime &); void unlock_sharable(); void lock_upgradable(); bool try_lock_upgradable(); bool timed_lock_upgradable(const boost::posix_time::ptime &); void unlock_upgradable(); void unlock_and_lock_upgradable(); void unlock_and_lock_sharable(); void unlock_upgradable_and_lock_sharable(); void unlock_upgradable_and_lock(); bool try_unlock_upgradable_and_lock(); *bool timed_unlock_upgradable_and_lock(const boost::posix_time::ptime &); bool try_unlock_sharable_and_lock(); bool try_unlock_sharable_and_lock_upgradable(); };
Description
Wraps a interprocess_upgradable_mutex that can be placed in shared memory and can be shared between processes. Allows timed lock tries
interprocess_upgradable_mutex public construct/copy/destruct
1.
2.
interprocess_upgradable_mutex();
4.
~interprocess_upgradable_mutex();
446
Boost.Interprocess
1.
void lock();
Effects: The calling thread tries to obtain exclusive ownership of the mutex, and if another thread has exclusive, sharable or upgradable ownership of the mutex, it waits until it can obtain the ownership. Throws: interprocess_exception on error. 2.
bool try_lock();
Effects: The calling thread tries to acquire exclusive ownership of the mutex without waiting. If no other thread has exclusive, sharable or upgradable ownership of the mutex this succeeds. Returns: If it can acquire exclusive ownership immediately returns true. If it has to wait, returns false. Throws: interprocess_exception on error. 3.
bool timed_lock(const boost::posix_time::ptime & abs_time);
Effects: The calling thread tries to acquire exclusive ownership of the mutex waiting if necessary until no other thread has exclusive, sharable or upgradable ownership of the mutex or abs_time is reached. Returns: If acquires exclusive ownership, returns true. Otherwise returns false. Throws: interprocess_exception on error. 4.
void unlock();
Precondition: The thread must have exclusive ownership of the mutex. Effects: The calling thread releases the exclusive ownership of the mutex. Throws: An exception derived from interprocess_exception on error. 5.
void lock_sharable();
Effects: The calling thread tries to obtain sharable ownership of the mutex, and if another thread has exclusive ownership of the mutex, waits until it can obtain the ownership. Throws: interprocess_exception on error. 6.
bool try_lock_sharable();
Effects: The calling thread tries to acquire sharable ownership of the mutex without waiting. If no other thread has exclusive ownership of the mutex this succeeds. Returns: If it can acquire sharable ownership immediately returns true. If it has to wait, returns false. Throws: interprocess_exception on error. 7.
bool timed_lock_sharable(const boost::posix_time::ptime & abs_time);
Effects: The calling thread tries to acquire sharable ownership of the mutex waiting if necessary until no other thread has exclusive ownership of the mutex or abs_time is reached. Returns: If acquires sharable ownership, returns true. Otherwise returns false. Throws: interprocess_exception on error. 8.
void unlock_sharable();
Precondition: The thread must have sharable ownership of the mutex. Effects: The calling thread releases the sharable ownership of the mutex. Throws: An exception derived from interprocess_exception on error. 9.
void lock_upgradable();
Effects: The calling thread tries to obtain upgradable ownership of the mutex, and if another thread has exclusive or upgradable ownership of the mutex, waits until it can obtain the ownership. Throws: interprocess_exception on error.
447
Boost.Interprocess
10.
bool try_lock_upgradable();
Effects: The calling thread tries to acquire upgradable ownership of the mutex without waiting. If no other thread has exclusive or upgradable ownership of the mutex this succeeds. Returns: If it can acquire upgradable ownership immediately returns true. If it has to wait, returns false. Throws: interprocess_exception on error. 11.
bool timed_lock_upgradable(const boost::posix_time::ptime & abs_time);
Effects: The calling thread tries to acquire upgradable ownership of the mutex waiting if necessary until no other thread has exclusive or upgradable ownership of the mutex or abs_time is reached. Returns: If acquires upgradable ownership, returns true. Otherwise returns false. Throws: interprocess_exception on error. 12.
void unlock_upgradable();
Precondition: The thread must have upgradable ownership of the mutex. Effects: The calling thread releases the upgradable ownership of the mutex. Throws: An exception derived from interprocess_exception on error. 13.
void unlock_and_lock_upgradable();
Precondition: The thread must have exclusive ownership of the mutex. Effects: The thread atomically releases exclusive ownership and acquires upgradable ownership. This operation is non-blocking. Throws: An exception derived from interprocess_exception on error. 14.
void unlock_and_lock_sharable();
Precondition: The thread must have exclusive ownership of the mutex. Effects: The thread atomically releases exclusive ownership and acquires sharable ownership. This operation is non-blocking. Throws: An exception derived from interprocess_exception on error. 15.
void unlock_upgradable_and_lock_sharable();
Precondition: The thread must have upgradable ownership of the mutex. Effects: The thread atomically releases upgradable ownership and acquires sharable ownership. This operation is non-blocking. Throws: An exception derived from interprocess_exception on error. 16.
void unlock_upgradable_and_lock();
Precondition: The thread must have upgradable ownership of the mutex. Effects: The thread atomically releases upgradable ownership and acquires exclusive ownership. This operation will block until all threads with sharable ownership release their sharable lock. Throws: An exception derived from interprocess_exception on error. 17.
bool try_unlock_upgradable_and_lock();
Precondition: The thread must have upgradable ownership of the mutex. Effects: The thread atomically releases upgradable ownership and tries to acquire exclusive ownership. This operation will fail if there are threads with sharable ownership, but it will maintain upgradable ownership. Returns: If acquires exclusive ownership, returns true. Otherwise returns false. Throws: An exception derived from interprocess_exception on error. 18.
*bool timed_unlock_upgradable_and_lock(const boost::posix_time::ptime & abs_time);
Precondition: The thread must have upgradable ownership of the mutex. Effects: The thread atomically releases upgradable ownership and tries to acquire exclusive ownership, waiting if necessary until abs_time. This operation will fail if there are threads
448
Boost.Interprocess
with sharable ownership or timeout reaches, but it will maintain upgradable ownership. Returns: If acquires exclusive ownership, returns true. Otherwise returns false. Throws: An exception derived from interprocess_exception on error. 19.
bool try_unlock_sharable_and_lock();
Precondition: The thread must have sharable ownership of the mutex. Effects: The thread atomically releases sharable ownership and tries to acquire exclusive ownership. This operation will fail if there are threads with sharable or upgradable ownership, but it will maintain sharable ownership. Returns: If acquires exclusive ownership, returns true. Otherwise returns false. Throws: An exception derived from interprocess_exception on error. 20.
bool try_unlock_sharable_and_lock_upgradable();
Precondition: The thread must have sharable ownership of the mutex. Effects: The thread atomically releases sharable ownership and tries to acquire upgradable ownership. This operation will fail if there are threads with sharable or upgradable ownership, but it will maintain sharable ownership. Returns: If acquires upgradable ownership, returns true. Otherwise returns false. Throws: An exception derived from interprocess_exception on error.
Header <boost/interprocess/sync/lock_options.hpp>
Describes the lock options with associated with interprocess_mutex lock constructors.
namespace boost { namespace interprocess { struct defer_lock_type; struct try_to_lock_type; struct accept_ownership_type; static const defer_lock_type defer_lock; static const try_to_lock_type try_to_lock; static const accept_ownership_type accept_ownership; } namespace posix_time { } }
Struct defer_lock_type
boost::interprocess::defer_lock_type Type to indicate to a mutex lock constructor that must not lock the mutex.
Synopsis
// In header: <boost/interprocess/sync/lock_options.hpp>
struct defer_lock_type { };
Struct try_to_lock_type
boost::interprocess::try_to_lock_type Type to indicate to a mutex lock constructor that must try to lock the mutex.
449
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/sync/lock_options.hpp>
struct try_to_lock_type { };
Struct accept_ownership_type
boost::interprocess::accept_ownership_type Type to indicate to a mutex lock constructor that the mutex is already locked.
Synopsis
// In header: <boost/interprocess/sync/lock_options.hpp>
struct accept_ownership_type { };
Global defer_lock
boost::interprocess::defer_lock
Synopsis
// In header: <boost/interprocess/sync/lock_options.hpp> static const defer_lock_type defer_lock;
Description
An object indicating that the locking must be deferred.
Global try_to_lock
boost::interprocess::try_to_lock
Synopsis
// In header: <boost/interprocess/sync/lock_options.hpp> static const try_to_lock_type try_to_lock;
Description
An object indicating that a try_lock() operation must be executed.
Global accept_ownership
boost::interprocess::accept_ownership
450
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/sync/lock_options.hpp> static const accept_ownership_type accept_ownership;
Description
An object indicating that the ownership of lockable object must be accepted by the new owner.
Header <boost/interprocess/sync/mutex_family.hpp>
Describes a shared interprocess_mutex family t algorithm used to allocate objects in shared memory.
namespace boost { namespace interprocess { struct mutex_family; struct null_mutex_family; } }
Struct mutex_family
boost::interprocess::mutex_family
Synopsis
// In header: <boost/interprocess/sync/mutex_family.hpp>
Description
Describes interprocess_mutex family to use with Interprocess framework based on boost::interprocess synchronization objects.
Struct null_mutex_family
boost::interprocess::null_mutex_family
Synopsis
// In header: <boost/interprocess/sync/mutex_family.hpp>
451
Boost.Interprocess
Description
Describes interprocess_mutex family to use with Interprocess frameworks based on null operation synchronization objects.
Header <boost/interprocess/sync/named_condition.hpp>
Describes a named condition class for inter-process synchronization
namespace boost { namespace interprocess { class named_condition; } }
Class named_condition
boost::interprocess::named_condition
Synopsis
// In header: <boost/interprocess/sync/named_condition.hpp>
class named_condition { public: // construct/copy/destruct named_condition(create_only_t, const char *, const permissions & = permissions()); named_condition(open_or_create_t, const char *, const permissions & = permissions()); named_condition(open_only_t, const char *); ~named_condition(); // public member functions *void notify_one(); void notify_all(); template<typename L> void wait(L &); template<typename L, typename Pr> void wait(L &, Pr); template<typename L> bool timed_wait(L &, const boost::posix_time::ptime &); template<typename L, typename Pr> bool timed_wait(L &, const boost::posix_time::ptime &, Pr); // public static functions static bool remove(const char *); };
Description
A global condition variable that can be created by name. This condition variable is designed to work with named_mutex and can't be placed in shared memory or memory mapped les.
named_condition public construct/copy/destruct
1.
named_condition(create_only_t create_only, const char * name, const permissions & perm = permissions());
Creates a global condition with a name. If the condition can't be created throws interprocess_exception
452
Boost.Interprocess
2.
named_condition(open_or_create_t open_or_create, const char * name, const permissions & perm = permissions());
Opens or creates a global condition with a name. If the condition is created, this call is equivalent to named_condition(create_only_t, ... ) If the condition is already created, this call is equivalent named_condition(open_only_t, ... ) Does not throw 3.
named_condition(open_only_t open_only, const char * name);
Opens a global condition with a name if that condition is previously created. If it is not previously created this function throws interprocess_exception. 4.
~named_condition();
Destroys *this and indicates that the calling process is nished using the resource. The destructor function will deallocate any system resources allocated by the system for use by this process for this resource. The resource can still be opened again calling the open constructor overload. To erase the resource from the system use remove().
named_condition public member functions
1.
*void notify_one();
If there is a thread waiting on *this, change that thread's state to ready. Otherwise there is no effect. 2.
void notify_all();
Change the state of all threads waiting on *this to ready. If there are no waiting threads, notify_all() has no effect. 3.
template<typename L> void wait(L & lock);
Releases the lock on the named_mutex object associated with lock, blocks the current thread of execution until readied by a call to this->notify_one() or this->notify_all(), and then reacquires the lock. 4.
template<typename L, typename Pr> void wait(L & lock, Pr pred);
Releases the lock on the named_mutex object associated with lock, blocks the current thread of execution until readied by a call to this->notify_one() or this->notify_all(), or until time abs_time is reached, and then reacquires the lock. Returns: false if time abs_time is reached, otherwise true. 6.
template<typename L, typename Pr> bool timed_wait(L & lock, const boost::posix_time::ptime & abs_time, Pr pred);
The same as: while (!pred()) { if (!timed_wait(lock, abs_time)) return pred(); } return true;
453
Boost.Interprocess
1.
Erases a named condition from the system. Returns false on error. Never throws.
Header <boost/interprocess/sync/named_condition_any.hpp>
Describes a named condition class for inter-process synchronization
namespace boost { namespace interprocess { class named_condition_any; } }
Class named_condition_any
boost::interprocess::named_condition_any
Synopsis
// In header: <boost/interprocess/sync/named_condition_any.hpp>
class named_condition_any { public: // construct/copy/destruct named_condition_any(create_only_t, const char *, const permissions & = permissions()); named_condition_any(open_or_create_t, const char *, const permissions & = permissions()); named_condition_any(open_only_t, const char *); ~named_condition_any(); // public member functions *void notify_one(); void notify_all(); template<typename L> void wait(L &); template<typename L, typename Pr> void wait(L &, Pr); template<typename L> bool timed_wait(L &, const boost::posix_time::ptime &); template<typename L, typename Pr> bool timed_wait(L &, const boost::posix_time::ptime &, Pr); // public static functions static bool remove(const char *); };
Description
A global condition variable that can be created by name. This condition variable is designed to work with named_mutex and can't be placed in shared memory or memory mapped les.
454
Boost.Interprocess
1.
Creates a global condition with a name. If the condition can't be created throws interprocess_exception 2.
named_condition_any(open_or_create_t, const char * name, const permissions & perm = permissions());
Opens or creates a global condition with a name. If the condition is created, this call is equivalent to named_condition_any(create_only_t, ... ) If the condition is already created, this call is equivalent named_condition_any(open_only_t, ... ) Does not throw 3.
named_condition_any(open_only_t, const char * name);
Opens a global condition with a name if that condition is previously created. If it is not previously created this function throws interprocess_exception. 4.
~named_condition_any();
Destroys *this and indicates that the calling process is nished using the resource. The destructor function will deallocate any system resources allocated by the system for use by this process for this resource. The resource can still be opened again calling the open constructor overload. To erase the resource from the system use remove().
named_condition_any public member functions
1.
*void notify_one();
If there is a thread waiting on *this, change that thread's state to ready. Otherwise there is no effect. 2.
void notify_all();
Change the state of all threads waiting on *this to ready. If there are no waiting threads, notify_all() has no effect. 3.
template<typename L> void wait(L & lock);
Releases the lock on the named_mutex object associated with lock, blocks the current thread of execution until readied by a call to this->notify_one() or this->notify_all(), and then reacquires the lock. 4.
template<typename L, typename Pr> void wait(L & lock, Pr pred);
Releases the lock on the named_mutex object associated with lock, blocks the current thread of execution until readied by a call to this->notify_one() or this->notify_all(), or until time abs_time is reached, and then reacquires the lock. Returns: false if time abs_time is reached, otherwise true.
455
Boost.Interprocess
6.
template<typename L, typename Pr> bool timed_wait(L & lock, const boost::posix_time::ptime & abs_time, Pr pred);
The same as: while (!pred()) { if (!timed_wait(lock, abs_time)) return pred(); } return true;
named_condition_any public static functions
1.
Erases a named condition from the system. Returns false on error. Never throws.
Header <boost/interprocess/sync/named_mutex.hpp>
Describes a named mutex class for inter-process synchronization
namespace boost { namespace interprocess { class named_mutex; } }
Class named_mutex
boost::interprocess::named_mutex
Synopsis
// In header: <boost/interprocess/sync/named_mutex.hpp>
class named_mutex { public: // construct/copy/destruct named_mutex(create_only_t, const char *, const permissions & = permissions()); named_mutex(open_or_create_t, const char *, const permissions & = permissions()); named_mutex(open_only_t, const char *); ~named_mutex(); // public member functions void unlock(); void lock(); bool try_lock(); bool timed_lock(const boost::posix_time::ptime &); // public static functions static bool remove(const char *); };
Description
A mutex with a global name, so it can be found from different processes. This mutex can't be placed in shared memory, and each process should have it's own named_mutex.
456
Boost.Interprocess
1.
named_mutex(create_only_t create_only, const char * name, const permissions & perm = permissions());
Opens or creates a global mutex with a name. If the mutex is created, this call is equivalent to named_mutex(create_only_t, ... ) If the mutex is already created, this call is equivalent named_mutex(open_only_t, ... ) Does not throw 3.
named_mutex(open_only_t open_only, const char * name);
Opens a global mutex with a name if that mutex is previously created. If it is not previously created this function throws interprocess_exception. 4.
~named_mutex();
Destroys *this and indicates that the calling process is nished using the resource. The destructor function will deallocate any system resources allocated by the system for use by this process for this resource. The resource can still be opened again calling the open constructor overload. To erase the resource from the system use remove().
named_mutex public member functions
1.
void unlock();
Locks interprocess_mutex, sleeps when interprocess_mutex is already locked. Throws interprocess_exception if a severe error is found 3.
bool try_lock();
Tries to lock the interprocess_mutex, returns false when interprocess_mutex is already locked, returns true when success. Throws interprocess_exception if a severe error is found 4.
bool timed_lock(const boost::posix_time::ptime & abs_time);
Tries to lock the interprocess_mutex until time abs_time, Returns false when timeout expires, returns true when locks. Throws interprocess_exception if a severe error is found
named_mutex public static functions
1.
Erases a named mutex from the system. Returns false on error. Never throws.
457
Boost.Interprocess
Header <boost/interprocess/sync/named_recursive_mutex.hpp>
Describes a named named_recursive_mutex class for inter-process synchronization
namespace boost { namespace interprocess { class named_recursive_mutex; } }
Class named_recursive_mutex
boost::interprocess::named_recursive_mutex
Synopsis
// In header: <boost/interprocess/sync/named_recursive_mutex.hpp>
class named_recursive_mutex { public: // construct/copy/destruct named_recursive_mutex(create_only_t, const char *, const permissions & = permissions()); named_recursive_mutex(open_or_create_t, const char *, const permissions & = permissions()); named_recursive_mutex(open_only_t, const char *); ~named_recursive_mutex(); // public member functions void unlock(); void lock(); bool try_lock(); bool timed_lock(const boost::posix_time::ptime &); // public static functions static bool remove(const char *); };
Description
A recursive mutex with a global name, so it can be found from different processes. This mutex can't be placed in shared memory, and each process should have it's own named_recursive_mutex.
named_recursive_mutex public construct/copy/destruct
1.
named_recursive_mutex(create_only_t create_only, const char * name, const permissions & perm = permissions());
Creates a global recursive_mutex with a name. If the recursive_mutex can't be created throws interprocess_exception 2.
named_recursive_mutex(open_or_create_t open_or_create, const char * name, const permissions & perm = permissions());
458
Boost.Interprocess
Opens or creates a global recursive_mutex with a name. If the recursive_mutex is created, this call is equivalent to named_recursive_mutex(create_only_t, ... ) If the recursive_mutex is already created, this call is equivalent named_recursive_mutex(open_only_t, ... ) Does not throw 3.
named_recursive_mutex(open_only_t open_only, const char * name);
Opens a global recursive_mutex with a name if that recursive_mutex is previously created. If it is not previously created this function throws interprocess_exception. 4.
~named_recursive_mutex();
Destroys *this and indicates that the calling process is nished using the resource. The destructor function will deallocate any system resources allocated by the system for use by this process for this resource. The resource can still be opened again calling the open constructor overload. To erase the resource from the system use remove().
named_recursive_mutex public member functions
1.
void unlock();
Locks named_recursive_mutex, sleeps when named_recursive_mutex is already locked. Throws interprocess_exception if a severe error is found. 3.
bool try_lock();
Tries to lock the named_recursive_mutex, returns false when named_recursive_mutex is already locked, returns true when success. Throws interprocess_exception if a severe error is found. 4.
bool timed_lock(const boost::posix_time::ptime & abs_time);
Tries to lock the named_recursive_mutex until time abs_time, Returns false when timeout expires, returns true when locks. Throws interprocess_exception if a severe error is found
named_recursive_mutex public static functions
1.
Header <boost/interprocess/sync/named_semaphore.hpp>
Describes a named semaphore class for inter-process synchronization
namespace boost { namespace interprocess { class named_semaphore; } }
459
Boost.Interprocess
Class named_semaphore
boost::interprocess::named_semaphore
Synopsis
// In header: <boost/interprocess/sync/named_semaphore.hpp>
class named_semaphore { public: // construct/copy/destruct named_semaphore(create_only_t, const char *, unsigned int, const permissions & = permissions()); named_semaphore(open_or_create_t, const char *, unsigned int, const permissions & = permissions()); named_semaphore(open_only_t, const char *); ~named_semaphore(); // public member functions void post(); void wait(); bool try_wait(); bool timed_wait(const boost::posix_time::ptime &); // public static functions static bool remove(const char *); };
Description
A semaphore with a global name, so it can be found from different processes. Allows several resource sharing patterns and efcient acknowledgment mechanisms.
named_semaphore public construct/copy/destruct
1.
named_semaphore(create_only_t, const char * name, unsigned int initialCount, const permissions & perm = permissions());
Creates a global semaphore with a name, and an initial count. If the semaphore can't be created throws interprocess_exception 2.
named_semaphore(open_or_create_t, const char * name, unsigned int initialCount, const permissions & perm = permissions());
Opens or creates a global semaphore with a name, and an initial count. If the semaphore is created, this call is equivalent to named_semaphore(create_only_t, ...) If the semaphore is already created, this call is equivalent to named_semaphore(open_only_t, ... ) and initialCount is ignored. 3.
named_semaphore(open_only_t, const char * name);
Opens a global semaphore with a name if that semaphore is previously. created. If it is not previously created this function throws interprocess_exception. 4.
~named_semaphore();
460
Boost.Interprocess
Destroys *this and indicates that the calling process is nished using the resource. The destructor function will deallocate any system resources allocated by the system for use by this process for this resource. The resource can still be opened again calling the open constructor overload. To erase the resource from the system use remove().
named_semaphore public member functions
1.
void post();
Increments the semaphore count. If there are processes/threads blocked waiting for the semaphore, then one of these processes will return successfully from its wait function. If there is an error an interprocess_exception exception is thrown. 2.
void wait();
Decrements the semaphore. If the semaphore value is not greater than zero, then the calling process/thread blocks until it can decrement the counter. If there is an error an interprocess_exception exception is thrown. 3.
bool try_wait();
Decrements the semaphore if the semaphore's value is greater than zero and returns true. If the value is not greater than zero returns false. If there is an error an interprocess_exception exception is thrown. 4.
bool timed_wait(const boost::posix_time::ptime & abs_time);
Decrements the semaphore if the semaphore's value is greater than zero and returns true. Otherwise, waits for the semaphore to the posted or the timeout expires. If the timeout expires, the function returns false. If the semaphore is posted the function returns true. If there is an error throws sem_exception
named_semaphore public static functions
1.
Erases a named semaphore from the system. Returns false on error. Never throws.
Header <boost/interprocess/sync/named_sharable_mutex.hpp>
Describes a named sharable mutex class for inter-process synchronization
namespace boost { namespace interprocess { class named_sharable_mutex; } }
Class named_sharable_mutex
boost::interprocess::named_sharable_mutex
461
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/sync/named_sharable_mutex.hpp>
class named_sharable_mutex { public: // construct/copy/destruct named_sharable_mutex(create_only_t, const char *, const permissions & = permissions()); named_sharable_mutex(open_or_create_t, const char *, const permissions & = permissions()); named_sharable_mutex(open_only_t, const char *); ~named_sharable_mutex(); // public member functions void lock(); bool try_lock(); bool timed_lock(const boost::posix_time::ptime &); void unlock(); void lock_sharable(); bool try_lock_sharable(); bool timed_lock_sharable(const boost::posix_time::ptime &); void unlock_sharable(); // public static functions static bool remove(const char *); };
Description
A sharable mutex with a global name, so it can be found from different processes. This mutex can't be placed in shared memory, and each process should have it's own named sharable mutex.
named_sharable_mutex public construct/copy/destruct
1.
named_sharable_mutex(create_only_t create_only, const char * name, const permissions & perm = permissions());
Creates a global sharable mutex with a name. If the sharable mutex can't be created throws interprocess_exception 2.
named_sharable_mutex(open_or_create_t open_or_create, const char * name, const permissions & perm = permissions());
Opens or creates a global sharable mutex with a name. If the sharable mutex is created, this call is equivalent to named_sharable_mutex(create_only_t, ...) If the sharable mutex is already created, this call is equivalent to named_sharable_mutex(open_only_t, ... ). 3.
named_sharable_mutex(open_only_t open_only, const char * name);
Opens a global sharable mutex with a name if that sharable mutex is previously. created. If it is not previously created this function throws interprocess_exception. 4.
~named_sharable_mutex();
462
Boost.Interprocess
Destroys *this and indicates that the calling process is nished using the resource. The destructor function will deallocate any system resources allocated by the system for use by this process for this resource. The resource can still be opened again calling the open constructor overload. To erase the resource from the system use remove().
named_sharable_mutex public member functions
1.
void lock();
Effects: The calling thread tries to obtain exclusive ownership of the mutex, and if another thread has exclusive or sharable ownership of the mutex, it waits until it can obtain the ownership. Throws: interprocess_exception on error. 2.
bool try_lock();
Effects: The calling thread tries to acquire exclusive ownership of the mutex without waiting. If no other thread has exclusive or sharable ownership of the mutex this succeeds. Returns: If it can acquire exclusive ownership immediately returns true. If it has to wait, returns false. Throws: interprocess_exception on error. 3.
bool timed_lock(const boost::posix_time::ptime & abs_time);
Effects: The calling thread tries to acquire exclusive ownership of the mutex waiting if necessary until no other thread has exclusive, or sharable ownership of the mutex or abs_time is reached. Returns: If acquires exclusive ownership, returns true. Otherwise returns false. Throws: interprocess_exception on error. 4.
void unlock();
Precondition: The thread must have exclusive ownership of the mutex. Effects: The calling thread releases the exclusive ownership of the mutex. Throws: An exception derived from interprocess_exception on error. 5.
void lock_sharable();
Effects: The calling thread tries to obtain sharable ownership of the mutex, and if another thread has exclusive ownership of the mutex, waits until it can obtain the ownership. Throws: interprocess_exception on error. 6.
bool try_lock_sharable();
Effects: The calling thread tries to acquire sharable ownership of the mutex without waiting. If no other thread has exclusive ownership of the mutex this succeeds. Returns: If it can acquire sharable ownership immediately returns true. If it has to wait, returns false. Throws: interprocess_exception on error. 7.
bool timed_lock_sharable(const boost::posix_time::ptime & abs_time);
Effects: The calling thread tries to acquire sharable ownership of the mutex waiting if necessary until no other thread has exclusive ownership of the mutex or abs_time is reached. Returns: If acquires sharable ownership, returns true. Otherwise returns false. Throws: interprocess_exception on error. 8.
void unlock_sharable();
Precondition: The thread must have sharable ownership of the mutex. Effects: The calling thread releases the sharable ownership of the mutex. Throws: An exception derived from interprocess_exception on error.
463
Boost.Interprocess
1.
Erases a named sharable mutex from the system. Returns false on error. Never throws.
Header <boost/interprocess/sync/named_upgradable_mutex.hpp>
Describes a named upgradable mutex class for inter-process synchronization
namespace boost { namespace interprocess { class named_upgradable_mutex; } }
Class named_upgradable_mutex
boost::interprocess::named_upgradable_mutex
464
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/sync/named_upgradable_mutex.hpp>
class named_upgradable_mutex { public: // construct/copy/destruct named_upgradable_mutex(create_only_t, const char *, const permissions & = permissions()); named_upgradable_mutex(open_or_create_t, const char *, const permissions & = permissions()); named_upgradable_mutex(open_only_t, const char *); ~named_upgradable_mutex(); // public member functions void lock(); bool try_lock(); bool timed_lock(const boost::posix_time::ptime &); void unlock(); void lock_sharable(); bool try_lock_sharable(); bool timed_lock_sharable(const boost::posix_time::ptime &); void unlock_sharable(); void lock_upgradable(); bool try_lock_upgradable(); bool timed_lock_upgradable(const boost::posix_time::ptime &); void unlock_upgradable(); void unlock_and_lock_upgradable(); void unlock_and_lock_sharable(); void unlock_upgradable_and_lock_sharable(); void unlock_upgradable_and_lock(); bool try_unlock_upgradable_and_lock(); bool timed_unlock_upgradable_and_lock(const boost::posix_time::ptime &); bool try_unlock_sharable_and_lock(); bool try_unlock_sharable_and_lock_upgradable(); // public static functions static bool remove(const char *); };
Description
A upgradable mutex with a global name, so it can be found from different processes. This mutex can't be placed in shared memory, and each process should have it's own named upgradable mutex.
named_upgradable_mutex public construct/copy/destruct
1.
named_upgradable_mutex(create_only_t create_only, const char * name, const permissions & perm = permissions());
Creates a global upgradable mutex with a name. If the upgradable mutex can't be created throws interprocess_exception 2.
named_upgradable_mutex(open_or_create_t open_or_create, const char * name, const permissions & perm = permissions());
Opens or creates a global upgradable mutex with a name. If the upgradable mutex is created, this call is equivalent to named_upgradable_mutex(create_only_t, ...) If the upgradable mutex is already created, this call is equivalent to named_upgradable_mutex(open_only_t, ... ).
465
Boost.Interprocess
3.
Opens a global upgradable mutex with a name if that upgradable mutex is previously. created. If it is not previously created this function throws interprocess_exception. 4.
~named_upgradable_mutex();
Destroys *this and indicates that the calling process is nished using the resource. The destructor function will deallocate any system resources allocated by the system for use by this process for this resource. The resource can still be opened again calling the open constructor overload. To erase the resource from the system use remove().
named_upgradable_mutex public member functions
1.
void lock();
Effects: The calling thread tries to obtain exclusive ownership of the mutex, and if another thread has exclusive, sharable or upgradable ownership of the mutex, it waits until it can obtain the ownership. Throws: interprocess_exception on error. 2.
bool try_lock();
Effects: The calling thread tries to acquire exclusive ownership of the mutex without waiting. If no other thread has exclusive, sharable or upgradable ownership of the mutex this succeeds. Returns: If it can acquire exclusive ownership immediately returns true. If it has to wait, returns false. Throws: interprocess_exception on error. 3.
bool timed_lock(const boost::posix_time::ptime & abs_time);
Effects: The calling thread tries to acquire exclusive ownership of the mutex waiting if necessary until no other thread has exclusive, sharable or upgradable ownership of the mutex or abs_time is reached. Returns: If acquires exclusive ownership, returns true. Otherwise returns false. Throws: interprocess_exception on error. 4.
void unlock();
Precondition: The thread must have exclusive ownership of the mutex. Effects: The calling thread releases the exclusive ownership of the mutex. Throws: An exception derived from interprocess_exception on error. 5.
void lock_sharable();
Effects: The calling thread tries to obtain sharable ownership of the mutex, and if another thread has exclusive ownership of the mutex, waits until it can obtain the ownership. Throws: interprocess_exception on error. 6.
bool try_lock_sharable();
Effects: The calling thread tries to acquire sharable ownership of the mutex without waiting. If no other thread has exclusive ownership of the mutex this succeeds. Returns: If it can acquire sharable ownership immediately returns true. If it has to wait, returns false. Throws: interprocess_exception on error. 7.
bool timed_lock_sharable(const boost::posix_time::ptime & abs_time);
Effects: The calling thread tries to acquire sharable ownership of the mutex waiting if necessary until no other thread has exclusive ownership of the mutex or abs_time is reached. Returns: If acquires sharable ownership, returns true. Otherwise returns false. Throws: interprocess_exception on error.
466
Boost.Interprocess
8.
void unlock_sharable();
Precondition: The thread must have sharable ownership of the mutex. Effects: The calling thread releases the sharable ownership of the mutex. Throws: An exception derived from interprocess_exception on error. 9.
void lock_upgradable();
Effects: The calling thread tries to obtain upgradable ownership of the mutex, and if another thread has exclusive or upgradable ownership of the mutex, waits until it can obtain the ownership. Throws: interprocess_exception on error. 10.
bool try_lock_upgradable();
Effects: The calling thread tries to acquire upgradable ownership of the mutex without waiting. If no other thread has exclusive or upgradable ownership of the mutex this succeeds. Returns: If it can acquire upgradable ownership immediately returns true. If it has to wait, returns false. Throws: interprocess_exception on error. 11.
bool timed_lock_upgradable(const boost::posix_time::ptime & abs_time);
Effects: The calling thread tries to acquire upgradable ownership of the mutex waiting if necessary until no other thread has exclusive or upgradable ownership of the mutex or abs_time is reached. Returns: If acquires upgradable ownership, returns true. Otherwise returns false. Throws: interprocess_exception on error. 12.
void unlock_upgradable();
Precondition: The thread must have upgradable ownership of the mutex. Effects: The calling thread releases the upgradable ownership of the mutex. Throws: An exception derived from interprocess_exception on error. 13.
void unlock_and_lock_upgradable();
Precondition: The thread must have exclusive ownership of the mutex. Effects: The thread atomically releases exclusive ownership and acquires upgradable ownership. This operation is non-blocking. Throws: An exception derived from interprocess_exception on error. 14.
void unlock_and_lock_sharable();
Precondition: The thread must have exclusive ownership of the mutex. Effects: The thread atomically releases exclusive ownership and acquires sharable ownership. This operation is non-blocking. Throws: An exception derived from interprocess_exception on error. 15.
void unlock_upgradable_and_lock_sharable();
Precondition: The thread must have upgradable ownership of the mutex. Effects: The thread atomically releases upgradable ownership and acquires sharable ownership. This operation is non-blocking. Throws: An exception derived from interprocess_exception on error. 16.
void unlock_upgradable_and_lock();
Precondition: The thread must have upgradable ownership of the mutex. Effects: The thread atomically releases upgradable ownership and acquires exclusive ownership. This operation will block until all threads with sharable ownership release it. Throws: An exception derived from interprocess_exception on error.
467
Boost.Interprocess
17.
bool try_unlock_upgradable_and_lock();
Precondition: The thread must have upgradable ownership of the mutex. Effects: The thread atomically releases upgradable ownership and tries to acquire exclusive ownership. This operation will fail if there are threads with sharable ownership, but it will maintain upgradable ownership. Returns: If acquires exclusive ownership, returns true. Otherwise returns false. Throws: An exception derived from interprocess_exception on error. 18.
bool timed_unlock_upgradable_and_lock(const boost::posix_time::ptime & abs_time);
Precondition: The thread must have upgradable ownership of the mutex. Effects: The thread atomically releases upgradable ownership and tries to acquire exclusive ownership, waiting if necessary until abs_time. This operation will fail if there are threads with sharable ownership or timeout reaches, but it will maintain upgradable ownership. Returns: If acquires exclusive ownership, returns true. Otherwise returns false. Throws: An exception derived from interprocess_exception on error. 19.
bool try_unlock_sharable_and_lock();
Precondition: The thread must have sharable ownership of the mutex. Effects: The thread atomically releases sharable ownership and tries to acquire exclusive ownership. This operation will fail if there are threads with sharable or upgradable ownership, but it will maintain sharable ownership. Returns: If acquires exclusive ownership, returns true. Otherwise returns false. Throws: An exception derived from interprocess_exception on error. 20.
bool try_unlock_sharable_and_lock_upgradable();
Precondition: The thread must have sharable ownership of the mutex. Effects: The thread atomically releases sharable ownership and tries to acquire upgradable ownership. This operation will fail if there are threads with sharable or upgradable ownership, but it will maintain sharable ownership. Returns: If acquires upgradable ownership, returns true. Otherwise returns false. Throws: An exception derived from interprocess_exception on error.
named_upgradable_mutex public static functions
1.
Erases a named upgradable mutex from the system. Returns false on error. Never throws.
Header <boost/interprocess/sync/null_mutex.hpp>
Describes null_mutex classes
namespace boost { namespace interprocess { class null_mutex; } namespace posix_time { } }
Class null_mutex
boost::interprocess::null_mutex
468
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/sync/null_mutex.hpp>
class null_mutex { public: // construct/copy/destruct null_mutex(); ~null_mutex(); // public member functions void lock(); bool try_lock(); bool timed_lock(const boost::posix_time::ptime &); void unlock(); void lock_sharable(); bool try_lock_sharable(); bool timed_lock_sharable(const boost::posix_time::ptime &); void unlock_sharable(); void lock_upgradable(); bool try_lock_upgradable(); bool timed_lock_upgradable(const boost::posix_time::ptime &); void unlock_upgradable(); void unlock_and_lock_upgradable(); void unlock_and_lock_sharable(); void unlock_upgradable_and_lock_sharable(); void unlock_upgradable_and_lock(); bool try_unlock_upgradable_and_lock(); bool timed_unlock_upgradable_and_lock(const boost::posix_time::ptime &); bool try_unlock_sharable_and_lock(); bool try_unlock_sharable_and_lock_upgradable(); };
Description
Implements a mutex that simulates a mutex without doing any operation and simulates a successful operation.
null_mutex public construct/copy/destruct
1.
null_mutex();
Constructor. Empty. 2.
~null_mutex();
Destructor. Empty.
null_mutex public member functions
1.
void lock();
469
Boost.Interprocess
3.
470
Boost.Interprocess
Header <boost/interprocess/sync/scoped_lock.hpp>
Describes the scoped_lock class.
namespace boost { namespace interprocess { template<typename Mutex> class scoped_lock; } }
471
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/sync/scoped_lock.hpp> template<typename Mutex> class scoped_lock { public: // types typedef Mutex mutex_type; // construct/copy/destruct scoped_lock(); explicit scoped_lock(mutex_type &); scoped_lock(mutex_type &, defer_lock_type); scoped_lock(mutex_type &, accept_ownership_type); scoped_lock(mutex_type &, try_to_lock_type); scoped_lock(mutex_type &, const boost::posix_time::ptime &); scoped_lock(scoped_lock &&); template<typename T> explicit scoped_lock(upgradable_lock< T > &&, unspecified = 0); template<typename T> scoped_lock(upgradable_lock< T > &&, try_to_lock_type, unspecified = 0); template<typename T> scoped_lock(upgradable_lock< T > &&, boost::posix_time::ptime &, unspecified = 0); template<typename T> scoped_lock(sharable_lock< T > &&, try_to_lock_type, unspecified = 0); scoped_lock& operator=(scoped_lock &&); ~scoped_lock(); // public member functions void lock(); *bool try_lock(); *bool timed_lock(const boost::posix_time::ptime &); *void unlock(); bool owns() const; operator unspecified_bool_type() const; mutex_type * mutex() const; mutex_type * release(); void swap(scoped_lock< mutex_type > &); };
Description
scoped_lock is meant to carry out the tasks for locking, unlocking, try-locking and timed-locking (recursive or not) for the Mutex. The Mutex need not supply all of this functionality. If the client of scoped_lock<Mutex> does not use functionality which the Mutex does not supply, no harm is done. Mutex ownership transfer is supported through the syntax of move semantics. Ownership transfer is allowed both by construction and assignment. The scoped_lock does not support copy semantics. A compile time error results if copy construction or copy assignment is attempted. Mutex ownership can also be moved from an upgradable_lock and sharable_lock via constructor. In this role, scoped_lock shares the same functionality as a write_lock.
scoped_lock public construct/copy/destruct
1.
scoped_lock();
472
Boost.Interprocess
Effects: m.lock(). Postconditions: owns() == true and mutex() == &m. Notes: The constructor will take ownership of the mutex. If another thread already owns the mutex, this thread will block until the mutex is released. Whether or not this constructor handles recursive locking depends upon the mutex. 3.
scoped_lock(mutex_type & m, defer_lock_type);
Postconditions: owns() == false, and mutex() == &m. Notes: The constructor will not take ownership of the mutex. There is no effect required on the referenced mutex. 4.
scoped_lock(mutex_type & m, accept_ownership_type);
Postconditions: owns() == true, and mutex() == &m. Notes: The constructor will suppose that the mutex is already locked. There is no effect required on the referenced mutex. 5.
scoped_lock(mutex_type & m, try_to_lock_type);
Effects: m.try_lock(). Postconditions: mutex() == &m. owns() == the return value of the m.try_lock() executed within the constructor. Notes: The constructor will take ownership of the mutex if it can do so without waiting. Whether or not this constructor handles recursive locking depends upon the mutex. If the mutex_type does not support try_lock, this constructor will fail at compile time if instantiated, but otherwise have no effect. 6.
scoped_lock(mutex_type & m, const boost::posix_time::ptime & abs_time);
Effects: m.timed_lock(abs_time). Postconditions: mutex() == &m. owns() == the return value of the m.timed_lock(abs_time) executed within the constructor. Notes: The constructor will take ownership of the mutex if it can do it until abs_time is reached. Whether or not this constructor handles recursive locking depends upon the mutex. If the mutex_type does not support try_lock, this constructor will fail at compile time if instantiated, but otherwise have no effect. 7.
scoped_lock(scoped_lock && scop);
Postconditions: mutex() == the value scop.mutex() had before the constructor executes. s1.mutex() == 0. owns() == the value of scop.owns() before the constructor executes. scop.owns(). Notes: If the scop scoped_lock owns the mutex, ownership is moved to thisscoped_lock with no blocking. If the scop scoped_lock does not own the mutex, then neither will this scoped_lock. Only a moved scoped_lock's will match this signature. An non-moved scoped_lock can be moved with the expression: "boost::move(lock);". This constructor does not alter the state of the mutex, only potentially who owns it. 8.
template<typename T> explicit scoped_lock(upgradable_lock< T > && upgr, unspecified = 0);
Effects: If upgr.owns() then calls unlock_upgradable_and_lock() on the referenced mutex. upgr.release() is called. Postconditions: mutex() == the value upgr.mutex() had before the construction. upgr.mutex() == 0. owns() == upgr.owns() before the construction. upgr.owns() == false after the construction. Notes: If upgr is locked, this constructor will lock this scoped_lock while unlocking upgr. If upgr is unlocked, then this scoped_lock will be unlocked as well. Only a moved upgradable_lock's will match this signature. An non-moved upgradable_lock can be moved with the expression: "boost::move(lock);" This constructor may block if other threads hold a sharable_lock on this mutex (sharable_lock's can share ownership with an upgradable_lock). 9.
template<typename T> scoped_lock(upgradable_lock< T > && upgr, try_to_lock_type, unspecified = 0);
Effects: If upgr.owns() then calls try_unlock_upgradable_and_lock() on the referenced mutex: a)if try_unlock_upgradable_and_lock() returns true then mutex() obtains the value from upgr.release() and owns() is set to true. b)if try_unlock_upgradable_and_lock() returns false then upgr is unaffected and this scoped_lock construction as the same effects as a default construction. c)Else upgr.owns() is false. mutex() obtains the value from upgr.release() and owns() is set to false Notes: This construction will not block. It will try to obtain mutex ownership from upgr immediately, while changing the lock type from a "read lock" to
473
Boost.Interprocess
a "write lock". If the "read lock" isn't held in the rst place, the mutex merely changes type to an unlocked "write lock". If the "read lock" is held, then mutex transfer occurs only if it can do so in a non-blocking manner. 10.
template<typename T> scoped_lock(upgradable_lock< T > && upgr, boost::posix_time::ptime & abs_time, unspecified = 0);
Effects: If upgr.owns() then calls timed_unlock_upgradable_and_lock(abs_time) on the referenced mutex: a)if timed_unlock_upgradable_and_lock(abs_time) returns true then mutex() obtains the value from upgr.release() and owns() is set to true. b)if timed_unlock_upgradable_and_lock(abs_time) returns false then upgr is unaffected and this scoped_lock construction as the same effects as a default construction. c)Else upgr.owns() is false. mutex() obtains the value from upgr.release() and owns() is set to false Notes: This construction will not block. It will try to obtain mutex ownership from upgr immediately, while changing the lock type from a "read lock" to a "write lock". If the "read lock" isn't held in the rst place, the mutex merely changes type to an unlocked "write lock". If the "read lock" is held, then mutex transfer occurs only if it can do so in a non-blocking manner. 11.
template<typename T> scoped_lock(sharable_lock< T > && shar, try_to_lock_type, unspecified = 0);
Effects: If shar.owns() then calls try_unlock_sharable_and_lock() on the referenced mutex. a)if try_unlock_sharable_and_lock() returns true then mutex() obtains the value from shar.release() and owns() is set to true. b)if try_unlock_sharable_and_lock() returns false then shar is unaffected and this scoped_lock construction has the same effects as a default construction. c)Else shar.owns() is false. mutex() obtains the value from shar.release() and owns() is set to false Notes: This construction will not block. It will try to obtain mutex ownership from shar immediately, while changing the lock type from a "read lock" to a "write lock". If the "read lock" isn't held in the rst place, the mutex merely changes type to an unlocked "write lock". If the "read lock" is held, then mutex transfer occurs only if it can do so in a non-blocking manner. 12.
scoped_lock& operator=(scoped_lock && scop);
Effects: If owns() before the call, then unlock() is called on mutex(). *this gets the state of scop and scop gets set to a default constructed state. Notes: With a recursive mutex it is possible that both this and scop own the same mutex before the assignment. In this case, this will own the mutex after the assignment (and scop will not), but the mutex's lock count will be decremented by one. 13.
~scoped_lock();
Effects: if (owns()) mp_mutex->unlock(). Notes: The destructor behavior ensures that the mutex lock is not leaked.
scoped_lock public member functions
1.
void lock();
Effects: If mutex() == 0 or if already locked, throws a lock_exception() exception. Calls lock() on the referenced mutex. Postconditions: owns() == true. Notes: The scoped_lock changes from a state of not owning the mutex, to owning the mutex, blocking if necessary. 2.
*bool try_lock();
Effects: If mutex() == 0 or if already locked, throws a lock_exception() exception. Calls try_lock() on the referenced mutex. Postconditions: owns() == the value returned from mutex()->try_lock(). Notes: The scoped_lock changes from a state of not owning the mutex, to owning the mutex, but only if blocking was not required. If the mutex_type does not support try_lock(), this function will fail at compile time if instantiated, but otherwise have no effect. 3.
*bool timed_lock(const boost::posix_time::ptime & abs_time);
474
Boost.Interprocess
Effects: If mutex() == 0 or if already locked, throws a lock_exception() exception. Calls timed_lock(abs_time) on the referenced mutex. Postconditions: owns() == the value returned from mutex()-> timed_lock(abs_time). Notes: The scoped_lock changes from a state of not owning the mutex, to owning the mutex, but only if it can obtain ownership by the specied time. If the mutex_type does not support timed_lock (), this function will fail at compile time if instantiated, but otherwise have no effect. 4.
*void unlock();
Effects: If mutex() == 0 or if not locked, throws a lock_exception() exception. Calls unlock() on the referenced mutex. Postconditions: owns() == false. Notes: The scoped_lock changes from a state of owning the mutex, to not owning the mutex. 5.
bool owns() const;
Effects: Returns true if this scoped_lock has acquired the referenced mutex. 6.
operator unspecified_bool_type() const;
Effects: Returns a pointer to the referenced mutex, or 0 if there is no mutex to reference. Postconditions: mutex() == 0 and owns() == false. 9.
void swap(scoped_lock< mutex_type > & other);
Header <boost/interprocess/sync/sharable_lock.hpp>
Describes the upgradable_lock class that serves to acquire the upgradable lock of a mutex.
namespace boost { namespace interprocess { template<typename SharableMutex> class sharable_lock; } }
475
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/sync/sharable_lock.hpp> template<typename SharableMutex> class sharable_lock { public: // types typedef SharableMutex mutex_type; // construct/copy/destruct sharable_lock(); explicit sharable_lock(mutex_type &); sharable_lock(mutex_type &, defer_lock_type); sharable_lock(mutex_type &, accept_ownership_type); sharable_lock(mutex_type &, try_to_lock_type); sharable_lock(mutex_type &, const boost::posix_time::ptime &); sharable_lock(sharable_lock< mutex_type > &&); template<typename T> sharable_lock(upgradable_lock< T > &&, unspecified = 0); template<typename T> sharable_lock(scoped_lock< T > &&, unspecified = 0); sharable_lock& operator=(sharable_lock< mutex_type > &&); ~sharable_lock(); // public member functions void lock(); bool try_lock(); bool timed_lock(const boost::posix_time::ptime &); void unlock(); bool owns() const; operator unspecified_bool_type() const; mutex_type * mutex() const; mutex_type * release(); void swap(sharable_lock< mutex_type > &); };
Description
sharable_lock is meant to carry out the tasks for sharable-locking (such as read-locking), unlocking, try-sharable-locking and timedsharable-locking (recursive or not) for the Mutex. The Mutex need not supply all of this functionality. If the client of sharable_lock<Mutex> does not use functionality which the Mutex does not supply, no harm is done. Mutex ownership can be shared among sharable_locks, and a single upgradable_lock. sharable_lock does not support copy semantics. But sharable_lock supports ownership transfer from an sharable_lock, upgradable_lock and scoped_lock via transfer_lock syntax.
sharable_lock public construct/copy/destruct
1.
sharable_lock();
Effects: m.lock_sharable(). Postconditions: owns() == true and mutex() == &m. Notes: The constructor will take sharable-ownership of the mutex. If another thread already owns the mutex with exclusive ownership (scoped_lock), this thread will block until the mutex is released. If another thread owns the mutex with sharable or upgradable ownership, then no blocking will occur. Whether or not this constructor handles recursive locking depends upon the mutex. 3.
sharable_lock(mutex_type & m, defer_lock_type);
476
Boost.Interprocess
Postconditions: owns() == false, and mutex() == &m. Notes: The constructor will not take ownership of the mutex. There is no effect required on the referenced mutex. 4.
sharable_lock(mutex_type & m, accept_ownership_type);
Postconditions: owns() == true, and mutex() == &m. Notes: The constructor will suppose that the mutex is already sharable locked. There is no effect required on the referenced mutex. 5.
sharable_lock(mutex_type & m, try_to_lock_type);
Effects: m.try_lock_sharable() Postconditions: mutex() == &m. owns() == the return value of the m.try_lock_sharable() executed within the constructor. Notes: The constructor will take sharable-ownership of the mutex if it can do so without waiting. Whether or not this constructor handles recursive locking depends upon the mutex. If the mutex_type does not support try_lock_sharable, this constructor will fail at compile time if instantiated, but otherwise have no effect. 6.
sharable_lock(mutex_type & m, const boost::posix_time::ptime & abs_time);
Effects: m.timed_lock_sharable(abs_time) Postconditions: mutex() == &m. owns() == the return value of the m.timed_lock_sharable() executed within the constructor. Notes: The constructor will take sharable-ownership of the mutex if it can do so within the time specied. Whether or not this constructor handles recursive locking depends upon the mutex. If the mutex_type does not support timed_lock_sharable, this constructor will fail at compile time if instantiated, but otherwise have no effect. 7.
sharable_lock(sharable_lock< mutex_type > && upgr);
Postconditions: mutex() == upgr.mutex(). owns() == the value of upgr.owns() before the construction. upgr.owns() == false after the construction. Notes: If the upgr sharable_lock owns the mutex, ownership is moved to this sharable_lock with no blocking. If the upgr sharable_lock does not own the mutex, then neither will this sharable_lock. Only a moved sharable_lock's will match this signature. An non-moved sharable_lock can be moved with the expression: "boost::move(lock);". This constructor does not alter the state of the mutex, only potentially who owns it. 8.
template<typename T> sharable_lock(upgradable_lock< T > && upgr, unspecified = 0);
Effects: If upgr.owns() then calls unlock_upgradable_and_lock_sharable() on the referenced mutex. Postconditions: mutex() == the value upgr.mutex() had before the construction. upgr.mutex() == 0 owns() == the value of upgr.owns() before construction. upgr.owns() == false after the construction. Notes: If upgr is locked, this constructor will lock this sharable_lock while unlocking upgr. Only a moved sharable_lock's will match this signature. An non-moved upgradable_lock can be moved with the expression: "boost::move(lock);". 9.
template<typename T> sharable_lock(scoped_lock< T > && scop, unspecified = 0);
Effects: If scop.owns() then calls unlock_and_lock_sharable() on the referenced mutex. Postconditions: mutex() == the value scop.mutex() had before the construction. scop.mutex() == 0 owns() == scop.owns() before the constructor. After the construction, scop.owns() == false. Notes: If scop is locked, this constructor will transfer the exclusive ownership to a sharable-ownership of this sharable_lock. Only a moved scoped_lock's will match this signature. An non-moved scoped_lock can be moved with the expression: "boost::move(lock);". 10.
sharable_lock& operator=(sharable_lock< mutex_type > && upgr);
Effects: If owns() before the call, then unlock_sharable() is called on mutex(). *this gets the state of upgr and upgr gets set to a default constructed state. Notes: With a recursive mutex it is possible that both this and upgr own the mutex before the assignment.
477
Boost.Interprocess
In this case, this will own the mutex after the assignment (and upgr will not), but the mutex's lock count will be decremented by one. 11.
~sharable_lock();
Effects: if (owns()) mp_mutex->unlock_sharable(). Notes: The destructor behavior ensures that the mutex lock is not leaked.
sharable_lock public member functions
1.
void lock();
Effects: If mutex() == 0 or already locked, throws a lock_exception() exception. Calls lock_sharable() on the referenced mutex. Postconditions: owns() == true. Notes: The sharable_lock changes from a state of not owning the mutex, to owning the mutex, blocking if necessary. 2.
bool try_lock();
Effects: If mutex() == 0 or already locked, throws a lock_exception() exception. Calls try_lock_sharable() on the referenced mutex. Postconditions: owns() == the value returned from mutex()->try_lock_sharable(). Notes: The sharable_lock changes from a state of not owning the mutex, to owning the mutex, but only if blocking was not required. If the mutex_type does not support try_lock_sharable(), this function will fail at compile time if instantiated, but otherwise have no effect. 3.
bool timed_lock(const boost::posix_time::ptime & abs_time);
Effects: If mutex() == 0 or already locked, throws a lock_exception() exception. Calls timed_lock_sharable(abs_time) on the referenced mutex. Postconditions: owns() == the value returned from mutex()->timed_lock_sharable(elps_time). Notes: The sharable_lock changes from a state of not owning the mutex, to owning the mutex, but only if it can obtain ownership within the specied time interval. If the mutex_type does not support timed_lock_sharable(), this function will fail at compile time if instantiated, but otherwise have no effect. 4.
void unlock();
Effects: If mutex() == 0 or not locked, throws a lock_exception() exception. Calls unlock_sharable() on the referenced mutex. Postconditions: owns() == false. Notes: The sharable_lock changes from a state of owning the mutex, to not owning the mutex. 5.
bool owns() const;
Effects: Returns true if this scoped_lock has acquired the referenced mutex. 6.
operator unspecified_bool_type() const;
Effects: Returns a pointer to the referenced mutex, or 0 if there is no mutex to reference. Postconditions: mutex() == 0 and owns() == false.
478
Boost.Interprocess
9.
Header <boost/interprocess/sync/upgradable_lock.hpp>
Describes the upgradable_lock class that serves to acquire the upgradable lock of a mutex.
namespace boost { namespace interprocess { template<typename UpgradableMutex> class upgradable_lock; } }
Synopsis
// In header: <boost/interprocess/sync/upgradable_lock.hpp> template<typename UpgradableMutex> class upgradable_lock { public: // types typedef UpgradableMutex mutex_type; // construct/copy/destruct upgradable_lock(); explicit upgradable_lock(mutex_type &); upgradable_lock(mutex_type &, defer_lock_type); upgradable_lock(mutex_type &, accept_ownership_type); upgradable_lock(mutex_type &, try_to_lock_type); upgradable_lock(mutex_type &, const boost::posix_time::ptime &); upgradable_lock(upgradable_lock< mutex_type > &&); template<typename T> upgradable_lock(scoped_lock< T > &&, unspecified = 0); template<typename T> upgradable_lock(sharable_lock< T > &&, try_to_lock_type, unspecified = 0); upgradable_lock& operator=(upgradable_lock &&); ~upgradable_lock(); // public member functions void lock(); bool try_lock(); bool timed_lock(const boost::posix_time::ptime &); void unlock(); bool owns() const; operator unspecified_bool_type() const; mutex_type * mutex() const; mutex_type * release(); void swap(upgradable_lock< mutex_type > &); };
Description
upgradable_lock is meant to carry out the tasks for read-locking, unlocking, try-read-locking and timed-read-locking (recursive or not) for the Mutex. Additionally the upgradable_lock can transfer ownership to a scoped_lock using transfer_lock syntax. The Mutex
479
Boost.Interprocess
need not supply all of the functionality. If the client of upgradable_lock<Mutex> does not use functionality which the Mutex does not supply, no harm is done. Mutex ownership can be shared among read_locks, and a single upgradable_lock. upgradable_lock does not support copy semantics. However upgradable_lock supports ownership transfer from a upgradable_locks or scoped_locks via transfer_lock syntax.
upgradable_lock public construct/copy/destruct
1.
upgradable_lock();
3.
Postconditions: owns() == false, and mutex() == &m. Notes: The constructor will not take ownership of the mutex. There is no effect required on the referenced mutex. 4.
upgradable_lock(mutex_type & m, accept_ownership_type);
Postconditions: owns() == true, and mutex() == &m. Notes: The constructor will suppose that the mutex is already upgradable locked. There is no effect required on the referenced mutex. 5.
upgradable_lock(mutex_type & m, try_to_lock_type);
Effects: m.try_lock_upgradable(). Postconditions: mutex() == &m. owns() == the return value of the m.try_lock_upgradable() executed within the constructor. Notes: The constructor will take upgradable-ownership of the mutex if it can do so without waiting. Whether or not this constructor handles recursive locking depends upon the mutex. If the mutex_type does not support try_lock_upgradable, this constructor will fail at compile time if instantiated, but otherwise have no effect. 6.
upgradable_lock(mutex_type & m, const boost::posix_time::ptime & abs_time);
Effects: m.timed_lock_upgradable(abs_time) Postconditions: mutex() == &m. owns() == the return value of the m.timed_lock_upgradable() executed within the constructor. Notes: The constructor will take upgradable-ownership of the mutex if it can do so within the time specied. Whether or not this constructor handles recursive locking depends upon the mutex. If the mutex_type does not support timed_lock_upgradable, this constructor will fail at compile time if instantiated, but otherwise have no effect. 7.
upgradable_lock(upgradable_lock< mutex_type > && upgr);
Effects: No effects on the underlying mutex. Postconditions: mutex() == the value upgr.mutex() had before the construction. upgr.mutex() == 0. owns() == upgr.owns() before the construction. upgr.owns() == false. Notes: If upgr is locked, this constructor will lock this upgradable_lock while unlocking upgr. If upgr is unlocked, then this upgradable_lock will be unlocked as well. Only a moved upgradable_lock's will match this signature. An non-moved upgradable_lock can be moved with the expression: "boost::move(lock);". This constructor does not alter the state of the mutex, only potentially who owns it. 8.
template<typename T> upgradable_lock(scoped_lock< T > && scop, unspecified = 0);
Effects: If scop.owns(), m_.unlock_and_lock_upgradable(). Postconditions: mutex() == the value scop.mutex() had before the construction. scop.mutex() == 0. owns() == scop.owns() before the constructor. After the construction, scop.owns() == false. Notes: If scop is locked, this constructor will transfer the exclusive-ownership to an upgradable-ownership of this upgrad-
480
Boost.Interprocess
able_lock. Only a moved sharable_lock's will match this signature. An non-moved sharable_lock can be moved with
Effects: If shar.owns() then calls try_unlock_sharable_and_lock_upgradable() on the referenced mutex. a)if try_unlock_sharable_and_lock_upgradable() returns true then mutex() obtains the value from shar.release() and owns() is set to true. b)if try_unlock_sharable_and_lock_upgradable() returns false then shar is unaffected and this upgradable_lock construction has the same effects as a default construction. c)Else shar.owns() is false. mutex() obtains the value from shar.release() and owns() is set to false. Notes: This construction will not block. It will try to obtain mutex ownership from shar immediately, while changing the lock type from a "read lock" to an "upgradable lock". If the "read lock" isn't held in the rst place, the mutex merely changes type to an unlocked "upgradable lock". If the "read lock" is held, then mutex transfer occurs only if it can do so in a non-blocking manner. 10.
upgradable_lock& operator=(upgradable_lock && upgr);
Effects: If owns(), then unlock_upgradable() is called on mutex(). *this gets the state of upgr and upgr gets set to a default constructed state. Notes: With a recursive mutex it is possible that both this and upgr own the mutex before the assignment. In this case, this will own the mutex after the assignment (and upgr will not), but the mutex's upgradable lock count will be decremented by one. 11.
~upgradable_lock();
Effects: if (owns()) m_->unlock_upgradable(). Notes: The destructor behavior ensures that the mutex lock is not leaked.
upgradable_lock public member functions
1.
void lock();
Effects: If mutex() == 0 or if already locked, throws a lock_exception() exception. Calls lock_upgradable() on the referenced mutex. Postconditions: owns() == true. Notes: The sharable_lock changes from a state of not owning the mutex, to owning the mutex, blocking if necessary. 2.
bool try_lock();
Effects: If mutex() == 0 or if already locked, throws a lock_exception() exception. Calls try_lock_upgradable() on the referenced mutex. Postconditions: owns() == the value returned from mutex()->try_lock_upgradable(). Notes: The upgradable_lock changes from a state of not owning the mutex, to owning the mutex, but only if blocking was not required. If the mutex_type does not support try_lock_upgradable(), this function will fail at compile time if instantiated, but otherwise have no effect. 3.
bool timed_lock(const boost::posix_time::ptime & abs_time);
Effects: If mutex() == 0 or if already locked, throws a lock_exception() exception. Calls timed_lock_upgradable(abs_time) on the referenced mutex. Postconditions: owns() == the value returned from mutex()->timed_lock_upgradable(abs_time). Notes: The upgradable_lock changes from a state of not owning the mutex, to owning the mutex, but only if it can obtain ownership within the specied time. If the mutex_type does not support timed_lock_upgradable(abs_time), this function will fail at compile time if instantiated, but otherwise have no effect. 4.
void unlock();
481
Boost.Interprocess
Effects: If mutex() == 0 or if not locked, throws a lock_exception() exception. Calls unlock_upgradable() on the referenced mutex. Postconditions: owns() == false. Notes: The upgradable_lock changes from a state of owning the mutex, to not owning the mutex. 5.
bool owns() const;
Effects: Returns true if this scoped_lock has acquired the referenced mutex. 6.
operator unspecified_bool_type() const;
Effects: Returns a pointer to the referenced mutex, or 0 if there is no mutex to reference. Postconditions: mutex() == 0 and owns() == false. 9.
void swap(upgradable_lock< mutex_type > & other);
Header <boost/interprocess/windows_shared_memory.hpp>
Describes a class representing a native windows shared memory.
namespace boost { namespace interprocess { class windows_shared_memory; } }
Class windows_shared_memory
boost::interprocess::windows_shared_memory
482
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/windows_shared_memory.hpp>
class windows_shared_memory { public: // construct/copy/destruct windows_shared_memory(); windows_shared_memory(create_only_t, const char *, mode_t, std::size_t, const permissions & = permissions()); windows_shared_memory(open_or_create_t, const char *, mode_t, std::size_t, const permissions & = permissions()); windows_shared_memory(open_only_t, const char *, mode_t); windows_shared_memory(windows_shared_memory &&); windows_shared_memory& operator=(windows_shared_memory &&); ~windows_shared_memory(); // public member functions void swap(windows_shared_memory &); const char * get_name() const; mode_t get_mode() const; mapping_handle_t get_mapping_handle() const; };
Description
A class that wraps the native Windows shared memory that is implemented as a le mapping of the paging le. Unlike shared_memory_object, windows_shared_memory has no kernel persistence and the shared memory is destroyed when all processes destroy all their windows_shared_memory objects and mapped regions for the same shared memory or the processes end/crash. Warning: Windows native shared memory and interprocess portable shared memory (boost::interprocess::shared_memory_object) can't communicate between them.
windows_shared_memory public construct/copy/destruct
1.
windows_shared_memory();
Creates a new native shared memory with name "name" and mode "mode", with the access mode "mode". If the le previously exists, throws an error. 3.
windows_shared_memory(open_or_create_t, const char * name, mode_t mode, std::size_t size, const permissions & perm = permissions());
Tries to create a shared memory object with name "name" and mode "mode", with the access mode "mode". If the le previously exists, it tries to open it with mode "mode". Otherwise throws an error. 4.
windows_shared_memory(open_only_t, const char * name, mode_t mode);
483
Boost.Interprocess
Tries to open a shared memory object with name "name", with the access mode "mode". If the le does not previously exist, it throws an error. 5.
windows_shared_memory(windows_shared_memory && moved);
Moves the ownership of "moved"'s shared memory object to *this. After the call, "moved" does not represent any shared memory object. Does not throw 6.
windows_shared_memory& operator=(windows_shared_memory && moved);
Moves the ownership of "moved"'s shared memory to *this. After the call, "moved" does not represent any shared memory. Does not throw 7.
~windows_shared_memory();
Destroys *this. All mapped regions are still valid after destruction. When all mapped regions and windows_shared_memory objects referring the shared memory are destroyed, the operating system will destroy the shared memory.
windows_shared_memory public member functions
1.
Header <boost/interprocess/xsi_key.hpp>
Describes a class representing a xsi key type.
namespace boost { namespace interprocess { class xsi_key; } }
Class xsi_key
boost::interprocess::xsi_key
484
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/xsi_key.hpp>
class xsi_key { public: // construct/copy/destruct xsi_key(); xsi_key(const char *, boost::uint8_t); // public member functions key_t get_key() const; };
Description
A class that wraps XSI (System V) key_t type. This type calculates key_t from path and id using ftok or sets key to IPC_PRIVATE using the default constructor.
xsi_key public construct/copy/destruct
1.
xsi_key();
Creates a new XSI shared memory with a key obtained from a call to ftok (with path "path" and id "id"), of size "size" and permissions "perm". If the shared memory previously exists, throws an error.
xsi_key public member functions
1.
Header <boost/interprocess/xsi_shared_memory.hpp>
Describes a class representing a native xsi shared memory.
namespace boost { namespace interprocess { class xsi_shared_memory; } }
Class xsi_shared_memory
boost::interprocess::xsi_shared_memory
485
Boost.Interprocess
Synopsis
// In header: <boost/interprocess/xsi_shared_memory.hpp>
class xsi_shared_memory { public: // construct/copy/destruct xsi_shared_memory(); xsi_shared_memory(open_only_t, int); xsi_shared_memory(create_only_t, const xsi_key &, std::size_t, const permissions & = permissions()); xsi_shared_memory(open_or_create_t, const xsi_key &, std::size_t, const permissions & = permissions()); xsi_shared_memory(open_only_t, const xsi_key &); xsi_shared_memory(xsi_shared_memory &&); xsi_shared_memory& operator=(xsi_shared_memory &&); ~xsi_shared_memory(); // public member functions void swap(xsi_shared_memory &); int get_shmid() const; mapping_handle_t get_mapping_handle() const; // public static functions static bool remove(int); };
Description
A class that wraps XSI (System V) shared memory. Unlike shared_memory_object, xsi_shared_memory needs a valid xsi_key to identify a shared memory object. Warning: XSI shared memory and interprocess portable shared memory (boost::interprocess::shared_memory_object) can't communicate between them.
xsi_shared_memory public construct/copy/destruct
1.
xsi_shared_memory();
Initializes *this with a shmid previously obtained (possibly from another process) This lower-level initializer allows shared memory mapping without having a key. 3.
xsi_shared_memory(create_only_t, const xsi_key & key, std::size_t size, const permissions & perm = permissions());
Creates a new XSI shared memory from 'key', with size "size" and permissions "perm". If the shared memory previously exists, throws an error. 4.
xsi_shared_memory(open_or_create_t, const xsi_key & key, std::size_t size, const permissions & perm = permissions());
486
Boost.Interprocess
Opens an existing shared memory with identier 'key' or creates a new XSI shared memory from identier 'key', with size "size" and permissions "perm". 5.
xsi_shared_memory(open_only_t, const xsi_key & key);
Tries to open a XSI shared memory with identier 'key' If the shared memory does not previously exist, it throws an error. 6.
xsi_shared_memory(xsi_shared_memory && moved);
Moves the ownership of "moved"'s shared memory object to *this. After the call, "moved" does not represent any shared memory object. Does not throw 7.
xsi_shared_memory& operator=(xsi_shared_memory && moved);
Moves the ownership of "moved"'s shared memory to *this. After the call, "moved" does not represent any shared memory. Does not throw 8.
~xsi_shared_memory();
Destroys *this. The shared memory won't be destroyed, just this connection to it. Use remove() to destroy the shared memory.
xsi_shared_memory public member functions
1.
1.
Erases the XSI shared memory object identied by shmid from the system. Returns false on error. Never throws
487