Skip to content

Commit

Permalink
update(Race): minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
b97tsk committed Oct 7, 2023
1 parent 014b264 commit c79d4ec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions race.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (some observables[T]) Race(ctx context.Context, sink Observer[T]) {
subs[i] = NewPair(context.WithCancel(ctx))
}

var race atomic.Value
var race atomic.Uint32

ctxHoisted := waitgroup.Hoist(ctx)

Expand All @@ -53,7 +53,7 @@ func (some observables[T]) Race(ctx context.Context, sink Observer[T]) {
return
}

if race.CompareAndSwap(nil, subs[index].Left()) {
if race.CompareAndSwap(0, 1) {
for i := range subs {
if i != index {
subs[i].Right()()
Expand Down
1 change: 0 additions & 1 deletion race_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func TestRace(t *testing.T) {
)
}

rand.Seed(time.Now().UnixNano())
rand.Shuffle(len(s), func(i, j int) { s[i], s[j] = s[j], s[i] })

NewTestSuite[time.Duration](t).Case(
Expand Down

0 comments on commit c79d4ec

Please sign in to comment.