singleton with "momento"
Frustrated
c1514843 at drdrb.com
Thu Jan 9 13:51:45 PST 2014
Lets suppose I have setup some code to use a singleton object.
Now lets suppose I want to duplicate that code(say to run
multiple times simultaneously).
The singleton pattern itself prevents multiple copies. One would
need multiple instances to be able to run multiple times BUT in
the context of each piece of code the object would be a singleton.
It seems one would need a singleton would allow in some cases to
not be a singleton. While I'm sure there are some ways around
this using a singleton directly I wonder if there is any modified
pattern to handle this situation?
Basically if one thought of having a signal universe with an
object in it that is a singleton, then decided to end up with
multiple universes. In this case there would be copies of the
singleton pattern but with regard to each universe they should
behave as expected... and each universe is completely separated
from all the others).
Anyone know how to easily deal with this?
In my code essentially I have a "universal context"(a singleton)
that contains some universal objects(singletons). The context is
just a container of all the important data that user code needs
quick access too.
I know at some point I'll need to have multiple independent
contexts to allow for some advanced processing. Hence I can't
have them as singletons but I do want some level of uniqueness(No
copies floating around in the universe).
(instead of having to save, change, then restore the context for
every context switch)
I'm thinking of something like singleton!(class, universe) where
universe is an id but I'm not sure if that is quite right.
More information about the Digitalmars-d-learn
mailing list