Object-InsideOut - Re: InsideOut Singleton?

Posted on Wed Jan 25 19:18:57 2006 by jdhedden in response to 1705 (See the whole thread of 7)
Re: InsideOut Singleton?
What happens if the constructor takes a while to create the singleton (big database query for example), and a second process calls the new() method while the first one is still being run?

That can only happen if you're using threads. In that case, you need to use the proper controls supplied by the threads module.

As to Class::Singleton, it offers no advantages over the sample code I suggested (and using it requires Perl to load and parse two additional modules, namely 'base' and 'Class::Singleton'). It has a minor downside in that it stores the singleton object in a global variable ($MyClass::_instance).
Write a response