FdbWatch

Namespace: FoundationDB.Client · class

Implements: IDisposable

Watch that triggers when a watched key has changed in the database

Constructors

FdbWatch

FdbWatch(FdbFuture<Slice> future, Slice key)

Creates a FdbWatch

Properties

IsAlive

bool IsAlive { get; }

true if the watch is still active, or false if it fired or was cancelled

Task

Task<Slice> Task { get; }

Task that will complete when the watch fires, or is cancelled. It will return the watched key, or an exception.

Methods

Cancel

void Cancel()

Cancels the watch.

It will immediately stop monitoring the key.

Has no effect if the watch has already fired

Dispose

void Dispose()

GetAwaiter

TaskAwaiter<Slice> GetAwaiter()

Returns an awaiter for the Watch

ToString

string ToString()

WaitAsync

Task WaitAsync(CancellationToken ct)

Gets a Task that will complete when this watch fires or when the specified CancellationToken has cancellation requested.

  • ct — The CancellationToken to monitor for a cancellation request.

Returns: Task that completes successfully when the watch fires, or fails if the cancellation token is triggered, or the parent IFdbDatabase instance is disposed.

Task<bool> WaitAsync(TimeSpan timeout, CancellationToken ct)

Gets a Task that will complete when this watch fires, when the specified timeout expires, or when the specified CancellationToken has cancellation requested.

  • timeout — The timeout after which the FdbWatch should be cancelled if it hasn't otherwise fired.
  • ct — The CancellationToken to monitor for a cancellation request.

Returns: Task that returns true if the watch as fired, or false if the timeout has expired.

Task<bool> WaitAsync(TimeSpan timeout, TimeProvider timeProvider, CancellationToken ct)

Gets a Task that will complete when this watch fires, when the specified timeout expires, or when the specified CancellationToken has cancellation requested.

  • timeout — The timeout after which the FdbWatch should be cancelled if it hasn't otherwise fired.
  • timeProvider — Time provider used to measure the timeout, so a virtualized clock (a test's fake time) drives the idle wake instead of the real wall clock.
  • ct — The CancellationToken to monitor for a cancellation request.

Returns: Task that returns true if the watch has fired, or false if the timeout has expired.

Fields

Key

readonly Slice Key

Key that is being watched