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.
Sync.Lock
Section titled “Sync.Lock”Share through a service; other plugins lock it through their own sync.
held(): booleanheld(): booleanbool Held()bool held() constpub fn held(&self) -> boolfn held(self: Wraith.Sync.Lock) boolbool Wraith_Sync_Lock_held(Wraith_Sync_Lock self)Whether anyone has it, for showing. May change straight after.
Get it with Api.sync().
newLock(): Wraith.Sync.Locklock(lock: Wraith.Sync.Lock | null): Promise<void>tryLock(lock: Wraith.Sync.Lock | null): booleanunlock(lock: Wraith.Sync.Lock | null): voidnewLock(): Wraith.Sync.Locklock(lock: Wraith.Sync.Lock|nil): salamander.PromisetryLock(lock: Wraith.Sync.Lock|nil): booleanunlock(lock: Wraith.Sync.Lock|nil)Wraith.Sync.Lock? NewLock()System.Threading.Tasks.Task LockAsync(Wraith.Sync.Lock? @lock, System.Threading.CancellationToken cancel = default)bool TryLock(Wraith.Sync.Lock? @lock)void Unlock(Wraith.Sync.Lock? @lock)Wraith::Sync_Lock newLock() constsal::Future<void, Wraith::SyncError> lock(Wraith::Sync_Lock lock) constbool tryLock(Wraith::Sync_Lock lock) constvoid unlock(Wraith::Sync_Lock lock) constpub fn new_lock(&self) -> wraith::SyncLockpub fn lock(&self, lock: wraith::SyncLock) -> salamander::Future<(), wraith::SyncError>pub fn try_lock(&self, lock: wraith::SyncLock) -> boolpub fn unlock(&self, lock: wraith::SyncLock)fn newLock(self: Wraith.Sync) Wraith.Sync.Lockfn lock(self: Wraith.Sync, lock: Wraith.Sync.Lock) rt.Promise((Wraith.SyncError || rt.Failure)!void, Wraith.SyncErrorCode)fn tryLock(self: Wraith.Sync, lock: Wraith.Sync.Lock) boolfn unlock(self: Wraith.Sync, lock: Wraith.Sync.Lock) voidWraith_Sync_Lock Wraith_Sync_newLock(Wraith_Sync self)sal_Promise Wraith_Sync_lock(Wraith_Sync self, Wraith_Sync_Lock lock)bool Wraith_Sync_tryLock(Wraith_Sync self, Wraith_Sync_Lock lock)void Wraith_Sync_unlock(Wraith_Sync self, Wraith_Sync_Lock lock)newLock
Section titled “newLock”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.
tryLock
Section titled “tryLock”Takes it if nobody has it.
Uses Sync.Lock.
unlock
Section titled “unlock”Hands it to the longest waiter. Nothing if this plugin doesn’t have it.
Uses Sync.Lock.
SyncError
Section titled “SyncError”What can go wrong, besides Cancelled, Unsupported and Gone.
| Code | Error | |
|---|---|---|
| 1 | AlreadyHeld |
This plugin has it already. Not reentrant. |
| 2 | Failed |
wraith.io · Mods on the Hub · Get Wraith
Made with ♥ by Asgard
