Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FiberBoundContextStorageExecutionAwareBC.php

class FiberBoundContextStorageExecutionAwareBC

@internal

Hierarchy

  • class \OpenTelemetry\Context\FiberBoundContextStorageExecutionAwareBC implements \OpenTelemetry\Context\ContextStorageInterface, \OpenTelemetry\Context\ExecutionContextAwareInterface

Expanded class hierarchy of FiberBoundContextStorageExecutionAwareBC

File

vendor/open-telemetry/context/FiberBoundContextStorageExecutionAwareBC.php, line 10

Namespace

OpenTelemetry\Context
View source
final class FiberBoundContextStorageExecutionAwareBC implements ContextStorageInterface, ExecutionContextAwareInterface {
    private readonly FiberBoundContextStorage $storage;
    private ?ContextStorage $bc = null;
    public function __construct() {
        $this->storage = new FiberBoundContextStorage();
    }
    public function fork(int|string $id) : void {
        $this->bcStorage()
            ->fork($id);
    }
    public function switch(int|string $id) : void {
        $this->bcStorage()
            ->switch($id);
    }
    public function destroy(int|string $id) : void {
        $this->bcStorage()
            ->destroy($id);
    }
    private function bcStorage() : ContextStorage {
        if ($this->bc === null) {
            $this->bc = new ContextStorage();
            // Copy head into $this->bc storage to preserve already attached scopes
            
            /** @psalm-suppress PossiblyNullFunctionCall */
            $head = (static fn($storage) => $storage->heads[$storage])
                ->bindTo(null, FiberBoundContextStorage::class)($this->storage);
            $head->storage = $this->bc;
            
            /** @psalm-suppress PossiblyNullFunctionCall */
            (static fn($storage) => $storage->current = $storage->main = $head)
                ->bindTo(null, ContextStorage::class)($this->bc);
        }
        return $this->bc;
    }
    public function scope() : ?ContextStorageScopeInterface {
        return $this->bc ? $this->bc
            ->scope() : $this->storage
            ->scope();
    }
    public function current() : ContextInterface {
        return $this->bc ? $this->bc
            ->current() : $this->storage
            ->current();
    }
    public function attach(ContextInterface $context) : ContextStorageScopeInterface {
        return $this->bc ? $this->bc
            ->attach($context) : $this->storage
            ->attach($context);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
FiberBoundContextStorageExecutionAwareBC::$bc private property
FiberBoundContextStorageExecutionAwareBC::$storage private property
FiberBoundContextStorageExecutionAwareBC::attach public function Attaches the context as active context. Overrides ContextStorageInterface::attach
FiberBoundContextStorageExecutionAwareBC::bcStorage private function
FiberBoundContextStorageExecutionAwareBC::current public function Returns the current context. Overrides ContextStorageInterface::current
FiberBoundContextStorageExecutionAwareBC::destroy public function Overrides ExecutionContextAwareInterface::destroy
FiberBoundContextStorageExecutionAwareBC::fork public function Overrides ExecutionContextAwareInterface::fork
FiberBoundContextStorageExecutionAwareBC::scope public function Returns the current scope. Overrides ContextStorageInterface::scope
FiberBoundContextStorageExecutionAwareBC::switch public function Overrides ExecutionContextAwareInterface::switch
FiberBoundContextStorageExecutionAwareBC::__construct public function

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal