Lock

interface Lock

A single resource that cannot be used by more than one task at a time. Common usages include representations of hardware (physical devices) and proxy objects.

Inheritors

Types

Link copied to clipboard
class StrLock(val name: String) : Lock

Simple implementation of Lock based around string IDs.

Functions

Link copied to clipboard
open fun derive(): Lock

Create a new Lock derived from this Lock. The new lock should have a unique identity (it should not be equivalent to any other lock) but should be obviously associated with this one.

abstract fun derive(annotation: String?): Lock

Create a new Lock derived from this Lock. The new lock should have a unique identity (it should not be equivalent to any other lock) but should be obviously associated with this one. The provided annotation may optionally be used to provide additional information.

Link copied to clipboard
abstract fun getFriendlyName(): String

A name that could be used to refer to this lock in error messages or logs. Hopefully descriptive enough to locate when problems occur.

Link copied to clipboard
open fun onAcquire(source: ITask<*>)

Called internally when this lock becomes 'acquired' (in use) by a Task.

Link copied to clipboard
open fun onRelease(source: ITask<*>)

Called internally when this lock is no longer 'acquired' by any Task and becomes able to be claimed by any task.

Link copied to clipboard
open fun onTransfer(source: ITask<*>, destination: ITask<*>)

Called internally when this lock is explicitly transferred to another Task. Transferring locks prevents 'lock stealing' during the small transition period due to .then().