Merge pull request #403 from solar3s/issue374

core: use 10-buffered chans for events, see #374
This commit is contained in:
Ron Evans 2017-04-07 14:09:52 +02:00 committed by GitHub
commit acbc561773
1 changed files with 4 additions and 2 deletions

View File

@ -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 {
@ -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),
}
@ -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
}