I come from the C++ world.
And recently, I started using Apache Thrift, the RPC framework. I am writing PHP client code and Python server code.
When I am reading the PHP implementation, I find the following:
class TStringFuncFactory {
private static $_instance;
/**
* Get the Singleton instance of TStringFunc implementation that is
* compatible with the current system's mbstring.func_overload settings.
*
* @return TStringFunc
*/
public static function create() {
if(!self::$_instance) {
self::_setInstance();
}
return self::$_instance;
}
....
}
It is the singleton WITHOUT locks.
Question
What is the processing pattern of PHP? Does it guarantee that this won't happen risk condition.