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 ¶
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.