Skip to content

Commit

Permalink
core: use 10-buffered chans for events, see hybridgroup#374
Browse files Browse the repository at this point in the history
  • Loading branch information
rkjdid committed Apr 7, 2017
1 parent f89113c commit d86f406
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions eventer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type eventer struct {
eventsMutex sync.Mutex
}

const eventChanBufferSize = 10

// Eventer is the interface which describes how a Driver or Adaptor
// handles events.
type Eventer interface {
Expand Down Expand Up @@ -54,7 +56,7 @@ type Eventer interface {
func NewEventer() Eventer {
evtr := &eventer{
eventnames: make(map[string]string),
in: make(eventChannel, 1),
in: make(eventChannel, eventChanBufferSize),
outs: make(map[eventChannel]eventChannel),
}

Expand Down Expand Up @@ -106,7 +108,7 @@ func (e *eventer) Publish(name string, data interface{}) {
func (e *eventer) Subscribe() eventChannel {
e.eventsMutex.Lock()
defer e.eventsMutex.Unlock()
out := make(eventChannel)
out := make(eventChannel, eventChanBufferSize)
e.outs[out] = out
return out
}
Expand Down

0 comments on commit d86f406

Please sign in to comment.