Skip to content

Commit

Permalink
test: with data race
Browse files Browse the repository at this point in the history
  • Loading branch information
jizhuozhi committed Jul 21, 2024
1 parent f300811 commit 258434c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
go-version: '1.18'

- name: Test
run: go test -v ./... -coverprofile=coverage.out -covermode=atomic
run: go test -race -coverprofile=coverage.out -covermode=atomic -v ./...

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
Expand Down
3 changes: 3 additions & 0 deletions future.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ func (s *state[T]) get() (T, error) {
}
if atomic.CompareAndSwapUint64(&s.state, st, st+1) {
runtime_Semacquire(&s.sema)
if (atomic.LoadUint64(&s.state)&maskState)>>32 != stateDone {
panic("sync: notified before state has done")
}
return s.val, s.err
}
}
Expand Down

0 comments on commit 258434c

Please sign in to comment.