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 15. Boost.Interprocess

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
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
Permissions
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
Sharable and 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
Boost containers compatible with Boost.Interprocess
Memory allocation algorithms
simple_seq_fit: A simple shared memory management algorithm
rbtree_best_fit: Best-fit logarithmic-time complexity allocation
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
Notes
Indexes and Reference

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.

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.

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

  • Visual >= 7.1
  • GCC >= 4.1
  • Intel 11

Last revised: July 29, 2014 at 09:04:52 GMT


PrevUpHomeNext