class DetectionLock

Tracks running laser point detections of a volume to prevent concurrent submissions.

The state of a volume is stored in a single cache entry so a volume submission doesn't have to check the entries of all images of the volume.

Methods

static bool
acquireVolume(int $volumeId)

Try to mark a volume detection as running.

static void
releaseVolume(int $volumeId)

Mark a volume detection as finished.

static bool
acquireImage(int $volumeId, int $imageId)

Try to mark a single image detection as running.

static void
releaseImage(int $volumeId, int $imageId)

Mark a single image detection as finished.

static string
key(int $volumeId)

Get the cache key of the state of a volume.

static bool
mutate(int $volumeId, callable $callback)

Atomically read, modify and write the state of a volume.

Details

at line 23
static bool acquireVolume(int $volumeId)

Try to mark a volume detection as running.

Parameters

int $volumeId

Return Value

bool

Whether the lock was acquired.

at line 45
static void releaseVolume(int $volumeId)

Mark a volume detection as finished.

Parameters

int $volumeId

Return Value

void

at line 62
static bool acquireImage(int $volumeId, int $imageId)

Try to mark a single image detection as running.

Parameters

int $volumeId
int $imageId

Return Value

bool

Whether the lock was acquired.

at line 85
static void releaseImage(int $volumeId, int $imageId)

Mark a single image detection as finished.

Parameters

int $volumeId
int $imageId

Return Value

void

at line 101
static string key(int $volumeId)

Get the cache key of the state of a volume.

Parameters

int $volumeId

Return Value

string

at line 117
static protected bool mutate(int $volumeId, callable $callback)

Atomically read, modify and write the state of a volume.

Parameters

int $volumeId
callable $callback

Receives the state by reference. The state is only written if the callback returns true.

Return Value

bool

Return value of the callback.

Exceptions

LockTimeoutException