single object across processes

C

curious_one

Hi,
Is there a way to access a single instance of an object(singleton
class) across different processes ?
thanks
curious.one
 
G

Gianni Mariani

curious_one said:
Hi,
Is there a way to access a single instance of an object(singleton
class) across different processes ?
thanks
curious.one

cross posting to 4 groups is going to annoy some people.

comp.lang.c++ answer : c++ has no knowledge of process. What your
question got to do with the c++ language ?

comp.unix.internals : what's an object ? what's a singleton ?

comp.unix.programmer : no answer

comp.unix.solaris : java has JVM's and you can't do anything a JVM can't
do !


So the true answer to your question is that if you want to share a
singleton you need to allocate it in shared memory. Now you run into
problems of address mapping. The object may be in a different address
in different processes. Not only that, any virtual methods almost
certainly will cause trouble since they won't be mapped to the same
addresses either (if they exist at all).


So far, your singleton is very limited in ability.

So, if you're still interested because this is really what you need,
then you may get some help from some mutex library.

So there are some C++ template classes that could help (like a
relocating smart pointer that relocates addresses dynamically) and a few
others to deal with finding the right methods in a process.

More than this is hard to specuate ...


G
 
V

vijay

COM helps u do that , I use it for different reason , but for almost a
similar purpose,
A single instance of a server can cater to different processes across
different machines, I programmed on Windows
But COM is a specification, So it should be present on UNIX also,
Vijay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top