API overview
| API | Summary |
|---|---|
@tasklet code | Create an object that is a memoized version of () -> code but also acts like a Promise that is not settable. |
Backoff(mindelay, maxdelay) -> backoff | Create a callable backoff where backoff() spin-wait some amount of times. |
Guard(data) | Guard mutable data. Use guarding to obtain exclusive access to data. |
Once{T}(f = T) | A concurrent object for lazily initializing an object of type T. |
Promise{T}() | Create a promise of type T; i.e., a memory location that holds a value of type T that can be set once and retrieved asynchronously. |
ReadWriteGuard(data) | Guard mutable data. Use guarding and guarding_read to obtain exclusive ("write") and shared ("read") access to data. |
ReadWriteLock() | Create a read-write lock. |
ThreadLocalStorage{T}(factory) | Create a thread-local storage of type T created by factory(). |
guarding(f!, guard) | Apply f! to the data wrapped in guard while obtaining exclusive access. |
guarding_read(f, guard) | Apply f to the data wrapped in guard while obtaining shared access. |
lock_read(rwlock) | lock_read(rwlock) takes reader (shared) lock. It must be released with unlock_read. |
race_put_with!(thunk, promise::Promise{T}) -> value::T | Fetch an existing value or set value = thunk(). The thunk is called at most once for each instance of promise. |
spinloop() | A hint to the compiler, runtime, and hardware that spinloop() is in the middle of a spin loop. Call this in a spin loop that requires some other worker threads to make forward progress in order for the current thread to make forward progress. |
try_race_fetch(promiselike) -> Ok(value::T) or Err(NotSetError()) | Try to retrieve a value if it is already set. Return Ok(value) on success and Err(NotSetError()) on failure. |
try_race_put!(promise::Promise{T}, value) -> Ok(value′::T) or Err(existing::T) | Try to set a value in the promise. |
try_race_put_with!(thunk, promise::Promise{T}) -> Ok(computed::T) or Err(existing::T) | Fetch an existing value or set a computed value (computed = thunk()). The thunk is called at most once for each instance of promise. |
trylock_read(rwlock) -> acquired::Bool | Try to take reader lock. Return true on success. |
unlock_read(rwlock) | Unlock the reader lock taken with a preceding invocation of lock_read. |