CloudSqlite.withWriteLock Function

Perform an asynchronous write operation on a CloudContainer with the write lock held.

  1. if write lock is already held, call operation and return.
  2. attempt to acquire the write lock, with retries. Throw if unable to obtain write lock.
  3. perform the operation

3.a if the operation throws, abandon all changes and re-throw 4. release the write lock. 5. return value from operation

withWriteLock<T>(user: string, container: CloudSqlite.CloudContainer, operation: () => T, busyHandler?: CloudSqlite.WriteLockBusyHandler): Promise<T>

Parameter Type Description
user string the name to be displayed to other users in the event they attempt to obtain the lock while it is held by us
container CloudSqlite.CloudContainer the CloudContainer for which the lock is to be acquired
operation () => T an asynchronous operation performed with the write lock held.
busyHandler CloudSqlite.WriteLockBusyHandler if present, function called when the write lock is currently held by another user.

Returns - Promise<T>

a Promise with the result of operation

Defined in

Last Updated: 30 November, 2023