Skip to content

Commit

Permalink
Merge pull request #208 from oakmound/fix/unbindcaller-resetcount
Browse files Browse the repository at this point in the history
event/internal: Unbind calls now take the current reset of the bus
  • Loading branch information
200sc committed Jun 5, 2022
2 parents a75e0d2 + 9e53a7e commit 3325adc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion event/internal.go
Expand Up @@ -36,7 +36,7 @@ func (bus *Bus) trigger(binds bindableList, eventID UnsafeEventID, callerID Call
// A: This goroutine does not own a write lock on the bus, and should therefore
// not modify its contents. We do not have a simple way of promoting our read lock
// to a write lock.
bus.Unbind(Binding{EventID: eventID, CallerID: callerID, BindID: bindID})
bus.Unbind(Binding{EventID: eventID, CallerID: callerID, BindID: bindID, busResetCount: bus.resetCount})
case ResponseUnbindThisCaller:
bus.UnbindAllFrom(callerID)
}
Expand Down
3 changes: 3 additions & 0 deletions event/response_test.go
Expand Up @@ -12,6 +12,9 @@ func TestBindingResponses(t *testing.T) {
t.Run("UnbindThisBinding", func(t *testing.T) {
b := event.NewBus(event.NewCallerMap())

// bus reset counts are checked against bindings
b.Reset()

var calls int32
b1 := b.UnsafeBind(1, 0, func(ci event.CallerID, h event.Handler, i interface{}) event.Response {
atomic.AddInt32(&calls, 1)
Expand Down

0 comments on commit 3325adc

Please sign in to comment.