class ConcurrencyManager extends MultipleInstanceManager mixin Driver

Traits

Properties

protected Repository $config

The configuration repository instance.

from  MultipleInstanceManager
protected array $instances

The array of resolved instances.

from  MultipleInstanceManager
protected array $customCreators

The registered custom instance creators.

from  MultipleInstanceManager
protected string $driverKey

The key name of the "driver" equivalent configuration option.

from  MultipleInstanceManager

Methods

Closure|null
bindCallbackToSelf(Closure $callback)

Bind the provided callback to the class instance.

__construct(Application $app)

Create a new manager instance.

string
getDefaultInstance()

Get the default instance name.

void
setDefaultInstance(string $name)

Set the default concurrency driver name.

array
getInstanceConfig(string $name)

Get the instance specific configuration.

mixed
instance(string|null $name = null)

Get an instance by name.

mixed
get(string $name)

Attempt to get an instance from the local cache.

mixed
resolve(string $name)

Resolve the given instance.

mixed
callCustomCreator(array $config)

Call a custom instance creator.

forgetInstance(array|string|null $name = null)

Unset the given instances.

void
purge(string|null $name = null)

Disconnect the given instance and remove from local cache.

extend(string $name, Closure $callback)

Register a custom instance creator Closure.

setApplication(Application $app)

Set the application instance used by the manager.

mixed
__call(string $method, array $parameters)

Dynamically call the default instance.

mixed
driver(UnitEnum|string|null $name = null)

Get a driver instance by name.

createCoroutineDriver()

Create an instance of the coroutine concurrency driver.

createProcessDriver()

Create an instance of the process concurrency driver.

createSyncDriver()

Create an instance of the sync concurrency driver.

Details

protected Closure|null bindCallbackToSelf(Closure $callback)

Bind the provided callback to the class instance.

Parameters

Closure $callback

Return Value

Closure|null

Exceptions

ReflectionException

__construct(Application $app)

Create a new manager instance.

Parameters

Application $app

at line 61
string getDefaultInstance()

Get the default instance name.

Return Value

string

at line 73
void setDefaultInstance(string $name)

Set the default concurrency driver name.

Boot-only. Mutates process-global config; per-request use races across coroutines.

Parameters

string $name

Return Value

void

at line 82
array getInstanceConfig(string $name)

Get the instance specific configuration.

Parameters

string $name

Return Value

array

mixed instance(string|null $name = null)

Get an instance by name.

Parameters

string|null $name

Return Value

mixed

protected mixed get(string $name)

Attempt to get an instance from the local cache.

Parameters

string $name

Return Value

mixed

protected mixed resolve(string $name)

Resolve the given instance.

Parameters

string $name

Return Value

mixed

Exceptions

InvalidArgumentException
RuntimeException

protected mixed callCustomCreator(array $config)

Call a custom instance creator.

Parameters

array $config

Return Value

mixed

MultipleInstanceManager forgetInstance(array|string|null $name = null)

Unset the given instances.

Boot or tests only. Mutates the singleton's instance cache; concurrent coroutines may already hold a reference to the forgotten instance and next resolution will rebuild.

Parameters

array|string|null $name

Return Value

MultipleInstanceManager

void purge(string|null $name = null)

Disconnect the given instance and remove from local cache.

Boot or tests only. Mutates the singleton's instance cache; concurrent coroutines may already hold a reference to the instance and next resolution will rebuild.

Parameters

string|null $name

Return Value

void

MultipleInstanceManager extend(string $name, Closure $callback)

Register a custom instance creator Closure.

Boot-only. The callback persists in the singleton's customCreators array for the worker lifetime and applies to every subsequent instance resolution.

Parameters

string $name
Closure $callback

Return Value

MultipleInstanceManager

MultipleInstanceManager setApplication(Application $app)

Set the application instance used by the manager.

Tests only. Swaps the singleton's application reference; per-request use races across coroutines and breaks every concurrent resolution through this manager.

Parameters

Application $app

Return Value

MultipleInstanceManager

mixed __call(string $method, array $parameters)

Dynamically call the default instance.

Parameters

string $method
array $parameters

Return Value

mixed

at line 22
mixed driver(UnitEnum|string|null $name = null)

Get a driver instance by name.

Parameters

UnitEnum|string|null $name

Return Value

mixed

at line 34
CoroutineDriver createCoroutineDriver()

Create an instance of the coroutine concurrency driver.

Return Value

CoroutineDriver

at line 42
ProcessDriver createProcessDriver()

Create an instance of the process concurrency driver.

Return Value

ProcessDriver

at line 53
SyncDriver createSyncDriver()

Create an instance of the sync concurrency driver.

Return Value

SyncDriver