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

Breadcrumb

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

class DelayedStalenessHandler

@internal

Hierarchy

  • class \OpenTelemetry\SDK\Metrics\StalenessHandler\DelayedStalenessHandler implements \OpenTelemetry\SDK\Metrics\StalenessHandlerInterface, \OpenTelemetry\SDK\Metrics\ReferenceCounterInterface

Expanded class hierarchy of DelayedStalenessHandler

File

vendor/open-telemetry/sdk/Metrics/StalenessHandler/DelayedStalenessHandler.php, line 15

Namespace

OpenTelemetry\SDK\Metrics\StalenessHandler
View source
final class DelayedStalenessHandler implements StalenessHandlerInterface, ReferenceCounterInterface {
    
    /** @var Closure[]|null */
    private ?array $onStale = [];
    private int $count = 0;
    public function __construct(Closure $stale, Closure $freshen) {
    }
    public function acquire(bool $persistent = false) : void {
        if ($this->count === 0) {
            ($this->freshen)($this);
        }
        $this->count++;
        if ($persistent) {
            $this->onStale = null;
        }
    }
    public function release() : void {
        if (--$this->count || $this->onStale === null) {
            return;
        }
        ($this->stale)($this);
    }
    public function onStale(Closure $callback) : void {
        if ($this->onStale === null) {
            return;
        }
        $this->onStale[] = $callback;
    }
    public function triggerStale() : void {
        assert($this->onStale !== null);
        $callbacks = $this->onStale;
        $this->onStale = [];
        foreach ($callbacks as $callback) {
            $callback();
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
DelayedStalenessHandler::$count private property
DelayedStalenessHandler::$onStale private property @var Closure[]|null
DelayedStalenessHandler::acquire public function Overrides ReferenceCounterInterface::acquire
DelayedStalenessHandler::onStale public function Overrides StalenessHandlerInterface::onStale
DelayedStalenessHandler::release public function Overrides ReferenceCounterInterface::release
DelayedStalenessHandler::triggerStale public function
DelayedStalenessHandler::__construct public function

API Navigation

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