Back to / backgroundcontext

Package backgroundcontext

Latest Go to latest
Published: Jun 24, 2020 | License: Apache-2.0 | Module:


Package backgroundcontext manages the singleton v23 context. This package is not for general use. It it only for packages that (1) need to access a background context, and (2) are used both as a binary and as a shared library (e.g., in R).


Package Files

func Get

func Get() context.Context

Get returns a background context: if a v23 context has been set, it is returned; otherwise the standard Go background context is returned.

func Set

func Set(ctx *v23context.T)

Set sets the singleton global context. It should be called at most once, usually immediately after a process starts. Calling Set() multiple times will cause a panic. Thread safe.

func T

func T() *v23context.T

T returns the background context set by Set. It panics if Set has not been called yet. Thread safe.

func Wrap

func Wrap(ctx context.Context) context.Context

Wrap wraps the provided context, composing it with the defined background context, if any. This allows contexts to be wrapped so that v23 stubs can get the background context's RPC client.

Cancelations are not forwarded: it is assumed that the set background context is never canceled.

BUG: this is very complicated; but it seems required to make vanadium play nicely with contexts defined outside of its universe.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier