contextimpl

package
v0.0.0-...-cba17b0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

README

justforfunc 10: Implemeting the Context Package

Let's implement the context package, with exactly the same API as the one in the standard library, in under 40 minutes.

References:

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Canceled = errors.New("context canceled")
View Source
var DeadlineExceeded = deadlineExceededErr{}

Functions

func WithCancel

func WithCancel(parent Context) (Context, CancelFunc)

func WithDeadline

func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc)

func WithTimeout

func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc)

Types

type CancelFunc

type CancelFunc func()

type Context

type Context interface {
	Deadline() (deadline time.Time, ok bool)
	Done() <-chan struct{}
	Err() error
	Value(key interface{}) interface{}
}

func Background

func Background() Context

func TODO

func TODO() Context

func WithValue

func WithValue(parent Context, key, value interface{}) Context

Jump to

Keyboard shortcuts

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