track

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Copyright [2020] [thinkgos] thinkgo@aliyun.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var ErrDying = errors.New("track: dying")

ErrDying is the error returned by Context.Err when the context is canceled.

Functions

This section is empty.

Types

type Context

type Context interface {
	// Done returns a channel that's closed when work done on behalf of this
	// context should be closed. Successive calls to Done return the same value.
	// The close of the Done channel may happen asynchronously after the close or
	// cancel function called.
	// a Done channel for cancellation.
	Done() <-chan struct{}
	// Err returns the err for the goroutine death provided via Close
	// If Done is not yet closed, Err returns nil.
	// If Done is closed, Err returns ErrDying.
	// If Done is closed with Cancel function, Err returns custom error.
	Err() error
	// Close flags the goroutine as dying.
	Close() error
	// Cancel flags the goroutine as dying with custom error.
	// if error is nil, it will use ErrDying.
	Cancel(err error) error
}

Context's methods may be called by multiple goroutines simultaneously.

type Track

type Track struct {
	// contains filtered or unexported fields
}

Track tracks the lifecycle of a goroutine as alive, dying.

func (*Track) Cancel

func (sf *Track) Cancel(err error) error

Cancel flags the goroutine as dying with custom error. if error is nil, it will use ErrDying.

func (*Track) Close

func (sf *Track) Close() error

Close flags the goroutine as dying.

func (*Track) Done

func (sf *Track) Done() chan struct{}

a Done channel for cancellation.

func (*Track) Err

func (sf *Track) Err() error

Err returns the err for the goroutine death provided via Close If Done is not yet closed, Err returns nil. If Done is closed, Err returns ErrDying.

Jump to

Keyboard shortcuts

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