base: Index | Files

package backgroundcontext

import ""

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 Uses

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 Uses

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 Uses

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 Uses

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.

Package backgroundcontext imports 4 packages (graph) and is imported by 8 packages. Updated 2019-10-17. Refresh now. Tools for package owners.