xcontext

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

README

zombiezen.com/go/xcontext Package

The Go package xcontext provides extra functionality for contexts that is not available from the standard context package.

Install

go get zombiezen.com/go/xcontext

License

BSD 3-Clause. This package was spun out from github.com/yourbase/commons.

Documentation

Overview

Package xcontext is a package to offer extra functionality for contexts that is not available from the standard context package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseWhenDone added in v1.1.0

func CloseWhenDone(ctx context.Context, c io.Closer) io.Closer

CloseWhenDone calls c.Close() when the Context is Done or the returned io.Closer is called, whichever comes first. It guarantees that c.Close() will be called at most once. Subsequent calls to the the returned io.Closer's Close method will return the error returned by c.Close().

Closing the returned io.Closer releases resources associated with it, so code should close the returned io.Closer as soon as c is no longer being used.

func IgnoreDeadline

func IgnoreDeadline(ctx context.Context) context.Context

IgnoreDeadline returns a context that keeps all the values of its parent context but detaches from the cancellation and error handling.

KeepAlive should be preferred over IgnoreDeadline in most cases to prevent work from preventing shutdown.

func KeepAlive

func KeepAlive(parent context.Context, d time.Duration) (context.Context, context.CancelFunc)

KeepAlive returns a context that keeps all the values of its parent context and ensures that it is not marked Done for at least d time.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL