Commit 7b1e7138 authored by A. Unique TensorFlower's avatar A. Unique TensorFlower Committed by TensorFlower Gardener
Browse files

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
parent 717ac62e
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment