p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

comdeveloper thread: AW: AW: general COM-question

Message #1 by Holger Thiele <HThiele@D...> on Wed, 21 Feb 2001 18:08:09 +0100
Hi Jurgen,

no, i don't know anything about the OPOS standard,

but i understand that you have some coding standard to follow here.

If this standard imposes using in-proc servers and you want to

restrict resource access across processes then you will have to use

some shared memory/shared (i.e. named) synchronization object


A singleton object in COM parlance is, as so often, really a misnomer.

It means that you have a special class factory that owns exactly

one object instance that is shared among all clients.

If the COM server is implemented as a dll, then this will give

you one shared object PER PROCESS. If you want the same object

shared across processes, the server has to be out-of-proc.

In ATL, this class factory is generated using the 


As explained in an article by Don Box in the October 1998 issue of MSJ,

you should "Beware the COM singleton".

One problem this article doesn't mention (if my memory serves me right),

is the fact that an object that gets exposed as a singleton must be

threadsafe no matter what the COM apartment declaration says.

Another excellent resource is "Professional ATL COM Programming" by

Richard Grimes.



  Return to Index