Skip to content
This repository has been archived by the owner on Nov 21, 2023. It is now read-only.

Commit

Permalink
Merge pull request #19 from goinsane/develop
Browse files Browse the repository at this point in the history
v1.5.6
  • Loading branch information
orkunkaraduman authored Mar 7, 2022
2 parents 3e3a665 + 310da2b commit af35ca6
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions terminatecontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@ func (c *terminateContext) Terminate() {
}

// NewTerminateContext returns the underlying context as TerminateContext.
// It cancels the context when it was done through parent, deadline, timeout or in any way.
// The code should call Terminate method or cancel function to release resources associated with it.
func NewTerminateContext(ctx context.Context, cancel context.CancelFunc) TerminateContext {
result := new(terminateContext)
result.Context, result.CancelFunc = ctx, cancel
AutoCancel(ctx, cancel)
return result
}

// WithTerminate creates a new cancel context as TerminateContext.
// It cancels the context when it was done through parent.
// The code should call Terminate method to release resources associated with it, as cancel function.
func WithTerminate(parent context.Context) TerminateContext {
return NewTerminateContext(context.WithCancel(parent))
Expand Down

0 comments on commit af35ca6

Please sign in to comment.