This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc 3.x custom allocators


On Fri, Jan 10, 2003 at 12:12:54PM -0600, Benjamin Kosnik wrote:
 
> I've enclosed some weak example code, based on the custom allocators a
> la the pool allocator in TCPL 19.4.2 A User-Defined Allocator.
 
  I don't see an attachement. :-)

> I don't suppose you can post a full example of what you are trying to
> do, one that works with 2.95.3? Then I could try to port it for you.
 
  I attached the 2 files that implement the code I'm using now with
2.95.3 (on Linux), plus a DejaGnu test case that exercises the Memory
class. This code is *way ugly*, as it was a "proof-of-concept" for a
customer last year, who now has me making this work for real. I made my
changes in existing 10 year old code...  Part of this is I've now ripped
out all the ugly semaphore code, and made it into a standalone class. I'm also
changing to using POSIX shared memory from the older SVR4 style. There
are two similar allocators in the header file. One is for the containers
used in the memory manager, and the other is for the application itself.

> It would be really nice to have a complete, usable example in the
> libstdc++ docs for this. It would be really, really nice to have docs
> for custom allocators that used: 1) libhoard, 2) persistent allocation,
> 3) shared segments like you are trying to do.

  For sure. Putting data structures in shared memory is a pretty common
real-time application trick. This was the first time I'd done this 100% in
C++ though. I use this code to create a std::list in the shared memory that's
a queue of messages between 2 tasks. What's libhoard ?

  The ultimate solution would work with both GCC 3 and 2, but I can live with
ifdefs. I've found tons of examples, it's just that they all only work
with libstdc++-v2.

	- rob -

Attachment: TCXXMem.C
Description: Text document

Attachment: Memory.H
Description: Text document

Attachment: Memory.C
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]