Interface CancelContext

A Context carries a deadline, a cancellation signal, and other values across API boundaries.

Hierarchy

Properties

deadline: undefined | Date

returns the time when work done on behalf of this context should be canceled. returns undefined when no deadline is set. Successive calls to Deadline return the same results.

done: ReadChannel<void>

returns a channel that's closed when work done on behalf of this context should be canceled. Successive calls to Done return the same value.

err: undefined | Exception

If done is not yet closed,err is undefined. If done is closed, err is a non-nil error explaining why

isClosed: boolean

If done is not yet closed, isClosed is false. If done is closed, isClosed is true

Methods

  • Canceling this context releases resources associated with it, so code should call cancel as soon as the operations running in this Context complete.

    Parameters

    • Optional reason: any

    Returns void

  • get() returns the value associated with this context for key or undefined if no value is associated with key. Successive calls to get() with the same key returns the same result.

    Type Parameters

    • T

    Parameters

    Returns undefined | T

  • get() returns the [value,true] associated with this context for key or [undefined, false] if no value is associated with key. Successive calls to get() with the same key returns the same result.

    Type Parameters

    • T

    Parameters

    Returns [undefined, false] | [T, true]

  • Promise returns true after waiting for the number of milliseconds specified by ms, if done before then Promise returns false immediately

    Parameters

    • ms: number

    Returns Promise<boolean>

  • returns a copy of the this context with the deadline adjusted to be no later than d. If the this's deadline is already earlier than d, withDeadline(d) is semantically equivalent to this. The returned context's Done channel is closed when the deadline expires, when the returned cancel function is called, or when the this context's Done channel is closed, whichever happens first.

    Parameters

    • d: Date

    Returns CancelContext

  • returns a copy of the this context with the deadline adjusted to be no later than d. If the this's deadline is already earlier than d, withDeadline(d) is semantically equivalent to this. The returned context's Done channel is closed when the deadline expires, when the returned cancel function is called, or when the this context's Done channel is closed, whichever happens first.

    Parameters

    • d: Date
    • cancelFunc: true

    Returns [CancelContext, CancelFunc]

Generated using TypeDoc