mirror of
https://github.com/boostorg/interprocess.git
synced 2026-01-19 04:12:13 +00:00
Merge from trunk
[SVN r80689]
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
[/
|
||||
/ Copyright (c) 2005-2011 Ion Gaztanaga
|
||||
/ Copyright (c) 2005-2012 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)
|
||||
@@ -622,14 +622,9 @@ to shared memory created with other process that don't use
|
||||
Windows shared memory creation is a bit different from portable shared memory
|
||||
creation: the size of the segment must be specified when creating the object and
|
||||
can't be specified through `truncate` like with the shared memory object.
|
||||
|
||||
Take in care that when the last process attached to a shared memory is destroyed
|
||||
[*the shared memory is destroyed] so there is [*no persistency] with native windows
|
||||
shared memory. Native windows shared memory has also another limitation: a process can
|
||||
open and map the whole shared memory created by another process but it can't know
|
||||
which is the size of that memory. This limitation is imposed by the Windows API so
|
||||
the user must somehow transmit the size of the segment to processes opening the
|
||||
segment.
|
||||
shared memory.
|
||||
|
||||
Sharing memory between services and user applications is also different. To share memory
|
||||
between services and user applications the name of the shared memory must start with the
|
||||
@@ -865,7 +860,7 @@ to create `mapped_region` objects. A mapped region created from a shared memory
|
||||
object or a file mapping are the same class and this has many advantages.
|
||||
|
||||
One can, for example, mix in STL containers mapped regions from shared memory
|
||||
and memory mapped files. The libraries that only depend on mapped regions can
|
||||
and memory mapped files. Libraries that only depend on mapped regions can
|
||||
be used to work with shared memory or memory mapped files without recompiling them.
|
||||
|
||||
[endsect]
|
||||
@@ -881,7 +876,7 @@ surely different in each process. Since each process might have used its address
|
||||
in a different way (allocation of more or less dynamic memory, for example), there is
|
||||
no guarantee that the file/shared memory is going to be mapped in the same address.
|
||||
|
||||
If two processes map the same object in different addresses, this invalids the use
|
||||
If two processes map the same object in different addresses, this invalidates the use
|
||||
of pointers in that memory, since the pointer (which is an absolute address) would
|
||||
only make sense for the process that wrote it. The solution for this is to use offsets
|
||||
(distance) between objects instead of pointers: If two objects are placed in the same
|
||||
@@ -1590,6 +1585,14 @@ Boost.Interprocess offers the following condition types:
|
||||
An anonymous condition variable that can be placed in shared memory or memory
|
||||
mapped files to be used with [classref boost::interprocess::interprocess_mutex].
|
||||
|
||||
[c++]
|
||||
|
||||
#include <boost/interprocess/sync/interprocess_condition_any.hpp>
|
||||
|
||||
* [classref boost::interprocess::interprocess_condition_any interprocess_condition_any]:
|
||||
An anonymous condition variable that can be placed in shared memory or memory
|
||||
mapped files to be used with any lock type.
|
||||
|
||||
[c++]
|
||||
|
||||
#include <boost/interprocess/sync/named_condition.hpp>
|
||||
@@ -1597,6 +1600,13 @@ Boost.Interprocess offers the following condition types:
|
||||
* [classref boost::interprocess::named_condition named_condition]: A named
|
||||
condition variable to be used with [classref boost::interprocess::named_mutex named_mutex].
|
||||
|
||||
[c++]
|
||||
|
||||
#include <boost/interprocess/sync/named_condition_any.hpp>
|
||||
|
||||
* [classref boost::interprocess::named_condition 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:
|
||||
@@ -1725,12 +1735,12 @@ efficient than a mutex/condition combination.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:upgradable_mutexes Upgradable Mutexes]
|
||||
[section:sharable_upgradable_mutexes Sharable and Upgradable Mutexes]
|
||||
|
||||
[section:upgradable_whats_a_mutex What's An Upgradable Mutex?]
|
||||
[section:upgradable_whats_a_mutex What's a Sharable and an Upgradable Mutex?]
|
||||
|
||||
An upgradable mutex is a special mutex that offers more locking possibilities than
|
||||
a normal mutex. Sometimes, we can distinguish between [*reading] the data and
|
||||
Sharable and upgradable mutex are special mutex types that offers more locking possibilities
|
||||
than a normal mutex. Sometimes, we can distinguish between [*reading] the data and
|
||||
[*modifying] the data. If just some threads need to modify the data, and a plain mutex
|
||||
is used to protect the data from concurrent access, concurrency is pretty limited:
|
||||
two threads that only read the data will be serialized instead of being executed
|
||||
@@ -1740,20 +1750,21 @@ If we allow concurrent access to threads that just read the data but we avoid
|
||||
concurrent access between threads that read and modify or between threads that modify,
|
||||
we can increase performance. This is specially true in applications where data reading
|
||||
is more common than data modification and the synchronized data reading code needs
|
||||
some time to execute. With an upgradable mutex we can acquire 3
|
||||
lock types:
|
||||
some time to execute. With a sharable mutex we can acquire 2 lock types:
|
||||
|
||||
* [*Exclusive lock]: Similar to a plain mutex. If a thread acquires an exclusive
|
||||
lock, no other thread can acquire any lock (exclusive or other) until the exclusive
|
||||
lock is released. If any thread has a sharable or upgradable lock a thread trying
|
||||
lock is released. If any thread other has any lock other than exclusive, a thread trying
|
||||
to acquire an exclusive lock will block.
|
||||
This lock will be acquired by threads that will modify the data.
|
||||
|
||||
* [*Sharable lock]: If a thread acquires a sharable lock, other threads
|
||||
can acquire a sharable lock or an upgradable lock. If any thread has acquired
|
||||
can't acquire the exclusive lock. If any thread has acquired
|
||||
the exclusive lock a thread trying to acquire a sharable lock will block.
|
||||
This locking is executed by threads that just need to read the data.
|
||||
|
||||
With an upgradable mutex we can acquire previous locks plus a new upgradable lock:
|
||||
|
||||
* [*Upgradable lock]: Acquiring an upgradable lock is similar to acquiring
|
||||
a [*privileged sharable lock]. If a thread acquires an upgradable lock, other threads
|
||||
can acquire a sharable lock. If any thread has acquired the exclusive or upgradable lock
|
||||
@@ -1772,20 +1783,34 @@ lock types:
|
||||
|
||||
To sum up:
|
||||
|
||||
[table Locking Possibilities
|
||||
[table Locking Possibilities for a Sharable Mutex
|
||||
[[If a thread has acquired the...] [Other threads can acquire...]]
|
||||
[[Sharable lock] [many sharable locks]]
|
||||
[[Exclusive lock] [no locks]]
|
||||
]
|
||||
|
||||
[table Locking Possibilities for an Upgradable Mutex
|
||||
[[If a thread has acquired the...] [Other threads can acquire...]]
|
||||
[[Sharable lock] [many sharable locks and 1 upgradable lock]]
|
||||
[[Upgradable lock] [many sharable locks]]
|
||||
[[Exclusive lock] [no locks]]
|
||||
]
|
||||
|
||||
A thread that has acquired a lock can try to acquire another lock type atomically.
|
||||
[endsect]
|
||||
|
||||
[section:upgradable_transitions Lock transitions for Upgradable Mutex]
|
||||
|
||||
A sharable mutex has no option to change the acquired lock for another lock
|
||||
atomically.
|
||||
|
||||
On the other hand, for an upgradable mutex, a thread that has
|
||||
acquired a lock can try to acquire another lock type atomically.
|
||||
All lock transitions are not guaranteed to succeed. Even if a transition is guaranteed
|
||||
to succeed, some transitions will block the thread waiting until other threads release
|
||||
the sharable locks. [*Atomically] means that no other thread will acquire an Upgradable
|
||||
or Exclusive lock in the transition, [*so data is guaranteed to remain unchanged]:
|
||||
|
||||
[table Transition Possibilities
|
||||
[table Transition Possibilities for an Upgradable Mutex
|
||||
[[If a thread has acquired the...] [It can atomically release the previous lock and...]]
|
||||
[[Sharable lock] [try to obtain (not guaranteed) immediately the Exclusive lock if no other thread has exclusive or upgrable lock]]
|
||||
[[Sharable lock] [try to obtain (not guaranteed) immediately the Upgradable lock if no other thread has exclusive or upgrable lock]]
|
||||
@@ -1803,18 +1828,18 @@ and there are more readers than modifiers.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:upgradable_mutexes_operations Upgradable Mutex Operations]
|
||||
[section:sharable_upgradable_mutexes_operations Upgradable Mutex Operations]
|
||||
|
||||
All the upgradable mutex types from [*Boost.Interprocess] implement
|
||||
the following operations:
|
||||
|
||||
[section:upgradable_mutexes_operations_exclusive Exclusive Locking]
|
||||
[section:sharable_upgradable_mutexes_operations_exclusive Exclusive Locking (Sharable & Upgradable Mutexes)]
|
||||
|
||||
[blurb ['[*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,
|
||||
another thread has any ownership of the mutex (exclusive or other),
|
||||
it waits until it can obtain the ownership.
|
||||
|
||||
[*Throws:] *interprocess_exception* on error.
|
||||
@@ -1823,8 +1848,8 @@ it waits until it can obtain the ownership.
|
||||
|
||||
[*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.
|
||||
waiting. If no other thread has any ownership of the mutex (exclusive or other)
|
||||
this succeeds.
|
||||
|
||||
[*Returns:] If it can acquire exclusive ownership immediately returns true.
|
||||
If it has to wait, returns false.
|
||||
@@ -1835,8 +1860,8 @@ If it has to wait, returns false.
|
||||
|
||||
[*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.
|
||||
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.
|
||||
@@ -1853,7 +1878,7 @@ returns false.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:upgradable_mutexes_operations_sharable Sharable Locking]
|
||||
[section:sharable_upgradable_mutexes_operations_sharable Sharable Locking (Sharable & Upgradable Mutexes)]
|
||||
|
||||
[blurb ['[*void lock_sharable()]]]
|
||||
|
||||
@@ -1898,7 +1923,7 @@ returns false.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:upgradable_mutexes_operations_upgradable Upgradable Locking]
|
||||
[section:upgradable_mutexes_operations_upgradable Upgradable Locking (Upgradable Mutex only)]
|
||||
|
||||
[blurb ['[*void lock_upgradable()]]]
|
||||
|
||||
@@ -1943,7 +1968,7 @@ returns false.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:upgradable_mutexes_operations_demotions Demotions]
|
||||
[section:upgradable_mutexes_operations_demotions Demotions (Upgradable Mutex only)]
|
||||
|
||||
[blurb ['[*void unlock_and_lock_upgradable()]]]
|
||||
|
||||
@@ -1974,7 +1999,7 @@ ownership. This operation is non-blocking.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:upgradable_mutexes_operations_promotions Promotions]
|
||||
[section:upgradable_mutexes_operations_promotions Promotions (Upgradable Mutex only)]
|
||||
[blurb ['[*void unlock_upgradable_and_lock()]]]
|
||||
|
||||
[*Precondition:] The thread must have upgradable ownership of the mutex.
|
||||
@@ -2036,7 +2061,23 @@ are UTC time points, not local time points]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:upgradable_mutexes_mutex_interprocess_mutexes Boost.Interprocess Upgradable Mutex Types And Headers]
|
||||
[section:sharable_upgradable_mutexes_mutex_interprocess_mutexes Boost.Interprocess Sharable & Upgradable Mutex Types And Headers]
|
||||
|
||||
Boost.Interprocess offers the following sharable mutex types:
|
||||
|
||||
[c++]
|
||||
|
||||
#include <boost/interprocess/sync/interprocess_sharable_mutex.hpp>
|
||||
|
||||
* [classref boost::interprocess::interprocess_sharable_mutex interprocess_sharable_mutex]: A non-recursive,
|
||||
anonymous sharable mutex that can be placed in shared memory or memory mapped files.
|
||||
|
||||
[c++]
|
||||
|
||||
#include <boost/interprocess/sync/named_sharable_mutex.hpp>
|
||||
|
||||
* [classref boost::interprocess::named_sharable_mutex named_sharable_mutex]: A non-recursive,
|
||||
named sharable mutex.
|
||||
|
||||
Boost.Interprocess offers the following upgradable mutex types:
|
||||
|
||||
@@ -2056,7 +2097,7 @@ Boost.Interprocess offers the following upgradable mutex types:
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:upgradable_mutexes_locks Sharable Lock And Upgradable Lock]
|
||||
[section:sharable_upgradable_locks Sharable Lock And Upgradable Lock]
|
||||
|
||||
As with plain mutexes, it's important to release the acquired lock even in the presence
|
||||
of exceptions. [*Boost.Interprocess] mutexes are best used with the
|
||||
@@ -2089,20 +2130,16 @@ can use `sharable_lock` if the synchronization object offers [*lock_sharable()]
|
||||
`sharable_lock` calls [*unlock_sharable()] in its destructor, and
|
||||
`upgradable_lock` calls [*unlock_upgradable()] in its destructor, so the
|
||||
upgradable 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.
|
||||
|
||||
|
||||
[c++]
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
//Let's create any mutex type:
|
||||
MutexType mutex;
|
||||
SharableOrUpgradableMutex sh_or_up_mutex;
|
||||
|
||||
{
|
||||
//This will call lock_sharable()
|
||||
sharable_lock<MutexType> lock(mutex);
|
||||
sharable_lock<SharableOrUpgradableMutex> lock(sh_or_up_mutex);
|
||||
|
||||
//Some code
|
||||
|
||||
@@ -2111,7 +2148,7 @@ try_lock, timed_lock a mutex or not to lock it at all.
|
||||
|
||||
{
|
||||
//This won't lock the mutex()
|
||||
sharable_lock<MutexType> lock(mutex, defer_lock);
|
||||
sharable_lock<SharableOrUpgradableMutex> lock(sh_or_up_mutex, defer_lock);
|
||||
|
||||
//Lock it on demand. This will call lock_sharable()
|
||||
lock.lock();
|
||||
@@ -2123,7 +2160,7 @@ try_lock, timed_lock a mutex or not to lock it at all.
|
||||
|
||||
{
|
||||
//This will call try_lock_sharable()
|
||||
sharable_lock<MutexType> lock(mutex, try_to_lock);
|
||||
sharable_lock<SharableOrUpgradableMutex> lock(sh_or_up_mutex, try_to_lock);
|
||||
|
||||
//Check if the mutex has been successfully locked
|
||||
if(lock){
|
||||
@@ -2136,7 +2173,7 @@ try_lock, timed_lock a mutex or not to lock it at all.
|
||||
boost::posix_time::ptime abs_time = ...
|
||||
|
||||
//This will call timed_lock_sharable()
|
||||
scoped_lock<MutexType> lock(mutex, abs_time);
|
||||
scoped_lock<SharableOrUpgradableMutex> lock(sh_or_up_mutex, abs_time);
|
||||
|
||||
//Check if the mutex has been successfully locked
|
||||
if(lock){
|
||||
@@ -2145,9 +2182,11 @@ try_lock, timed_lock a mutex or not to lock it at all.
|
||||
//If the mutex was locked it will be unlocked
|
||||
}
|
||||
|
||||
UpgradableMutex up_mutex;
|
||||
|
||||
{
|
||||
//This will call lock_upgradable()
|
||||
upgradable_lock<MutexType> lock(mutex);
|
||||
upgradable_lock<UpgradableMutex> lock(up_mutex);
|
||||
|
||||
//Some code
|
||||
|
||||
@@ -2156,7 +2195,7 @@ try_lock, timed_lock a mutex or not to lock it at all.
|
||||
|
||||
{
|
||||
//This won't lock the mutex()
|
||||
upgradable_lock<MutexType> lock(mutex, defer_lock);
|
||||
upgradable_lock<UpgradableMutex> lock(up_mutex, defer_lock);
|
||||
|
||||
//Lock it on demand. This will call lock_upgradable()
|
||||
lock.lock();
|
||||
@@ -2168,7 +2207,7 @@ try_lock, timed_lock a mutex or not to lock it at all.
|
||||
|
||||
{
|
||||
//This will call try_lock_upgradable()
|
||||
upgradable_lock<MutexType> lock(mutex, try_to_lock);
|
||||
upgradable_lock<UpgradableMutex> lock(up_mutex, try_to_lock);
|
||||
|
||||
//Check if the mutex has been successfully locked
|
||||
if(lock){
|
||||
@@ -2181,7 +2220,7 @@ try_lock, timed_lock a mutex or not to lock it at all.
|
||||
boost::posix_time::ptime abs_time = ...
|
||||
|
||||
//This will call timed_lock_upgradable()
|
||||
scoped_lock<MutexType> lock(mutex, abs_time);
|
||||
scoped_lock<UpgradableMutex> lock(up_mutex, abs_time);
|
||||
|
||||
//Check if the mutex has been successfully locked
|
||||
if(lock){
|
||||
@@ -6574,11 +6613,13 @@ example, a new managed shared memory that uses the new index:
|
||||
|
||||
[section:notes_windows Notes for Windows users]
|
||||
|
||||
[*Boost.Interprocess] uses the COM library to implement some features and initializes
|
||||
the COM library with concurrency model `COINIT_APARTMENTTHREADED`.
|
||||
If the COM library was already initialized by the calling thread for other model, [*Boost.Interprocess]
|
||||
[section:notes_windows_com_init COM Initialization]
|
||||
|
||||
[*Boost.Interprocess] uses the Windows COM library to implement some features and initializes
|
||||
it with concurrency model `COINIT_APARTMENTTHREADED`.
|
||||
If the COM library was already initialized by the calling thread for another concurrency model, [*Boost.Interprocess]
|
||||
handles this gracefully and uses COM calls for the already initialized model. If for some reason, you
|
||||
might want [*Boost.Interprocess] to initialize the COM library with another model, define the macro
|
||||
want [*Boost.Interprocess] to initialize the COM library with another model, define the macro
|
||||
`BOOST_INTERPROCESS_WINDOWS_COINIT_MODEL` before including [*Boost.Interprocess] to one of these values:
|
||||
|
||||
* `COINIT_APARTMENTTHREADED_BIPC`
|
||||
@@ -6588,6 +6629,46 @@ might want [*Boost.Interprocess] to initialize the COM library with another mode
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:notes_windows_shm_folder Shared memory emulation folder]
|
||||
|
||||
Shared memory (`shared_memory_object`) is implemented in windows using memory mapped files, placed in a
|
||||
directory in the shared documents folder (`SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Common AppData`).
|
||||
This directory name is the last bootup time (obtained via COM calls), so that each bootup shared memory is created in a new
|
||||
folder obtaining kernel persistence shared memory.
|
||||
|
||||
Unfortunately, due to COM implementation related errors, in Boost 1.48 & Boost 1.49 the bootup-time folder was dumped and files
|
||||
were directly created in shared documents folder, reverting to filesystem persistence shared memory. Boost 1.50 fixed those issues
|
||||
and recovered bootup time directory and kernel persistence. If you need to reproduce Boost 1.48 & Boost 1.49 behaviour to communicate
|
||||
with applications compiled with that version, comment `#define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME` directive
|
||||
in the Windows configuration part of `boost/interprocess/detail/workaround.hpp`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:notes_linux Notes for Linux users]
|
||||
|
||||
[section:notes_linux_overcommit Overcommit]
|
||||
|
||||
The committed address space is the total amount of virtual memory (swap or physical memory/RAM) that the kernel might have to supply
|
||||
if all applications decide to access all of the memory they've requested from the kernel.
|
||||
By default, Linux allows processes to commit more virtual memory than available in the system. If that memory is not
|
||||
accessed, no physical memory + swap is actually used.
|
||||
|
||||
The reason for this behaviour is that Linux tries to optimize memory usage on forked processes; fork() creates a full copy of
|
||||
the process space, but with overcommitted memory, in this new forked instance only pages which have been written to actually need
|
||||
to be allocated by the kernel. If applications access more memory than available, then the kernel must free memory in the hard way:
|
||||
the OOM (Out Of Memory)-killer picks some processes to kill in order to recover memory.
|
||||
|
||||
[*Boost.Interprocess] has no way to change this behaviour and users might suffer the OOM-killer when accessing shared memory.
|
||||
According to the [@http://www.kernel.org/doc/Documentation/vm/overcommit-accounting Kernel documentation], the
|
||||
Linux kernel supports several overcommit modes. If you need non-kill guarantees in your application, you should
|
||||
change this overcommit behaviour.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:thanks_to Thanks to...]
|
||||
@@ -6635,11 +6716,30 @@ thank them:
|
||||
|
||||
[section:release_notes Release Notes]
|
||||
|
||||
[section:release_notes_boost_1_52_00 Boost 1.52 Release]
|
||||
|
||||
* Added `shrink_by` and `advise` functions in `mapped_region`.
|
||||
* [*ABI breaking]Reimplemented `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
|
||||
undefining 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 configurations).
|
||||
* Implemented `sharable_mutex` and `interproces_condition_any`.
|
||||
* Improved `offset_ptr` performance.
|
||||
* Added integer overflow checks.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:release_notes_boost_1_51_00 Boost 1.51 Release]
|
||||
|
||||
* Synchronous and asynchronous flushing for `mapped_region::flush`.
|
||||
* Source & ABI breaking: Removed `get_offset` method from `mapped_region` as
|
||||
* [*Source & ABI breaking]: Removed `get_offset` method from `mapped_region` as
|
||||
it has no practical utility and `m_offset` member was not for anything else.
|
||||
* [*Source & ABI breaking]: Removed `flush` from `managed_shared_memory`.
|
||||
as it is unspecified according to POSIX:
|
||||
[@http://pubs.opengroup.org/onlinepubs/009695399/functions/msync.html
|
||||
['"The effect of msync() on a shared memory object or a typed memory object is unspecified"] ].
|
||||
* Fixed bug
|
||||
[@https://svn.boost.org/trac/boost/ticket/7152 #7152],
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Boost Interprocess Library Example Jamfile
|
||||
|
||||
# (C) Copyright Ion Gaztanaga 2006.
|
||||
# (C) Copyright Ion Gaztanaga 2006-2012.
|
||||
# Use, modification and distribution are subject to the
|
||||
# Boost Software License, Version 1.0. (See accompanying file
|
||||
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
@@ -23,7 +23,7 @@ int main ()
|
||||
|
||||
//Write all the memory to 1
|
||||
std::memset(region.get_address(), 1, region.get_size());
|
||||
|
||||
|
||||
//The segment is unmapped when "region" goes out of scope
|
||||
}
|
||||
catch(interprocess_exception &ex){
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
@@ -93,7 +93,7 @@ int main ()
|
||||
//Clear errors and rewind
|
||||
mybufstream.clear();
|
||||
mybufstream.seekp(0, std::ios::beg);
|
||||
|
||||
|
||||
//Now write again the data trying to do a buffer overflow
|
||||
for(int i = 0, m = data.size()*5; i < m; ++i){
|
||||
mybufstream << data[i%5] << std::endl;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
@@ -111,7 +111,7 @@ int main()
|
||||
m_segment.deallocate(ptrs.back());
|
||||
ptrs.pop_back();
|
||||
ptrs.push_back(m_segment.allocate_aligned(128, 128));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
@@ -81,7 +81,7 @@ int main()
|
||||
{
|
||||
//Now create a read-only version
|
||||
managed_mapped_file managed_file_ro(open_read_only, ManagedFile);
|
||||
|
||||
|
||||
//Check the original is intact
|
||||
if(!managed_file_ro.find<int>("MyInt").first && managed_file_ro.find<int>("MyInt2").first)
|
||||
throw int(0);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
@@ -54,7 +54,7 @@ int main()
|
||||
//from the first one and duplicate all the data.
|
||||
static boost::aligned_storage<memsize>::type static_buffer2;
|
||||
std::memcpy(&static_buffer2, &static_buffer, memsize);
|
||||
|
||||
|
||||
//Now open the duplicated managed memory passing the memory as argument
|
||||
wmanaged_external_buffer objects_in_static_memory2
|
||||
(open_only, &static_buffer2, memsize);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
@@ -50,7 +50,7 @@ int main ()
|
||||
//use previously obtained handle to find the new pointer.
|
||||
mylist = static_cast<MyList *>
|
||||
(heap_memory.get_address_from_handle(list_handle));
|
||||
|
||||
|
||||
//Fill list until there is no more memory in the buffer
|
||||
try{
|
||||
while(1) {
|
||||
@@ -61,7 +61,7 @@ int main ()
|
||||
//memory is full
|
||||
}
|
||||
|
||||
//Let's obtain the new size of the list
|
||||
//Let's obtain the new size of the list
|
||||
MyList::size_type new_size = mylist->size();
|
||||
|
||||
assert(new_size > old_size);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
@@ -25,7 +25,7 @@ typedef list<int, allocator<int, managed_mapped_file::segment_manager> >
|
||||
MyList;
|
||||
|
||||
int main ()
|
||||
{
|
||||
{
|
||||
//Define file names
|
||||
//<-
|
||||
#if 1
|
||||
@@ -77,7 +77,7 @@ int main ()
|
||||
//so use previously obtained handle to find the new pointer.
|
||||
MyList *mylist = static_cast<MyList *>
|
||||
(mfile_memory.get_address_from_handle(list_handle));
|
||||
|
||||
|
||||
//Fill list until there is no more room in the file
|
||||
try{
|
||||
while(1) {
|
||||
@@ -88,7 +88,7 @@ int main ()
|
||||
//mapped file is full
|
||||
}
|
||||
|
||||
//Let's obtain the new size of the list
|
||||
//Let's obtain the new size of the list
|
||||
MyList::size_type new_size = mylist->size();
|
||||
|
||||
assert(new_size > old_size);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
@@ -64,8 +64,7 @@ int main()
|
||||
|
||||
//Initialize our data
|
||||
while(!chain.empty()){
|
||||
void *buf = chain.front();
|
||||
chain.pop_front();
|
||||
void *buf = chain.pop_front();
|
||||
allocated_buffers.push_back(buf);
|
||||
//The iterator must be incremented before overwriting memory
|
||||
//because otherwise, the iterator is invalidated.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
@@ -28,7 +28,7 @@ int main ()
|
||||
typedef allocator<char, SegmentManager> CharAllocator;
|
||||
typedef basic_string<char, std::char_traits<char>
|
||||
,CharAllocator> MyShmString;
|
||||
typedef allocator<MyShmString, SegmentManager> StringAllocator;
|
||||
typedef allocator<MyShmString, SegmentManager> StringAllocator;
|
||||
typedef vector<MyShmString, StringAllocator> MyShmStringVector;
|
||||
|
||||
//Remove shared memory on construction and destruction
|
||||
@@ -73,7 +73,7 @@ int main ()
|
||||
//strings, leading to a great performance.
|
||||
MyShmString string_to_compare(charallocator);
|
||||
string_to_compare = "this is a long, long, long, long, long, long, string...";
|
||||
|
||||
|
||||
myshmvector->reserve(50);
|
||||
for(int i = 0; i < 50; ++i){
|
||||
MyShmString move_me(string_to_compare);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
@@ -112,12 +112,12 @@ int main(int argc, char *argv[])
|
||||
std::pair<MyType*, managed_shared_memory::size_type> res;
|
||||
|
||||
//Find the array
|
||||
res = segment.find<MyType> ("MyType array");
|
||||
res = segment.find<MyType> ("MyType array");
|
||||
//Length should be 10
|
||||
if(res.second != 10) return 1;
|
||||
|
||||
//Find the object
|
||||
res = segment.find<MyType> ("MyType instance");
|
||||
res = segment.find<MyType> ("MyType instance");
|
||||
//Length should be 1
|
||||
if(res.second != 1) return 1;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
@@ -77,7 +77,7 @@ int main ()
|
||||
//->
|
||||
|
||||
for(int i = 0; i < 10; ++i){
|
||||
|
||||
|
||||
//Do some operations...
|
||||
|
||||
//Write to file atomically
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
@@ -68,7 +68,7 @@ int main ()
|
||||
//is the same, this private_adaptive_pool will have its own pool so
|
||||
//"allocator_instance2" CAN'T deallocate nodes allocated by "allocator_instance".
|
||||
//"allocator_instance2" is NOT equal to "allocator_instance"
|
||||
assert(allocator_instance != allocator_instance2);
|
||||
assert(allocator_instance != allocator_instance2);
|
||||
|
||||
//Create another adaptive_pool using copy-constructor.
|
||||
private_adaptive_pool_t allocator_instance3(allocator_instance2);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
@@ -68,7 +68,7 @@ int main ()
|
||||
//is the same, this private_node_allocator will have its own pool so
|
||||
//"allocator_instance2" CAN'T deallocate nodes allocated by "allocator_instance".
|
||||
//"allocator_instance2" is NOT equal to "allocator_instance"
|
||||
assert(allocator_instance != allocator_instance2);
|
||||
assert(allocator_instance != allocator_instance2);
|
||||
|
||||
//Create another node_allocator using copy-constructor.
|
||||
private_node_allocator_t allocator_instance3(allocator_instance2);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
@@ -86,7 +86,7 @@ int main ()
|
||||
my_class * my_object = shmem.construct<my_class>("my_object")();
|
||||
my_class * my_object2 = shmem.construct<my_class>(anonymous_instance)();
|
||||
shmem.destroy_ptr(my_object2);
|
||||
|
||||
|
||||
//Since the next shared memory allocation can throw
|
||||
//assign it to a scoped_ptr so that if an exception occurs
|
||||
//we destroy the object automatically
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011.
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012.
|
||||
// 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)
|
||||
@@ -128,11 +128,11 @@ int main ()
|
||||
//Now destroy the remaining owner. "object to share" will be destroyed
|
||||
file.destroy_ptr(owner2);
|
||||
assert(file.find<type_to_share>("object to share").first == 0);
|
||||
|
||||
|
||||
//Test observer
|
||||
assert(local_observer1.expired());
|
||||
assert(local_observer1.use_count() == 0);
|
||||
|
||||
|
||||
//The reference count will be deallocated when all weak pointers
|
||||
//disappear. After that, the file is unmapped.
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011.
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012.
|
||||
// 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)
|
||||
@@ -62,7 +62,7 @@ int main ()
|
||||
//<-
|
||||
#endif
|
||||
//->
|
||||
|
||||
|
||||
//Create a shared pointer in shared memory
|
||||
//pointing to a newly created object in the segment
|
||||
my_shared_ptr &shared_ptr_instance =
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011.
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012.
|
||||
// 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)
|
||||
@@ -97,11 +97,11 @@ int main ()
|
||||
unique_vector->push_back(boost::move(p));
|
||||
assert(unique_vector->back()->number_ == i);
|
||||
}
|
||||
|
||||
|
||||
//Now create a list of unique pointers
|
||||
unique_ptr_list_t *unique_list =
|
||||
file.construct<unique_ptr_list_t>("unique list")(file.get_segment_manager());
|
||||
|
||||
|
||||
//Pass ownership of all values to the list
|
||||
for(int i = 99; !unique_vector->empty(); --i){
|
||||
unique_list->push_front(boost::move(unique_vector->back()));
|
||||
@@ -131,7 +131,7 @@ int main ()
|
||||
for(int i = 0; i < 100; ++i, ++list_it){
|
||||
assert((*list_it)->number_ == i);
|
||||
}
|
||||
|
||||
|
||||
//Now destroy the list. All elements will be automatically deallocated.
|
||||
file.destroy_ptr(unique_list);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
@@ -27,7 +27,7 @@ int main ()
|
||||
typedef basic_string<char, std::char_traits<char>, CharAllocator>
|
||||
MyShmString;
|
||||
typedef allocator<MyShmString, managed_shared_memory::segment_manager>
|
||||
StringAllocator;
|
||||
StringAllocator;
|
||||
typedef vector<MyShmString, StringAllocator>
|
||||
MyShmStringVector;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
@@ -105,7 +105,7 @@ class adaptive_pool_base
|
||||
//!adaptive_pool_base
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef adaptive_pool_base<Version, T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
|
||||
};
|
||||
|
||||
@@ -129,8 +129,8 @@ class adaptive_pool_base
|
||||
//!count of the associated node pool. Never throws
|
||||
adaptive_pool_base(const adaptive_pool_base &other)
|
||||
: mp_node_pool(other.get_node_pool())
|
||||
{
|
||||
node_pool<0>::get(ipcdetail::to_raw_pointer(mp_node_pool))->inc_ref_count();
|
||||
{
|
||||
node_pool<0>::get(ipcdetail::to_raw_pointer(mp_node_pool))->inc_ref_count();
|
||||
}
|
||||
|
||||
//!Assignment from other adaptive_pool_base
|
||||
@@ -211,7 +211,7 @@ class adaptive_pool_v1
|
||||
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef adaptive_pool_v1<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
|
||||
};
|
||||
|
||||
@@ -271,7 +271,7 @@ class adaptive_pool
|
||||
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef adaptive_pool<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
|
||||
};
|
||||
|
||||
@@ -303,7 +303,7 @@ class adaptive_pool
|
||||
//!adaptive_pool
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef adaptive_pool<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
@@ -115,7 +115,7 @@ class allocator
|
||||
//!objects of type T2
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef allocator<T2, SegmentManager> other;
|
||||
};
|
||||
|
||||
@@ -145,8 +145,9 @@ class allocator
|
||||
pointer allocate(size_type count, cvoid_ptr hint = 0)
|
||||
{
|
||||
(void)hint;
|
||||
if(count > this->max_size())
|
||||
if(size_overflows<sizeof(T)>(count)){
|
||||
throw bad_alloc();
|
||||
}
|
||||
return pointer(static_cast<value_type*>(mp_mngr->allocate(count*sizeof(T))));
|
||||
}
|
||||
|
||||
@@ -169,7 +170,7 @@ class allocator
|
||||
//!pointed by p can hold. This size only works for memory allocated with
|
||||
//!allocate, allocation_command and allocate_many.
|
||||
size_type size(const pointer &p) const
|
||||
{
|
||||
{
|
||||
return (size_type)mp_mngr->size(ipcdetail::to_raw_pointer(p))/sizeof(T);
|
||||
}
|
||||
|
||||
@@ -192,7 +193,10 @@ class allocator
|
||||
multiallocation_chain allocate_many
|
||||
(size_type elem_size, size_type num_elements)
|
||||
{
|
||||
return multiallocation_chain(mp_mngr->allocate_many(sizeof(T)*elem_size, num_elements));
|
||||
if(size_overflows<sizeof(T)>(elem_size)){
|
||||
throw bad_alloc();
|
||||
}
|
||||
return multiallocation_chain(mp_mngr->allocate_many(elem_size*sizeof(T), num_elements));
|
||||
}
|
||||
|
||||
//!Allocates n_elements elements, each one of size elem_sizes[i]in a
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
@@ -69,7 +69,7 @@ class cached_adaptive_pool_v1
|
||||
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef cached_adaptive_pool_v1
|
||||
<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
|
||||
};
|
||||
@@ -149,7 +149,7 @@ class cached_adaptive_pool
|
||||
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef cached_adaptive_pool
|
||||
<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
|
||||
};
|
||||
@@ -183,7 +183,7 @@ class cached_adaptive_pool
|
||||
//!cached_adaptive_pool
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef cached_adaptive_pool<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
@@ -64,7 +64,7 @@ class cached_node_allocator_v1
|
||||
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef cached_node_allocator_v1
|
||||
<T2, SegmentManager, NodesPerBlock> other;
|
||||
};
|
||||
@@ -122,7 +122,7 @@ class cached_node_allocator
|
||||
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef cached_node_allocator<T2, SegmentManager, NodesPerBlock> other;
|
||||
};
|
||||
|
||||
@@ -155,7 +155,7 @@ class cached_node_allocator
|
||||
//!cached_node_allocator
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef cached_node_allocator<T2, SegmentManager> other;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
@@ -74,7 +74,7 @@ class private_adaptive_node_pool
|
||||
};
|
||||
|
||||
//!Pooled shared memory allocator using adaptive pool. Includes
|
||||
//!a reference count but the class does not delete itself, this is
|
||||
//!a reference count but the class does not delete itself, this is
|
||||
//!responsibility of user classes. Node size (NodeSize) and the number of
|
||||
//!nodes allocated per block (NodesPerBlock) are known at compile time
|
||||
template< class SegmentManager
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2008. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2008-2012. 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)
|
||||
//
|
||||
@@ -73,7 +73,7 @@ namespace ipcdetail {
|
||||
template<class NodePool>
|
||||
struct get_or_create_node_pool_func
|
||||
{
|
||||
|
||||
|
||||
//!This connects or constructs the unique instance of node_pool_t
|
||||
//!Can throw boost::interprocess::bad_alloc
|
||||
void operator()()
|
||||
@@ -90,7 +90,7 @@ struct get_or_create_node_pool_func
|
||||
//!object parameters
|
||||
get_or_create_node_pool_func(typename NodePool::segment_manager *mngr)
|
||||
: mp_segment_manager(mngr){}
|
||||
|
||||
|
||||
NodePool *mp_node_pool;
|
||||
typename NodePool::segment_manager *mp_segment_manager;
|
||||
};
|
||||
@@ -118,7 +118,7 @@ struct destroy_if_last_link_func
|
||||
|
||||
//Last link, let's destroy the segment_manager
|
||||
mp_node_pool->get_segment_manager()->template destroy<NodePool>(boost::interprocess::unique_instance);
|
||||
}
|
||||
}
|
||||
|
||||
//!Constructor. Initializes function
|
||||
//!object parameters
|
||||
@@ -173,7 +173,7 @@ class cache_impl
|
||||
~cache_impl()
|
||||
{
|
||||
this->deallocate_all_cached_nodes();
|
||||
ipcdetail::destroy_node_pool_if_last_link(ipcdetail::to_raw_pointer(mp_node_pool));
|
||||
ipcdetail::destroy_node_pool_if_last_link(ipcdetail::to_raw_pointer(mp_node_pool));
|
||||
}
|
||||
|
||||
NodePool *get_node_pool() const
|
||||
@@ -191,8 +191,7 @@ class cache_impl
|
||||
if(m_cached_nodes.empty()){
|
||||
m_cached_nodes = mp_node_pool->allocate_nodes(m_max_cached_nodes/2);
|
||||
}
|
||||
void *ret = ipcdetail::to_raw_pointer(m_cached_nodes.front());
|
||||
m_cached_nodes.pop_front();
|
||||
void *ret = ipcdetail::to_raw_pointer(m_cached_nodes.pop_front());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -203,8 +202,7 @@ class cache_impl
|
||||
BOOST_TRY{
|
||||
//If don't have any cached node, we have to get a new list of free nodes from the pool
|
||||
while(!m_cached_nodes.empty() && count--){
|
||||
void *ret = ipcdetail::to_raw_pointer(m_cached_nodes.front());
|
||||
m_cached_nodes.pop_front();
|
||||
void *ret = ipcdetail::to_raw_pointer(m_cached_nodes.pop_front());
|
||||
chain.push_back(ret);
|
||||
++allocated;
|
||||
}
|
||||
@@ -335,7 +333,7 @@ class array_allocation_impl
|
||||
//!pointed by p can hold. This size only works for memory allocated with
|
||||
//!allocate, allocation_command and allocate_many.
|
||||
size_type size(const pointer &p) const
|
||||
{
|
||||
{
|
||||
return (size_type)this->derived()->get_segment_manager()->size(ipcdetail::to_raw_pointer(p))/sizeof(T);
|
||||
}
|
||||
|
||||
@@ -357,7 +355,10 @@ class array_allocation_impl
|
||||
//!with deallocate(...)
|
||||
multiallocation_chain allocate_many(size_type elem_size, size_type num_elements)
|
||||
{
|
||||
return this->derived()->get_segment_manager()->allocate_many(sizeof(T)*elem_size, num_elements);
|
||||
if(size_overflows<sizeof(T)>(elem_size)){
|
||||
throw bad_alloc();
|
||||
}
|
||||
return this->derived()->get_segment_manager()->allocate_many(elem_size*sizeof(T), num_elements);
|
||||
}
|
||||
|
||||
//!Allocates n_elements elements, each one of size elem_sizes[i]in a
|
||||
@@ -457,14 +458,17 @@ class node_pool_allocation_impl
|
||||
(void)hint;
|
||||
typedef typename node_pool<0>::type node_pool_t;
|
||||
node_pool_t *pool = node_pool<0>::get(this->derived()->get_node_pool());
|
||||
if(count > this->max_size())
|
||||
if(size_overflows<sizeof(T)>(count)){
|
||||
throw bad_alloc();
|
||||
else if(Version == 1 && count == 1)
|
||||
}
|
||||
else if(Version == 1 && count == 1){
|
||||
return pointer(static_cast<value_type*>
|
||||
(pool->allocate_node()));
|
||||
else
|
||||
}
|
||||
else{
|
||||
return pointer(static_cast<value_type*>
|
||||
(pool->get_segment_manager()->allocate(sizeof(T)*count)));
|
||||
(pool->get_segment_manager()->allocate(count*sizeof(T))));
|
||||
}
|
||||
}
|
||||
|
||||
//!Deallocate allocated memory. Never throws
|
||||
@@ -605,14 +609,15 @@ class cached_allocator_impl
|
||||
{
|
||||
(void)hint;
|
||||
void * ret;
|
||||
if(count > this->max_size())
|
||||
if(size_overflows<sizeof(T)>(count)){
|
||||
throw bad_alloc();
|
||||
}
|
||||
else if(Version == 1 && count == 1){
|
||||
ret = m_cache.cached_allocation();
|
||||
}
|
||||
else{
|
||||
ret = this->get_segment_manager()->allocate(sizeof(T)*count);
|
||||
}
|
||||
ret = this->get_segment_manager()->allocate(count*sizeof(T));
|
||||
}
|
||||
return pointer(static_cast<T*>(ret));
|
||||
}
|
||||
|
||||
@@ -699,7 +704,7 @@ bool operator!=(const cached_allocator_impl<T, N, V> &alloc1,
|
||||
|
||||
|
||||
//!Pooled shared memory allocator using adaptive pool. Includes
|
||||
//!a reference count but the class does not delete itself, this is
|
||||
//!a reference count but the class does not delete itself, this is
|
||||
//!responsibility of user classes. Node size (NodeSize) and the number of
|
||||
//!nodes allocated per block (NodesPerBlock) are known at compile time
|
||||
template<class private_node_allocator_t>
|
||||
@@ -736,7 +741,7 @@ class shared_pool_impl
|
||||
//-----------------------
|
||||
return private_node_allocator_t::allocate_node();
|
||||
}
|
||||
|
||||
|
||||
//!Deallocates an array pointed by ptr. Never throws
|
||||
void deallocate_node(void *ptr)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
@@ -37,7 +37,7 @@ namespace ipcdetail {
|
||||
|
||||
|
||||
//!Pooled shared memory allocator using single segregated storage. Includes
|
||||
//!a reference count but the class does not delete itself, this is
|
||||
//!a reference count but the class does not delete itself, this is
|
||||
//!responsibility of user classes. Node size (NodeSize) and the number of
|
||||
//!nodes allocated per block (NodesPerBlock) are known at compile time
|
||||
template< class SegmentManager, std::size_t NodeSize, std::size_t NodesPerBlock >
|
||||
@@ -73,11 +73,11 @@ class private_node_pool
|
||||
|
||||
|
||||
//!Pooled shared memory allocator using single segregated storage. Includes
|
||||
//!a reference count but the class does not delete itself, this is
|
||||
//!a reference count but the class does not delete itself, this is
|
||||
//!responsibility of user classes. Node size (NodeSize) and the number of
|
||||
//!nodes allocated per block (NodesPerBlock) are known at compile time
|
||||
//!Pooled shared memory allocator using adaptive pool. Includes
|
||||
//!a reference count but the class does not delete itself, this is
|
||||
//!a reference count but the class does not delete itself, this is
|
||||
//!responsibility of user classes. Node size (NodeSize) and the number of
|
||||
//!nodes allocated per block (NodesPerBlock) are known at compile time
|
||||
template< class SegmentManager
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2007-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
@@ -102,7 +102,7 @@ class node_allocator_base
|
||||
//!node_allocator_base
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef node_allocator_base<Version, T2, SegmentManager, NodesPerBlock> other;
|
||||
};
|
||||
|
||||
@@ -128,8 +128,8 @@ class node_allocator_base
|
||||
//!count of the associated node pool. Never throws
|
||||
node_allocator_base(const node_allocator_base &other)
|
||||
: mp_node_pool(other.get_node_pool())
|
||||
{
|
||||
node_pool<0>::get(ipcdetail::to_raw_pointer(mp_node_pool))->inc_ref_count();
|
||||
{
|
||||
node_pool<0>::get(ipcdetail::to_raw_pointer(mp_node_pool))->inc_ref_count();
|
||||
}
|
||||
|
||||
//!Copy constructor from related node_allocator_base. If not present, constructs
|
||||
@@ -206,7 +206,7 @@ class node_allocator_v1
|
||||
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef node_allocator_v1<T2, SegmentManager, NodesPerBlock> other;
|
||||
};
|
||||
|
||||
@@ -256,7 +256,7 @@ class node_allocator
|
||||
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef node_allocator<T2, SegmentManager, NodesPerBlock> other;
|
||||
};
|
||||
|
||||
@@ -288,7 +288,7 @@ class node_allocator
|
||||
//!node_allocator
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef node_allocator<T2, SegmentManager, NodesPerBlock> other;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
@@ -102,7 +102,7 @@ class private_adaptive_pool_base
|
||||
//!Obtains node_allocator from other node_allocator
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef private_adaptive_pool_base
|
||||
<Version, T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
|
||||
};
|
||||
@@ -210,7 +210,7 @@ class private_adaptive_pool_v1
|
||||
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef private_adaptive_pool_v1<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
|
||||
};
|
||||
|
||||
@@ -269,7 +269,7 @@ class private_adaptive_pool
|
||||
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef private_adaptive_pool
|
||||
<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
|
||||
};
|
||||
@@ -302,7 +302,7 @@ class private_adaptive_pool
|
||||
//!private_adaptive_pool
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef private_adaptive_pool
|
||||
<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
@@ -97,7 +97,7 @@ class private_node_allocator_base
|
||||
//!Obtains node_allocator from other node_allocator
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef private_node_allocator_base
|
||||
<Version, T2, SegmentManager, NodesPerBlock> other;
|
||||
};
|
||||
@@ -198,7 +198,7 @@ class private_node_allocator_v1
|
||||
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef private_node_allocator_v1<T2, SegmentManager, NodesPerBlock> other;
|
||||
};
|
||||
|
||||
@@ -246,7 +246,7 @@ class private_node_allocator
|
||||
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef private_node_allocator
|
||||
<T2, SegmentManager, NodesPerBlock> other;
|
||||
};
|
||||
@@ -279,7 +279,7 @@ class private_node_allocator
|
||||
//!private_node_allocator
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
{
|
||||
typedef private_node_allocator
|
||||
<T2, SegmentManager, NodesPerBlock> other;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
@@ -90,13 +90,13 @@ anonymous_shared_memory(std::size_t size, void *address = 0)
|
||||
, 0);
|
||||
|
||||
if(address == MAP_FAILED){
|
||||
if(fd != -1)
|
||||
if(fd != -1)
|
||||
close(fd);
|
||||
error_info err = system_error_code();
|
||||
throw interprocess_exception(err);
|
||||
}
|
||||
|
||||
if(fd != -1)
|
||||
if(fd != -1)
|
||||
close(fd);
|
||||
|
||||
return ipcdetail::raw_mapped_region_creator::create_posix_mapped_region(address, size);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2008-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2009. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2009-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2008-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2008-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2008-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2008-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2008-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2008-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2008-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2008-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2008-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2008-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2008-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2008-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2011
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012
|
||||
// (C) Copyright Markus Schoepflin 2007
|
||||
// (C) Copyright Bryce Lelbach 2010
|
||||
//
|
||||
@@ -390,96 +390,96 @@ inline boost::uint32_t atomic_cas32(
|
||||
} //namespace interprocess{
|
||||
} //namespace boost{
|
||||
|
||||
#elif defined(__IBMCPP__) && (__IBMCPP__ >= 800) && defined(_AIX)
|
||||
#elif defined(__IBMCPP__) && (__IBMCPP__ >= 800) && defined(_AIX)
|
||||
|
||||
#include <builtins.h>
|
||||
#include <builtins.h>
|
||||
|
||||
namespace boost {
|
||||
namespace interprocess {
|
||||
namespace ipcdetail{
|
||||
namespace boost {
|
||||
namespace interprocess {
|
||||
namespace ipcdetail{
|
||||
|
||||
//first define boost::uint32_t versions of __lwarx and __stwcx to avoid poluting
|
||||
//all the functions with casts
|
||||
//first define boost::uint32_t versions of __lwarx and __stwcx to avoid poluting
|
||||
//all the functions with casts
|
||||
|
||||
//! From XLC documenation :
|
||||
//! This function can be used with a subsequent stwcxu call to implement a
|
||||
//! read-modify-write on a specified memory location. The two functions work
|
||||
//! together to ensure that if the store is successfully performed, no other
|
||||
//! processor or mechanism can modify the target doubleword between the time
|
||||
//! lwarxu function is executed and the time the stwcxu functio ncompletes.
|
||||
//! "mem" : pointer to the object
|
||||
//! Returns the value at pointed to by mem
|
||||
inline boost::uint32_t lwarxu(volatile boost::uint32_t *mem)
|
||||
{
|
||||
return static_cast<boost::uint32_t>(__lwarx(reinterpret_cast<volatile int*>(mem)));
|
||||
}
|
||||
//! From XLC documenation :
|
||||
//! This function can be used with a subsequent stwcxu call to implement a
|
||||
//! read-modify-write on a specified memory location. The two functions work
|
||||
//! together to ensure that if the store is successfully performed, no other
|
||||
//! processor or mechanism can modify the target doubleword between the time
|
||||
//! lwarxu function is executed and the time the stwcxu functio ncompletes.
|
||||
//! "mem" : pointer to the object
|
||||
//! Returns the value at pointed to by mem
|
||||
inline boost::uint32_t lwarxu(volatile boost::uint32_t *mem)
|
||||
{
|
||||
return static_cast<boost::uint32_t>(__lwarx(reinterpret_cast<volatile int*>(mem)));
|
||||
}
|
||||
|
||||
//! "mem" : pointer to the object
|
||||
//! "val" : the value to store
|
||||
//! Returns true if the update of mem is successful and false if it is
|
||||
//!unsuccessful
|
||||
inline bool stwcxu(volatile boost::uint32_t* mem, boost::uint32_t val)
|
||||
{
|
||||
return (__stwcx(reinterpret_cast<volatile int*>(mem), static_cast<int>(val)) != 0);
|
||||
}
|
||||
//! "mem" : pointer to the object
|
||||
//! "val" : the value to store
|
||||
//! Returns true if the update of mem is successful and false if it is
|
||||
//!unsuccessful
|
||||
inline bool stwcxu(volatile boost::uint32_t* mem, boost::uint32_t val)
|
||||
{
|
||||
return (__stwcx(reinterpret_cast<volatile int*>(mem), static_cast<int>(val)) != 0);
|
||||
}
|
||||
|
||||
//! "mem": pointer to the object
|
||||
//! "val": amount to add
|
||||
//! Returns the old value pointed to by mem
|
||||
inline boost::uint32_t atomic_add32
|
||||
(volatile boost::uint32_t *mem, boost::uint32_t val)
|
||||
{
|
||||
boost::uint32_t oldValue;
|
||||
do
|
||||
{
|
||||
oldValue = lwarxu(mem);
|
||||
}while (!stwcxu(mem, oldValue+val));
|
||||
return oldValue;
|
||||
}
|
||||
//! "mem": pointer to the object
|
||||
//! "val": amount to add
|
||||
//! Returns the old value pointed to by mem
|
||||
inline boost::uint32_t atomic_add32
|
||||
(volatile boost::uint32_t *mem, boost::uint32_t val)
|
||||
{
|
||||
boost::uint32_t oldValue;
|
||||
do
|
||||
{
|
||||
oldValue = lwarxu(mem);
|
||||
}while (!stwcxu(mem, oldValue+val));
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
//! Atomically increment an apr_uint32_t by 1
|
||||
//! "mem": pointer to the object
|
||||
//! Returns the old value pointed to by mem
|
||||
inline boost::uint32_t atomic_inc32(volatile boost::uint32_t *mem)
|
||||
{ return atomic_add32(mem, 1); }
|
||||
//! Atomically increment an apr_uint32_t by 1
|
||||
//! "mem": pointer to the object
|
||||
//! Returns the old value pointed to by mem
|
||||
inline boost::uint32_t atomic_inc32(volatile boost::uint32_t *mem)
|
||||
{ return atomic_add32(mem, 1); }
|
||||
|
||||
//! Atomically decrement an boost::uint32_t by 1
|
||||
//! "mem": pointer to the atomic value
|
||||
//! Returns the old value pointed to by mem
|
||||
inline boost::uint32_t atomic_dec32(volatile boost::uint32_t *mem)
|
||||
{ return atomic_add32(mem, (boost::uint32_t)-1); }
|
||||
//! Atomically decrement an boost::uint32_t by 1
|
||||
//! "mem": pointer to the atomic value
|
||||
//! Returns the old value pointed to by mem
|
||||
inline boost::uint32_t atomic_dec32(volatile boost::uint32_t *mem)
|
||||
{ return atomic_add32(mem, (boost::uint32_t)-1); }
|
||||
|
||||
//! Atomically read an boost::uint32_t from memory
|
||||
inline boost::uint32_t atomic_read32(volatile boost::uint32_t *mem)
|
||||
{ return *mem; }
|
||||
//! Atomically read an boost::uint32_t from memory
|
||||
inline boost::uint32_t atomic_read32(volatile boost::uint32_t *mem)
|
||||
{ return *mem; }
|
||||
|
||||
//! Compare an boost::uint32_t's value with "cmp".
|
||||
//! If they are the same swap the value with "with"
|
||||
//! "mem": pointer to the value
|
||||
//! "with" what to swap it with
|
||||
//! "cmp": the value to compare it to
|
||||
//! Returns the old value of *mem
|
||||
inline boost::uint32_t atomic_cas32
|
||||
(volatile boost::uint32_t *mem, boost::uint32_t with, boost::uint32_t cmp)
|
||||
{
|
||||
boost::uint32_t oldValue;
|
||||
boost::uint32_t valueToStore;
|
||||
do
|
||||
{
|
||||
oldValue = lwarxu(mem);
|
||||
} while (!stwcxu(mem, (oldValue == with) ? cmp : oldValue));
|
||||
//! Compare an boost::uint32_t's value with "cmp".
|
||||
//! If they are the same swap the value with "with"
|
||||
//! "mem": pointer to the value
|
||||
//! "with" what to swap it with
|
||||
//! "cmp": the value to compare it to
|
||||
//! Returns the old value of *mem
|
||||
inline boost::uint32_t atomic_cas32
|
||||
(volatile boost::uint32_t *mem, boost::uint32_t with, boost::uint32_t cmp)
|
||||
{
|
||||
boost::uint32_t oldValue;
|
||||
boost::uint32_t valueToStore;
|
||||
do
|
||||
{
|
||||
oldValue = lwarxu(mem);
|
||||
} while (!stwcxu(mem, (oldValue == with) ? cmp : oldValue));
|
||||
|
||||
return oldValue;
|
||||
}
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
//! Atomically set an boost::uint32_t in memory
|
||||
//! "mem": pointer to the object
|
||||
//! "param": val value that the object will assume
|
||||
inline void atomic_write32(volatile boost::uint32_t *mem, boost::uint32_t val)
|
||||
{ *mem = val; }
|
||||
//! Atomically set an boost::uint32_t in memory
|
||||
//! "mem": pointer to the object
|
||||
//! "param": val value that the object will assume
|
||||
inline void atomic_write32(volatile boost::uint32_t *mem, boost::uint32_t val)
|
||||
{ *mem = val; }
|
||||
|
||||
} //namespace ipcdetail
|
||||
} //namespace interprocess
|
||||
} //namespace ipcdetail
|
||||
} //namespace interprocess
|
||||
} //namespace boost
|
||||
|
||||
#elif defined(__GNUC__) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 401 )
|
||||
@@ -552,9 +552,9 @@ inline bool atomic_add_unless32
|
||||
return c != unless_this;
|
||||
}
|
||||
|
||||
} //namespace ipcdetail
|
||||
} //namespace interprocess
|
||||
} //namespace boost
|
||||
} //namespace ipcdetail
|
||||
} //namespace interprocess
|
||||
} //namespace boost
|
||||
|
||||
|
||||
#include <boost/interprocess/detail/config_end.hpp>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
@@ -60,10 +60,10 @@ class file_wrapper
|
||||
//!After the call, "moved" does not represent any file.
|
||||
//!Does not throw
|
||||
file_wrapper &operator=(BOOST_RV_REF(file_wrapper) moved)
|
||||
{
|
||||
{
|
||||
file_wrapper tmp(boost::move(moved));
|
||||
this->swap(tmp);
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//!Swaps to file_wrappers.
|
||||
@@ -73,7 +73,7 @@ class file_wrapper
|
||||
//!Erases a file from the system.
|
||||
//!Returns false on error. Never throws
|
||||
static bool remove(const char *name);
|
||||
|
||||
|
||||
//!Sets the size of the file
|
||||
void truncate(offset_t length);
|
||||
|
||||
@@ -122,10 +122,10 @@ inline bool file_wrapper::get_size(offset_t &size) const
|
||||
{ return get_file_size((file_handle_t)m_handle, size); }
|
||||
|
||||
inline void file_wrapper::swap(file_wrapper &other)
|
||||
{
|
||||
{
|
||||
std::swap(m_handle, other.m_handle);
|
||||
std::swap(m_mode, other.m_mode);
|
||||
m_filename.swap(other.m_filename);
|
||||
m_filename.swap(other.m_filename);
|
||||
}
|
||||
|
||||
inline mapping_handle_t file_wrapper::get_mapping_handle() const
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2009-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2009-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2009-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2009-2012. 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)
|
||||
//
|
||||
@@ -199,7 +199,7 @@ class intermodule_singleton_common
|
||||
private:
|
||||
static ThreadSafeGlobalMap &get_map()
|
||||
{
|
||||
return *static_cast<ThreadSafeGlobalMap *>(static_cast<void *>(&mem_holder.map_mem));
|
||||
return *static_cast<ThreadSafeGlobalMap *>(static_cast<void *>(&mem_holder.map_mem[0]));
|
||||
}
|
||||
|
||||
static void initialize_global_map_handle()
|
||||
@@ -274,7 +274,7 @@ class intermodule_singleton_common
|
||||
//Values: Uninitialized, Initializing, Initialized, Broken
|
||||
static volatile boost::uint32_t this_module_map_initialized;
|
||||
|
||||
//Raw memory to construct the global map manager
|
||||
//Raw memory to construct the global map manager
|
||||
static struct mem_holder_t
|
||||
{
|
||||
::boost::detail::max_align aligner;
|
||||
@@ -411,7 +411,7 @@ class intermodule_singleton_impl
|
||||
atomic_inc32(&rcount->singleton_ref_count);
|
||||
ret_ptr = rcount->ptr;
|
||||
}
|
||||
void *data() const
|
||||
void *data() const
|
||||
{ return ret_ptr; }
|
||||
|
||||
private:
|
||||
@@ -448,7 +448,7 @@ class intermodule_singleton_impl
|
||||
}
|
||||
void *data() const
|
||||
{ return ret_ptr; }
|
||||
|
||||
|
||||
private:
|
||||
ThreadSafeGlobalMap &m_map;
|
||||
void *ret_ptr;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2007-2012. 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)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
@@ -177,7 +177,7 @@ struct intersegment_base
|
||||
|
||||
void set_mode(std::size_t mode)
|
||||
{
|
||||
BOOST_ASSERT(mode < is_max_mode);
|
||||
BOOST_ASSERT(mode < is_max_mode);
|
||||
members.direct.ctrl = mode;
|
||||
}
|
||||
|
||||
@@ -309,13 +309,13 @@ struct flat_map_intersegment
|
||||
void *ptr_base;
|
||||
void *this_base;
|
||||
get_segment_info_and_offset(this, this_info, this_offset, this_base);
|
||||
|
||||
|
||||
if(!this_info.group){
|
||||
this->set_mode(is_in_stack);
|
||||
this->members.direct.addr = const_cast<void*>(ptr);
|
||||
}
|
||||
else{
|
||||
get_segment_info_and_offset(ptr, ptr_info, ptr_offset, ptr_base);
|
||||
get_segment_info_and_offset(ptr, ptr_info, ptr_offset, ptr_base);
|
||||
|
||||
if(ptr_info.group != this_info.group){
|
||||
this->set_mode(is_pointee_outside);
|
||||
@@ -383,7 +383,7 @@ struct flat_map_intersegment
|
||||
};
|
||||
vector<segment_data> m_segments;
|
||||
multi_segment_services &m_ms_services;
|
||||
|
||||
|
||||
public:
|
||||
segment_group_t(multi_segment_services &ms_services)
|
||||
: m_ms_services(ms_services)
|
||||
@@ -445,7 +445,7 @@ struct flat_map_intersegment
|
||||
typedef Mutex mutex_type;
|
||||
//!Maps base addresses and segment information
|
||||
//!(size and segment group and id)*
|
||||
|
||||
|
||||
ptr_to_segment_info_t m_ptr_to_segment_info;
|
||||
|
||||
~mappings_t()
|
||||
@@ -486,7 +486,7 @@ struct flat_map_intersegment
|
||||
--it;
|
||||
char * segment_base = const_cast<char*>(reinterpret_cast<const char*>(it->first));
|
||||
std::size_t segment_size = it->second.size;
|
||||
|
||||
|
||||
if(segment_base <= reinterpret_cast<const char*>(ptr) &&
|
||||
(segment_base + segment_size) >= reinterpret_cast<const char*>(ptr)){
|
||||
segment = it->second;
|
||||
@@ -552,7 +552,7 @@ struct flat_map_intersegment
|
||||
s_groups.insert(segment_group_t(*services));
|
||||
BOOST_ASSERT(ret.second);
|
||||
return &*ret.first;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool delete_group(segment_group_id id)
|
||||
@@ -574,7 +574,7 @@ struct flat_map_intersegment
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -663,17 +663,17 @@ class intersegment_ptr : public flat_map_intersegment<interprocess_mutex>
|
||||
|
||||
//!Pointer-like -> operator. It can return 0 pointer.
|
||||
//!Never throws.
|
||||
pointer operator->() const
|
||||
pointer operator->() const
|
||||
{ return self_t::get(); }
|
||||
|
||||
//!Dereferencing operator, if it is a null intersegment_ptr behavior
|
||||
//!is undefined. Never throws.
|
||||
reference operator* () const
|
||||
reference operator* () const
|
||||
{ return *(self_t::get()); }
|
||||
|
||||
//!Indexing operator.
|
||||
//!Never throws.
|
||||
reference operator[](std::ptrdiff_t idx) const
|
||||
reference operator[](std::ptrdiff_t idx) const
|
||||
{ return self_t::get()[idx]; }
|
||||
|
||||
//!Assignment from pointer (saves extra conversion).
|
||||
@@ -690,15 +690,15 @@ class intersegment_ptr : public flat_map_intersegment<interprocess_mutex>
|
||||
//!are assignable, intersegment_ptrs will be assignable. Never throws.
|
||||
template <class T2>
|
||||
intersegment_ptr& operator= (const intersegment_ptr<T2> & ptr)
|
||||
{
|
||||
{
|
||||
pointer p(ptr.get()); (void)p;
|
||||
base_t::set_from_other(ptr); return *this;
|
||||
base_t::set_from_other(ptr); return *this;
|
||||
}
|
||||
|
||||
//!intersegment_ptr + std::ptrdiff_t.
|
||||
//!Never throws.
|
||||
intersegment_ptr operator+ (std::ptrdiff_t idx) const
|
||||
{
|
||||
intersegment_ptr operator+ (std::ptrdiff_t idx) const
|
||||
{
|
||||
intersegment_ptr result (*this);
|
||||
result.inc_offset(idx*sizeof(T));
|
||||
return result;
|
||||
@@ -706,8 +706,8 @@ class intersegment_ptr : public flat_map_intersegment<interprocess_mutex>
|
||||
|
||||
//!intersegment_ptr - std::ptrdiff_t.
|
||||
//!Never throws.
|
||||
intersegment_ptr operator- (std::ptrdiff_t idx) const
|
||||
{
|
||||
intersegment_ptr operator- (std::ptrdiff_t idx) const
|
||||
{
|
||||
intersegment_ptr result (*this);
|
||||
result.dec_offset(idx*sizeof(T));
|
||||
return result;
|
||||
@@ -745,7 +745,7 @@ class intersegment_ptr : public flat_map_intersegment<interprocess_mutex>
|
||||
|
||||
//!Safe bool conversion operator.
|
||||
//!Never throws.
|
||||
operator unspecified_bool_type() const
|
||||
operator unspecified_bool_type() const
|
||||
{ return base_t::is_null()? 0 : &self_t::unspecified_bool_type_func; }
|
||||
|
||||
//!Not operator. Not needed in theory, but improves portability.
|
||||
@@ -784,12 +784,12 @@ class intersegment_ptr : public flat_map_intersegment<interprocess_mutex>
|
||||
template <class T1, class T2> inline
|
||||
bool operator ==(const intersegment_ptr<T1> &left,
|
||||
const intersegment_ptr<T2> &right)
|
||||
{
|
||||
{
|
||||
//Make sure both pointers can be compared
|
||||
bool e = typename intersegment_ptr<T1>::pointer(0) ==
|
||||
typename intersegment_ptr<T2>::pointer(0);
|
||||
(void)e;
|
||||
return left._equal(right);
|
||||
return left._equal(right);
|
||||
}
|
||||
|
||||
//!Returns true if *this is less than other.
|
||||
@@ -798,12 +798,12 @@ bool operator ==(const intersegment_ptr<T1> &left,
|
||||
template <class T1, class T2> inline
|
||||
bool operator <(const intersegment_ptr<T1> &left,
|
||||
const intersegment_ptr<T2> &right)
|
||||
{
|
||||
{
|
||||
//Make sure both pointers can be compared
|
||||
bool e = typename intersegment_ptr<T1>::pointer(0) <
|
||||
typename intersegment_ptr<T2>::pointer(0);
|
||||
(void)e;
|
||||
return left._less(right);
|
||||
return left._less(right);
|
||||
}
|
||||
|
||||
template<class T1, class T2> inline
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
@@ -172,14 +172,14 @@ class basic_managed_memory_impl
|
||||
//This function should not throw. The index construction can
|
||||
//throw if constructor allocates memory. So we must catch it.
|
||||
BOOST_TRY{
|
||||
//Let's construct the allocator in memory
|
||||
//Let's construct the allocator in memory
|
||||
mp_header = new(addr) segment_manager(size);
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
return false;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
//!Connects to a segment manager in the reserved buffer. Never throws.
|
||||
@@ -192,7 +192,7 @@ class basic_managed_memory_impl
|
||||
|
||||
//!Frees resources. Never throws.
|
||||
bool close_impl()
|
||||
{
|
||||
{
|
||||
bool ret = mp_header != 0;
|
||||
mp_header = 0;
|
||||
return ret;
|
||||
@@ -254,12 +254,12 @@ class basic_managed_memory_impl
|
||||
handle_t get_handle_from_address (const void *ptr) const
|
||||
{
|
||||
return (handle_t)(reinterpret_cast<const char*>(ptr) -
|
||||
reinterpret_cast<const char*>(this->get_address()));
|
||||
reinterpret_cast<const char*>(this->get_address()));
|
||||
}
|
||||
|
||||
//!Returns true if the address belongs to the managed memory segment
|
||||
bool belongs_to_segment (const void *ptr) const
|
||||
{
|
||||
{
|
||||
return ptr >= this->get_address() &&
|
||||
ptr < (reinterpret_cast<const char*>(this->get_address()) + this->get_size());
|
||||
}
|
||||
@@ -292,7 +292,7 @@ class basic_managed_memory_impl
|
||||
allocation_command (boost::interprocess::allocation_type command, size_type limit_size,
|
||||
size_type preferred_size,size_type &received_size,
|
||||
T *reuse_ptr = 0)
|
||||
{
|
||||
{
|
||||
return mp_header->allocation_command
|
||||
(command, limit_size, preferred_size, received_size, reuse_ptr);
|
||||
}
|
||||
@@ -724,7 +724,7 @@ class create_open_func
|
||||
: m_frontend(frontend), m_type(type){}
|
||||
|
||||
bool operator()(void *addr, typename BasicManagedMemoryImpl::size_type size, bool created) const
|
||||
{
|
||||
{
|
||||
if(((m_type == DoOpen) && created) ||
|
||||
((m_type == DoCreate) && !created))
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012. 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)
|
||||
//
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <boost/assert.hpp>
|
||||
//These includes needed to fulfill default template parameters of
|
||||
//predeclarations in interprocess_fwd.hpp
|
||||
#include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
|
||||
#include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
|
||||
#include <boost/interprocess/sync/mutex_family.hpp>
|
||||
|
||||
//!\file
|
||||
@@ -69,7 +69,7 @@ class basic_managed_multi_shared_memory
|
||||
<CharType, MemoryAlgorithm, IndexType> self_t;
|
||||
typedef ipcdetail::basic_managed_memory_impl
|
||||
<CharType, MemoryAlgorithm, IndexType> base_t;
|
||||
|
||||
|
||||
typedef typename MemoryAlgorithm::void_pointer void_pointer;
|
||||
typedef typename ipcdetail::
|
||||
managed_open_or_create_impl<shared_memory_object, MemoryAlgorithm::Alignment> managed_impl;
|
||||
@@ -100,7 +100,7 @@ class basic_managed_multi_shared_memory
|
||||
// if(!m_shmem.create(m_mem_name, size, m_addr))
|
||||
// return 0;
|
||||
// return m_shmem.get_address();
|
||||
// }
|
||||
// }
|
||||
// private:
|
||||
// shared_memory &m_shmem;
|
||||
// const char *m_mem_name;
|
||||
@@ -134,7 +134,7 @@ class basic_managed_multi_shared_memory
|
||||
typename shmem_list_t::value_type &m_impl = *mp_frontend->m_shmem_list.rbegin();
|
||||
return result_type(m_impl.get_real_address(), m_impl.get_real_size()-1);
|
||||
}*/
|
||||
return result_type(static_cast<void *>(0), 0);
|
||||
return result_type(static_cast<void *>(0), 0);
|
||||
}
|
||||
|
||||
virtual bool update_segments ()
|
||||
@@ -174,7 +174,7 @@ class basic_managed_multi_shared_memory
|
||||
: mp_frontend(frontend), m_type(type), m_segment_number(segment_number){}
|
||||
|
||||
bool operator()(void *addr, size_type size, bool created) const
|
||||
{
|
||||
{
|
||||
if(((m_type == DoOpen) && created) ||
|
||||
((m_type == DoCreate) && !created))
|
||||
return false;
|
||||
@@ -226,7 +226,7 @@ class basic_managed_multi_shared_memory
|
||||
: mp_frontend(frontend){}
|
||||
|
||||
void operator()(const mapped_region ®ion, bool last) const
|
||||
{
|
||||
{
|
||||
if(last) mp_frontend->destroy_impl();
|
||||
else mp_frontend->close_impl();
|
||||
}
|
||||
@@ -251,7 +251,7 @@ class basic_managed_multi_shared_memory
|
||||
const permissions &perm = permissions())
|
||||
: m_group_services(get_this_pointer())
|
||||
{
|
||||
priv_open_or_create(create_open_func::DoCreate,name, size, perm);
|
||||
priv_open_or_create(create_open_func::DoCreate,name, size, perm);
|
||||
}
|
||||
|
||||
basic_managed_multi_shared_memory(open_or_create_t,
|
||||
@@ -301,7 +301,7 @@ class basic_managed_multi_shared_memory
|
||||
if(group){
|
||||
void_pointer::delete_group(group);
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool priv_new_segment(typename create_open_func::type_t type,
|
||||
@@ -368,7 +368,7 @@ class basic_managed_multi_shared_memory
|
||||
|
||||
//!Frees resources. Never throws.
|
||||
void priv_close()
|
||||
{
|
||||
{
|
||||
if(!m_shmem_list.empty()){
|
||||
bool ret;
|
||||
//Obtain group identifier
|
||||
@@ -385,7 +385,7 @@ class basic_managed_multi_shared_memory
|
||||
m_shmem_list.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
shmem_list_t m_shmem_list;
|
||||
group_services m_group_services;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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)
|
||||
//
|
||||
@@ -48,12 +48,12 @@ class xsi_key;
|
||||
|
||||
template<>
|
||||
struct managed_open_or_create_impl_device_id_t<xsi_shared_memory_file_wrapper>
|
||||
{
|
||||
{
|
||||
typedef xsi_key type;
|
||||
};
|
||||
|
||||
#endif //BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS
|
||||
|
||||
|
||||
/// @endcond
|
||||
|
||||
namespace ipcdetail {
|
||||
@@ -79,7 +79,7 @@ class managed_open_or_create_impl_device_holder<true, DeviceAbstraction>
|
||||
|
||||
const DeviceAbstraction &get_device() const
|
||||
{ return dev; }
|
||||
|
||||
|
||||
private:
|
||||
DeviceAbstraction dev;
|
||||
};
|
||||
@@ -94,9 +94,9 @@ class managed_open_or_create_impl
|
||||
typedef typename managed_open_or_create_impl_device_id_t<DeviceAbstraction>::type device_id_t;
|
||||
typedef managed_open_or_create_impl_device_holder<StoreDevice, DeviceAbstraction> DevHolder;
|
||||
enum
|
||||
{
|
||||
UninitializedSegment,
|
||||
InitializingSegment,
|
||||
{
|
||||
UninitializedSegment,
|
||||
InitializingSegment,
|
||||
InitializedSegment,
|
||||
CorruptedSegment
|
||||
};
|
||||
@@ -222,10 +222,10 @@ class managed_open_or_create_impl
|
||||
{ this->swap(moved); }
|
||||
|
||||
managed_open_or_create_impl &operator=(BOOST_RV_REF(managed_open_or_create_impl) moved)
|
||||
{
|
||||
{
|
||||
managed_open_or_create_impl tmp(boost::move(moved));
|
||||
this->swap(tmp);
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
~managed_open_or_create_impl()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Stephen Cleary 2000.
|
||||
// (C) Copyright Ion Gaztanaga 2007-2011.
|
||||
// (C) Copyright Ion Gaztanaga 2007-2012.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -93,7 +93,7 @@ inline std::size_t floor_log2 (std::size_t x)
|
||||
|
||||
std::size_t n = x;
|
||||
std::size_t log2 = 0;
|
||||
|
||||
|
||||
for(std::size_t shift = Bits >> 1; shift; shift >>= 1){
|
||||
std::size_t tmp = n >> shift;
|
||||
if (tmp)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2011.
|
||||
// (C) Copyright Ion Gaztanaga 2005-2012.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user