OxL Справочник OxL
РусскийEnglish

method ClusterApi.lockFenced

Like lock; the body receives the fencing token of this holding: it increases with every acquisition of the lock, so a resource that remembers the highest token it saw can refuse a holder that was paused and lost the lock meanwhile.

Example:

oxl✓ проверяется в CI
fn main() io, net, time {
  let r = cluster.lockFenced("report") { fence => fence.valid() }
  match r {
    bool ok => print("fence valid: {ok}")
    LockTimeout _ => print("busy")
    NetError _ => print("unavailable")
  }
}
Вывод
fence valid: true
pub(api) fn lockFenced<T, effect F>(key: str, ttl: Duration = 30s, wait: Duration = 60s, body: fn(Fence) -> T F) -> T | LockTimeout | NetError  net, time, F

С версии. 1.0.0-beta

Параметры

ИмяТип
keystr
ttlDuration = 30s
waitDuration = 60s
bodyfn(Fence) -> T F

Возвращает

T

Ошибки

  • LockTimeout
  • NetError net, time, F
  • `LockTimeout` when the lock is not free within `wait`; `NetError` when the lock service cannot be reached.

Эффекты

не объявлены (чистая, пока тело не говорит иное)

Определено в: std/core/node.oxl:443

См. также