class DispatchLockContext

Track dispatch lock ownership until a queue accepts the job.

Properties

static protected null|LockRecord> $records

The lock records owned by live dispatch operations.

static protected list<Closure(): null|Closure(Closure(): void): void> $releaseContextCallbacks

The callbacks that capture context before dispatch lock acquisition.

Methods

static void
captureReleaseContextUsing(callable|null $callback)

Register a callback that captures the context needed for deferred lock release.

static Closure|null
captureReleaseContext()

Capture and compose the current release context.

static void
registerUnique(object $job, Repository $cache, string|null $cacheStore, string $key, string $owner, Closure|null $releaseContext = null)

Register an acquired unique lock.

static void
registerDebounce(object $job, Repository $cache, string $key, string $owner, Closure|null $releaseContext = null)

Register an acquired debounce lock.

static array|null
peekPayloadMetadata(object $job)

Peek at hidden unique-job payload metadata.

static bool
has(object $job)

Determine whether a dispatch owns any locks.

static bool
delegate(object $job)

Delegate a dispatch's lock ownership to a registered callback.

static bool
claim(object $job)

Claim lock ownership in a delegated callback.

static void
accept(object $job)

Mark a dispatch as accepted by a queue.

static void
release(object $job)

Release locks still owned by a dispatch.

static array|null
snapshot(object $job)

Take an independent release snapshot before accepting a dispatch.

static void
releaseSnapshot(array $snapshot)

Release locks from an independent dispatch snapshot.

static void
releaseLocks(array $snapshot)

Release both owned locks even if one cleanup fails.

static array|null
record(object $job)

Get a dispatch's current lock record.

static bool
setDelegated(object $job, bool $delegated)

Set whether a dispatch's lock ownership has been delegated.

static array
newRecord()

Create an empty dispatch lock record.

static void
flushState()

Flush all static state.

Details

at line 62
static void captureReleaseContextUsing(callable|null $callback)

Register a callback that captures the context needed for deferred lock release.

Callbacks persist for the worker lifetime and affect subsequent dispatches. Return a wrapper that invokes the release operation once and restores the previous context in finally, or null when no context is needed. The first wrapper is outermost. Passing null clears registrations; capture runs before acquiring a lock.

Parameters

callable|null $callback

Return Value

void

at line 81
static Closure|null captureReleaseContext()

internal  
 

Capture and compose the current release context.

Return Value

Closure|null

at line 114
static void registerUnique(object $job, Repository $cache, string|null $cacheStore, string $key, string $owner, Closure|null $releaseContext = null)

internal  
 

Register an acquired unique lock.

Parameters

object $job
Repository $cache
string|null $cacheStore
string $key
string $owner
Closure|null $releaseContext

Return Value

void

at line 144
static void registerDebounce(object $job, Repository $cache, string $key, string $owner, Closure|null $releaseContext = null)

internal  
 

Register an acquired debounce lock.

Parameters

object $job
Repository $cache
string $key
string $owner
Closure|null $releaseContext

Return Value

void

at line 166
static array|null peekPayloadMetadata(object $job)

internal  
 

Peek at hidden unique-job payload metadata.

Parameters

object $job

Return Value

array|null

at line 176
static bool has(object $job)

internal  
 

Determine whether a dispatch owns any locks.

Parameters

object $job

Return Value

bool

at line 186
static bool delegate(object $job)

internal  
 

Delegate a dispatch's lock ownership to a registered callback.

Parameters

object $job

Return Value

bool

at line 196
static bool claim(object $job)

internal  
 

Claim lock ownership in a delegated callback.

Parameters

object $job

Return Value

bool

at line 206
static void accept(object $job)

internal  
 

Mark a dispatch as accepted by a queue.

Parameters

object $job

Return Value

void

at line 220
static void release(object $job)

internal  
 

Release locks still owned by a dispatch.

Parameters

object $job

Return Value

void

at line 250
static array|null snapshot(object $job)

internal  
 

Take an independent release snapshot before accepting a dispatch.

Parameters

object $job

Return Value

array|null

at line 272
static void releaseSnapshot(array $snapshot)

internal  
 

Release locks from an independent dispatch snapshot.

Parameters

array $snapshot

Return Value

void

at line 290
static protected void releaseLocks(array $snapshot)

Release both owned locks even if one cleanup fails.

Parameters

array $snapshot

Return Value

void

at line 328
static protected array|null record(object $job)

Get a dispatch's current lock record.

Parameters

object $job

Return Value

array|null

at line 340
static protected bool setDelegated(object $job, bool $delegated)

Set whether a dispatch's lock ownership has been delegated.

Parameters

object $job
bool $delegated

Return Value

bool

at line 360
static protected array newRecord()

Create an empty dispatch lock record.

Return Value

array

at line 374
static void flushState()

Flush all static state.

Return Value

void