sync

Types from the Go package sync (a library PocketBase builds on), as JavaScript sees them: they turn up as values of PocketBase's types and of hook events.

sync.Locker

A Locker represents an object that can be locked and unlocked.

Member Type
lock() (): void
unlock() (): void

sync.Mutex

A Mutex is a mutual exclusion lock. The zero value for a Mutex is an unlocked mutex.

A Mutex must not be copied after first use.

In the terminology of the Go memory model, the n'th call to Mutex.unlock “synchronizes before” the m'th call to Mutex.lock for any n < m. A successful call to Mutex.tryLock is equivalent to a call to Lock. A failed call to TryLock does not establish any “synchronizes before” relation at all.

Member Type
lock() (): void Lock locks m. If the lock is already in use, the calling goroutine blocks until the mutex is available.
tryLock() (): boolean TryLock tries to lock m and reports whether it succeeded.
unlock() (): void Unlock unlocks m. It is a run-time error if m is not locked on entry to Unlock.

sync.RWMutex

A RWMutex is a reader/writer mutual exclusion lock. The lock can be held by an arbitrary number of readers or a single writer. The zero value for a RWMutex is an unlocked mutex.

A RWMutex must not be copied after first use.

If any goroutine calls RWMutex.lock while the lock is already held by one or more readers, concurrent calls to RWMutex.rLock will block until the writer has acquired (and released) the lock, to ensure that the lock eventually becomes available to the writer. Note that this prohibits recursive read-locking. A RWMutex.rLock cannot be upgraded into a RWMutex.lock, nor can a RWMutex.lock be downgraded into a RWMutex.rLock.

In the terminology of the Go memory model, the n'th call to RWMutex.unlock “synchronizes before” the m'th call to Lock for any n < m, just as for Mutex. For any call to RLock, there exists an n such that the n'th call to Unlock “synchronizes before” that call to RLock, and the corresponding call to RWMutex.rUnlock “synchronizes before” the n+1'th call to Lock.

Member Type
rLock() (): void RLock locks rw for reading.
tryRLock() (): boolean TryRLock tries to lock rw for reading and reports whether it succeeded.
rUnlock() (): void RUnlock undoes a single RWMutex.rLock call; it does not affect other simultaneous readers. It is a run-time error if rw is not locked for reading on entry to RUnlock.
lock() (): void Lock locks rw for writing. If the lock is already locked for reading or writing, Lock blocks until the lock is available.
tryLock() (): boolean TryLock tries to lock rw for writing and reports whether it succeeded.
unlock() (): void Unlock unlocks rw for writing. It is a run-time error if rw is not locked for writing on entry to Unlock.
rLocker() (): Locker RLocker returns a Locker interface that implements the Locker.lock and Locker.unlock methods by calling rw.RLock and rw.RUnlock.