[shmem] Contribution

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[shmem] Contribution

Michael Kilburn
Hi

I am not active 'Boost' participant, but I keep an eye on this project and
check it's status from time to time. During last couple of years I was
involved in IPC and was naturally intrigued by the new boost library --  
Shared Memory Library. In documentation I have read that:

[------- start -------]
 To place STL-compatible containers in shared memory, Shmem allocators
define allocator<T>::pointer typedef as a relative pointer type, instead of
T*. Although the use of smart pointers is allowed by the standard, current
STL implementations can't handle Shmem shared memory STL compatible
allocators.
[------- end -------]

But in my recent project I actually created allocator for shared memory that
can be used in STL from MS VC7.1. Rejected two or three version of
allocator::pointer until it worked.  And I used it successfully: in my
project complex structures with maps, deques, vectors, pointers and even
smart pointers were created in shared memory. Only problem I have found --  
std::basic_string, it explicitly uses T* in union. I have used
limited_string or vector<char> instead of it.

If anybody interested -- just ask for more details, until then I'll
demonstrate simple example and allocator declaration:

[------- start example -------]
template<class MemModel = StdMemModel>
class RootObject : public MemModel::ObjectBase
{
public:
    typedef ProcessContext<MemModel> ProcessContext;
    typedef typename MemModel::rebind<ProcessContext>::Allocator::pointer
ProcessContextPtr;

//...

private:
    // process context map<ProcId, ProcessContextPtr>
    typedef std::map<DWORD, ProcessContextPtr, std::less<DWORD>,
        typename MemModel::rebind<std::pair<DWORD const, ProcessContextPtr>
 >::Allocator>
            ProcessMap;

    ProcessMap m_procMap;
};

// later in the code:
if (useShared)
{
    new RootObject <SharedModel>();
}
else
{
    new RootObject <>();
}

[------- end example -------]

I'll try to attach shared allocator declaration, hope that this newsgroup
allows this.

Bye.
Sincerely yours, Michael.


begin 666 heap.zip
M4$L#!!0````(`$-R7#0X,K$Y- <``- >```&````:&5A<"YHY5E;3]M(%'X&
MB?]PVDK("0&2JGT)D(KM4O4!"@O9OE25-=ACXJUO.YY LQ'[V_?,S3.V$Q):
MD"JMI2CQ^,PYWWSG,F><5W&4A32"CR?'%_Y'WQ\,_$'??]WOO_7]M_Z;@?^F
M[_L79UN;KU JSN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CV5QSM =7=D5@(F
M!]6G31,/<L@LY@>POG@BK*BYB38B2=F$J\8L^:M;RS4NZ<6K"6$T/,NQKL(N
M'D;DK?D#(Q7#U3\$CJA]0]3N6,5PK7^JO>5K-4/C$1R;&W.";W5\MIB"^A(#
M5FHQ" 5$'B0:W2#^>BU..55**:"(93BLP-@$*V0%%.J<E9B2S]F>.3,U7T \
M%ZYZV_9X=$]\AKF7;]L;?W[]LG]]7?'PC*9G]<AVQWXRLJ5+'QG>6NG\_E>+
M;D:E3(&WZE5<W=3(*U0;I@/K5PG[1\)6#C%_%V,TK_SW^3]02P$"% `4````
M" !#<EPT.#*Q.30'``#0'@``!@`````````!`"$`)($`````:&5A<"YH4$L%
3!@`````!``$`- ```%@'````````
`
end


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost