Skip to content

Commit

Permalink
avoid apis added in go 1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jan 16, 2023
1 parent 232f4b9 commit 19cc14d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,16 @@ const (
)

type CancelFlag struct {
atomic.Bool
uint32
}

func (flag *CancelFlag) Cancel() {
atomic.StoreUint32(&flag.uint32, 1)
}

// This checks for nil in one place so we don't have to do that everywhere
func (flag *CancelFlag) DidCancel() bool {
return flag != nil && flag.Load()
return flag != nil && atomic.LoadUint32(&flag.uint32) != 0
}

type Options struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/api_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ func (ctx *internalContext) Cancel() {

if build != nil {
// Tell observers to cut this build short
build.cancel.Store(true)
build.cancel.Cancel()

// Wait for the build to finish before returning
build.waitGroup.Wait()
Expand Down

0 comments on commit 19cc14d

Please sign in to comment.