468,140 Members | 1,578 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,140 developers. It's quick & easy.

single object across processes

Hi,
Is there a way to access a single instance of an object(singleton
class) across different processes ?
thanks
curious.one
Jul 19 '05 #1
2 3692
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
Jul 19 '05 #2
curious_one wrote:
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

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Rob.J.White | last post: by
3 posts views Thread by Prabhu Shastry | last post: by
6 posts views Thread by Param R. | last post: by
3 posts views Thread by Amil Hanish | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.