Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::interprocess::windows_shared_memory Class Reference

A class that wraps the native Windows shared memory that is implemented as a file mapping of the paging file. More...

#include <windows_shared_memory.hpp>

Public Member Functions

 windows_shared_memory ()
 Default constructor. More...
 
 windows_shared_memory (create_only_t, const char *name, mode_t mode, std::size_t size, const permissions &perm=permissions())
 Creates a new native shared memory with name "name" and at least size "size", with the access mode "mode". More...
 
 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 at least size "size", with the access mode "mode". More...
 
 windows_shared_memory (open_only_t, const char *name, mode_t mode)
 Tries to open a shared memory object with name "name", with the access mode "mode". More...
 
 windows_shared_memory (BOOST_RV_REF(windows_shared_memory) moved)
 Moves the ownership of "moved"'s shared memory object to *this. More...
 
windows_shared_memoryoperator= (BOOST_RV_REF(windows_shared_memory) moved)
 Moves the ownership of "moved"'s shared memory to *this. More...
 
void swap (windows_shared_memory &other)
 Swaps to shared_memory_objects. Does not throw. More...
 
 ~windows_shared_memory ()
 Destroys *this. More...
 
const char * get_name () const
 Returns the name of the shared memory. More...
 
mode_t get_mode () const
 Returns access mode. More...
 
mapping_handle_t get_mapping_handle () const
 Returns the mapping handle. Never throws. More...
 
offset_t get_size () const
 Returns the size of the windows shared memory. More...
 

Detailed Description

A class that wraps the native Windows shared memory that is implemented as a file mapping of the paging file.

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.

Constructor & Destructor Documentation

boost::interprocess::windows_shared_memory::windows_shared_memory ( )
inline

Default constructor.

Represents an empty windows_shared_memory.

boost::interprocess::windows_shared_memory::windows_shared_memory ( create_only_t  ,
const char *  name,
mode_t  mode,
std::size_t  size,
const permissions perm = permissions() 
)
inline

Creates a new native shared memory with name "name" and at least size "size", with the access mode "mode".

If the file previously exists, throws an error.

References boost::interprocess::ipcdetail::DoCreate.

boost::interprocess::windows_shared_memory::windows_shared_memory ( open_or_create_t  ,
const char *  name,
mode_t  mode,
std::size_t  size,
const permissions perm = permissions() 
)
inline

Tries to create a shared memory object with name "name" and at least size "size", with the access mode "mode".

If the file previously exists, it tries to open it with mode "mode". Otherwise throws an error.

References boost::interprocess::ipcdetail::DoOpenOrCreate.

boost::interprocess::windows_shared_memory::windows_shared_memory ( open_only_t  ,
const char *  name,
mode_t  mode 
)
inline

Tries to open a shared memory object with name "name", with the access mode "mode".

If the file does not previously exist, it throws an error.

References boost::interprocess::ipcdetail::DoOpen, and boost::filesystem::detail::permissions().

boost::interprocess::windows_shared_memory::windows_shared_memory ( BOOST_RV_REF(windows_shared_memory moved)
inline

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

References swap().

boost::interprocess::windows_shared_memory::~windows_shared_memory ( )
inline

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.

Member Function Documentation

mapping_handle_t boost::interprocess::windows_shared_memory::get_mapping_handle ( ) const
inline

Returns the mapping handle. Never throws.

mode_t boost::interprocess::windows_shared_memory::get_mode ( ) const
inline

Returns access mode.

const char * boost::interprocess::windows_shared_memory::get_name ( ) const
inline

Returns the name of the shared memory.

offset_t boost::interprocess::windows_shared_memory::get_size ( ) const
inline

Returns the size of the windows shared memory.

It will be a 4K rounded size of the "size" passed in the constructor.

References boost::size().

windows_shared_memory& boost::interprocess::windows_shared_memory::operator= ( BOOST_RV_REF(windows_shared_memory moved)
inline

Moves the ownership of "moved"'s shared memory to *this.

After the call, "moved" does not represent any shared memory. Does not throw

References boost::move(), and swap().

void boost::interprocess::windows_shared_memory::swap ( windows_shared_memory other)
inline

Swaps to shared_memory_objects. Does not throw.

References boost::swap.

Referenced by operator=(), and windows_shared_memory().


The documentation for this class was generated from the following file: