in reply to what is the real scope of a singleton

Yes. A Singleton lives the life of your application. If you want it to live longer you would need to serialize it -- as well as provide an interface that serializes the object when apps that use it are closed as well as an interface that de-serializes and re-instantiates (?) it into RAM whenever it is requested. What a horrible mess that will be. :) I can't think of a reason why I would a Singleton that lives past the life on an app, but if it can be done then surely it solves some problem*.

*I think this is a stretch -- but in some ways the session attached to a user in a web app might qualify as such a singleton ... sort of.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
  • Comment on Re: what is the real scope of a singleton

Replies are listed 'Best First'.
Re^2: what is the real scope of a singleton
by leocharre (Priest) on Dec 23, 2008 at 15:36 UTC

    Yea, I guess.. serialize it.. maybe seek memory somehow- for a live instance of this- how to go about it is way beyond me.

    I think simply using cache in this case- there is no way you could keep various instances in sync without molesting the system resources. We're not talking about storing some value of some expensive operation to a timeframe resolution- but .. an instant kind of .. storage.
    I guess this is more an ipc thing.

    Dunno, daemonizing or using some witchy pipe or some other posix conjuration.

    But yea- as the original post- I don't think this kind of behaviour is something you would want to have happen without being fully aware of what's up- every process on the system accessing the same chunk of memory space- very insteresting though.

    Thanks for clarifying, you rock.