|
Boost Users : |
Subject: [Boost-users] [Interprocess] Named objects with 'Managed External Buffer' (newbie)
From: Jorge Bellon (jbellon_at_[hidden])
Date: 2014-04-25 11:13:06
Good afternoon,
First, I apologize if I'm asking something obvious or outside the acceptable topics. I'm starting to
use Boost so I'm quite newbie.
I'm interested in using the managed_external_buffer in order to perform buffer copies into a
created buffer that was created previously. Therefore, I will be storing mostly raw data into that
buffer.
Basically, I'm trying to do the following:
Suppose a program uses the following int array:
int numbers[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
Eventually, I have to copy a chunk of that array into a pre-allocated buffer (i.e. the
managed_external_buffer). Let the chunk be defined with:
typedef struct {
void* addr;
size_t size;
} chunk_t;
However, these chunks can overlap, so I will sometimes merge two overlapping chunks into a
bigger one. Example:
// Chunk 1
chunk1_addr = (void*)&numbers[3];
chunk1_size = 3 * sizeof(int);
// Chunk 2
chunk2_addr = (void*) &numbers[4];
chunk2_size = 4 * sizeof(int);
The desired result is a single chunk containing {3, 4, 5, 6, 7}.
The proposed problem is the merge, but how to find those chunks in the managed_external_buffer,
so my question is the following:
- Would it be possible to use named objects with another data type other than CharType and use
managed_external_buffer::find to look for them? The thing is I could generate a hash or a numerical
ID to identify the chunk. Generating a string using that number could be done but it would not be
efficient.
Otherwise, I guess I would have to keep a map (or other collection) with the <chunk ID, chunk
pointer> pairs, define the managed_external_buffer with boost::interprocess::null_index (since I
won't be using named objects) and use it through allocate and deallocate. Is this correct?
Thanks in advance,
Jorge
WARNING / LEGAL TEXT: This message is intended only for the use of the
individual or entity to which it is addressed and may contain
information which is privileged, confidential, proprietary, or exempt
from disclosure under applicable law. If you are not the intended
recipient or the person responsible for delivering the message to the
intended recipient, you are strictly prohibited from disclosing,
distributing, copying, or in any way using this message. If you have
received this communication in error, please notify the sender and
destroy and delete any copies you may have received.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net