single object across processes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • curious_one

    single object across processes

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

    #2
    Re: single object across processes

    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


    Comment

    • Gianni Mariani

      #3
      Re: single object across processes

      curious_one wrote:[color=blue]
      > Hi,
      > Is there a way to access a single instance of an object(singleto n
      > class) across different processes ?
      > thanks
      > curious.one[/color]

      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.inter nals : what's an object ? what's a singleton ?

      comp.unix.progr ammer : no answer

      comp.unix.solar is : 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

      Comment

      Working...