Improve thread-safety of ProcessState::singleton() and
GPUProcessState::singleton().
One might wish to subclass GPUProcessState in order to override some of
its methods using special knowledge about the platform in use.
Suppose the new class is called SubGPUProcessState. In such a case it
is necessary that all calls to SubGPUProcessState::singleton() and
GPUProcessState::singleton() return exactly the same pointer, to an
instance of SubGPUProcessState. To accomplish this there must be a
static var initializer that sets the singleton correctly prior to main
routine invocation. Here's an example program fragment:
SubGPUProcessState* global_initializer = ([]() {
SubGPUProcessState* ps = SubGPUProcessState::singleton();
return down_cast<SubGPUProcessState*>(GPUProcessState::singleton(ps));
})();
PiperOrigin-RevId: 222134183
Loading
Please sign in to comment