Skip to content

Sync

Locks shared between plugins, threads, tasks and scripts. lock never blocks, and a freed lock goes to the longest waiter. Locks, holds and waits go with their plugin. Any thread.

Share through a service; other plugins lock it through their own sync.

held(): boolean

Whether anyone has it, for showing. May change straight after.

Get it with Api.sync().

newLock(): Wraith.Sync.Lock
lock(lock: Wraith.Sync.Lock | null): Promise<void>
tryLock(lock: Wraith.Sync.Lock | null): boolean
unlock(lock: Wraith.Sync.Lock | null): void

Goes when this plugin does.

Uses Sync.Lock.

Settles once it’s this plugin’s. Fails with Salamander’s built-in Gone if the lock goes first.

Async. Fails with SyncError. Uses Sync.Lock.

Takes it if nobody has it.

Uses Sync.Lock.

Hands it to the longest waiter. Nothing if this plugin doesn’t have it.

Uses Sync.Lock.

What can go wrong, besides Cancelled, Unsupported and Gone.

Code Error
1 AlreadyHeld This plugin has it already. Not reentrant.
2 Failed

Made with ♥ by Asgard