Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Chapter 8. Boost.Interprocess

Ion Gaztañaga

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
Building Boost.Interprocess
Tested compilers
Quick Guide for the Impatient
Using shared memory as a pool of unnamed memory blocks
Creating named shared memory objects
Using an offset smart pointer for shared memory
Creating vectors in shared memory
Creating maps in shared memory
Some basic explanations
Processes And Threads
Sharing information between processes
Persistence Of Interprocess Mechanisms
Names Of Interprocess Mechanisms
Constructors, destructors and lifetime of Interprocess named resources
Sharing memory between processes
Shared memory
Memory Mapped Files
More About Mapped Regions
Limitations When Constructing Objects In Mapped Regions
Mapping Address Independent Pointer: offset_ptr
Synchronization mechanisms
Synchronization mechanisms overview
Mutexes
Conditions
Semaphores
Upgradable Mutexes
Lock Transfers Through Move Semantics
File Locks
Message Queue
Managed Memory Segments
Making Interprocess Data Communication Easy
Managed Shared Memory
Managed Mapped File
Managed Memory Segment Features
Managed Memory Segment Advanced Features
Managed Heap Memory And Managed External Buffer
Allocators, containers and memory allocation algorithms
Introduction to Interprocess allocators
Segregated storage node allocators
Adaptive pool node allocators
Interprocess and containers in managed memory segments
Memory allocation algorithms
Direct iostream formatting: vectorstream and bufferstream
Formatting directly in your character vector: vectorstream
Formatting directly in your character buffer: bufferstream
Ownership smart pointers
Intrusive pointer
Scoped pointer
Shared pointer and weak pointer
Unique pointer
Architecture and internals
Basic guidelines
From the memory algorithm to the managed segment
Allocators and containers
Performance of Boost.Interprocess
Customizing Boost.Interprocess
Writing a new shared memory allocation algorithm
Building custom STL compatible allocators for Boost.Interprocess
Building custom indexes
Acknowledgements, notes and links
Thanks to...
Release Notes
Books and interesting links
Future improvements...
Boost.Interprocess Reference
Header <boost/interprocess/allocators/adaptive_pool.hpp>
Header <boost/interprocess/allocators/allocation_type.hpp>
Header <boost/interprocess/allocators/allocator.hpp>
Header <boost/interprocess/allocators/cached_adaptive_pool.hpp>
Header <boost/interprocess/allocators/cached_node_allocator.hpp>
Header <boost/interprocess/allocators/node_allocator.hpp>
Header <boost/interprocess/allocators/private_adaptive_pool.hpp>
Header <boost/interprocess/allocators/private_node_allocator.hpp>
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/set.hpp>
Header <boost/interprocess/containers/slist.hpp>
Header <boost/interprocess/containers/string.hpp>
Header <boost/interprocess/containers/vector.hpp>
Header <boost/interprocess/creation_tags.hpp>
Header <boost/interprocess/exceptions.hpp>
Header <boost/interprocess/file_mapping.hpp>
Header <boost/interprocess/indexes/flat_map_index.hpp>
Header <boost/interprocess/indexes/iset_index.hpp>
Header <boost/interprocess/indexes/iunordered_set_index.hpp>
Header <boost/interprocess/indexes/map_index.hpp>
Header <boost/interprocess/indexes/null_index.hpp>
Header <boost/interprocess/indexes/unordered_map_index.hpp>
Header <boost/interprocess/interprocess_fwd.hpp>
Header <boost/interprocess/ipc/message_queue.hpp>
Header <boost/interprocess/managed_external_buffer.hpp>
Header <boost/interprocess/managed_heap_memory.hpp>
Header <boost/interprocess/managed_mapped_file.hpp>
Header <boost/interprocess/managed_shared_memory.hpp>
Header <boost/interprocess/managed_windows_shared_memory.hpp>
Header <boost/interprocess/mapped_region.hpp>
Header <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
Header <boost/interprocess/mem_algo/simple_seq_fit.hpp>
Header <boost/interprocess/offset_ptr.hpp>
Header <boost/interprocess/segment_manager.hpp>
Header <boost/interprocess/shared_memory_object.hpp>
Header <boost/interprocess/smart_ptr/deleter.hpp>
Header <boost/interprocess/smart_ptr/enable_shared_from_this.hpp>
Header <boost/interprocess/smart_ptr/intrusive_ptr.hpp>
Header <boost/interprocess/smart_ptr/scoped_ptr.hpp>
Header <boost/interprocess/smart_ptr/shared_ptr.hpp>
Header <boost/interprocess/smart_ptr/unique_ptr.hpp>
Header <boost/interprocess/smart_ptr/weak_ptr.hpp>
Header <boost/interprocess/streams/bufferstream.hpp>
Header <boost/interprocess/streams/vectorstream.hpp>
Header <boost/interprocess/sync/file_lock.hpp>
Header <boost/interprocess/sync/interprocess_barrier.hpp>
Header <boost/interprocess/sync/interprocess_condition.hpp>
Header <boost/interprocess/sync/interprocess_mutex.hpp>
Header <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
Header <boost/interprocess/sync/interprocess_semaphore.hpp>
Header <boost/interprocess/sync/interprocess_upgradable_mutex.hpp>
Header <boost/interprocess/sync/lock_options.hpp>
Header <boost/interprocess/sync/mutex_family.hpp>
Header <boost/interprocess/sync/named_condition.hpp>
Header <boost/interprocess/sync/named_mutex.hpp>
Header <boost/interprocess/sync/named_recursive_mutex.hpp>
Header <boost/interprocess/sync/named_semaphore.hpp>
Header <boost/interprocess/sync/named_upgradable_mutex.hpp>
Header <boost/interprocess/sync/null_mutex.hpp>
Header <boost/interprocess/sync/scoped_lock.hpp>
Header <boost/interprocess/sync/sharable_lock.hpp>
Header <boost/interprocess/sync/upgradable_lock.hpp>
Header <boost/interprocess/windows_shared_memory.hpp>

Boost.Interprocess simplifies the use of common interprocess communication and synchronization mechanisms and offers a wide range of them:

  • Shared memory.
  • Memory-mapped files.
  • Semaphores, mutexes, condition variables and upgradable mutex types to place them in shared memory and memory mapped files.
  • 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 file (in general, to allocate portions of a fixed 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 files:

  • Dynamic creation of anonymous and named objects in a shared memory or memory mapped file.
  • STL-like containers compatible with shared memory/memory-mapped files.
  • STL-like allocators ready for shared memory/memory-mapped files implementing several memory allocation patterns (like pooling).

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 define BOOST_DATE_TIME_NO_LIB to avoid Boost from trying to automatically link the Boost.DateTime.

Boost.Interprocess has been tested in the following compilers/platforms:

  • Visual 7.1 Windows XP
  • Visual 8.0 Windows XP
  • GCC 4.1.1 MinGW
  • GCC 3.4.4 Cygwin
  • Intel 9.1 Windows XP
  • GCC 4.1.2 Linux
  • GCC 3.4.3 Solaris 11
  • GCC 4.0 MacOs 10.4.1

Last revised: March 28, 2008 at 08:11:24 GMT


PrevUpHomeNext