Greetings Fellow Monks,
I believe I have an interesting problem with the implementation of the Singleton design pattern.
Essentially I'm trying to keep a cache of meta-data read from MP3 files, within a fork()ing server.
To do this I create a singleton "cache object" within the parent, then modify the contents of it within the child process.
Unfortunately my changes to the singleton object in the child processes are not reflected within the parent - So unsure how to proceed, I was under the impression that the singleton reference would be valid for both.
This is my creation code:
my $oneTrueSelf; sub new { if($oneTrueSelf) { return $oneTrueSelf; } else { my $type = shift; my $this = {} $oneTrueSelf = bless $this, $type; return $this->new(); } }
Is there an obvious way to proceed? Or do I have to brave the scary shared memory magic?
SteveIn reply to The Singleton design pattern and fork(); by skx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |