This article is intended to extend the idea of Inter Process Communication
with a Memory Mapped File object by using a class that handles that memory
object (or any memory) as a memory pool, a “heap”. This class,
CAllocationHandler, creates a layout of that memory consisting of a header,
an allocation table, and a memory area where the allocated memory blocks
resides. Those memory blocks may be moved by the class
during the allocation/deallocation calls, so the memory blocks are mainly
handled using “memory handles”.
To directly access a memory block, it must be locked through this handle.
The memory handle can also be transferred between processes that uses the
same Memory Mapped File object and used to access the data.
The archive AllocationHandler_src contains the class files
and the article (a plain text file)
The archive AllocationHandler_demo contains a simple Console application
that demonstrates the use of CAllocationHandler by simulating two producer
threads of data allocated on the “heap”, then saving the
memory handles in a CList that is periodically checked by a consumer thread.