Thrift php singleton without locks?

I come from the world of C ++.

And recently, I started using Apache Thrift, an RPC infrastructure. I am writing client PHP code and Python server code.

When I read 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 mbstring.func_overload settings.
 *
 * @return TStringFunc
 */
public static function create() {
    if(!self::$_instance) {
        self::_setInstance();
    }

    return self::$_instance;
}
....
}

These are single WITHOUT locks.

Question

What is a PHP processing template? Does this guarantee that it will not have a risk condition.

+4
source share
1 answer

+1 @NB

PHP (cli or http) exists as a single thread on a single cpu core, unless you are doing some real work to make your application multithreaded.

How to use multithreading in PHP applications

HTTP PHP . , PHP, .

, . .

+1

All Articles