vendor go-memdb

This commit is contained in:
Alex Dadgar 2017-08-31 15:16:11 -07:00
parent 62c14c21a5
commit 8486042a86
3 changed files with 46 additions and 47 deletions

View file

@ -61,16 +61,15 @@ func (w WatchSet) Watch(timeoutCh <-chan time.Time) bool {
}
}()
return w.WatchCtx(ctx)
return w.WatchCtx(ctx) == context.Canceled
}
// WatchCtx is used to wait for either the watch set to trigger or for the
// context to be cancelled. Returns true if the context is cancelled. Watch with
// a timeout channel can be mimicked by creating a context with a deadline.
// WatchCtx should be preferred over Watch.
func (w WatchSet) WatchCtx(ctx context.Context) bool {
// context to be cancelled. Watch with a timeout channel can be mimicked by
// creating a context with a deadline. WatchCtx should be preferred over Watch.
func (w WatchSet) WatchCtx(ctx context.Context) error {
if w == nil {
return false
return nil
}
if n := len(w); n <= aFew {
@ -87,11 +86,11 @@ func (w WatchSet) WatchCtx(ctx context.Context) bool {
}
// watchMany is used if there are many watchers.
func (w WatchSet) watchMany(ctx context.Context) bool {
func (w WatchSet) watchMany(ctx context.Context) error {
// Set up a goroutine for each watcher.
triggerCh := make(chan struct{}, 1)
watcher := func(chunk []<-chan struct{}) {
if timeout := watchFew(ctx, chunk); !timeout {
if err := watchFew(ctx, chunk); err == nil {
select {
case triggerCh <- struct{}{}:
default:
@ -123,8 +122,8 @@ func (w WatchSet) watchMany(ctx context.Context) bool {
// Wait for a channel to trigger or timeout.
select {
case <-triggerCh:
return false
return nil
case <-ctx.Done():
return true
return ctx.Err()
}
}

View file

@ -12,106 +12,106 @@ const aFew = 32
// watchFew is used if there are only a few watchers as a performance
// optimization.
func watchFew(ctx context.Context, ch []<-chan struct{}) bool {
func watchFew(ctx context.Context, ch []<-chan struct{}) error {
select {
case <-ch[0]:
return false
return nil
case <-ch[1]:
return false
return nil
case <-ch[2]:
return false
return nil
case <-ch[3]:
return false
return nil
case <-ch[4]:
return false
return nil
case <-ch[5]:
return false
return nil
case <-ch[6]:
return false
return nil
case <-ch[7]:
return false
return nil
case <-ch[8]:
return false
return nil
case <-ch[9]:
return false
return nil
case <-ch[10]:
return false
return nil
case <-ch[11]:
return false
return nil
case <-ch[12]:
return false
return nil
case <-ch[13]:
return false
return nil
case <-ch[14]:
return false
return nil
case <-ch[15]:
return false
return nil
case <-ch[16]:
return false
return nil
case <-ch[17]:
return false
return nil
case <-ch[18]:
return false
return nil
case <-ch[19]:
return false
return nil
case <-ch[20]:
return false
return nil
case <-ch[21]:
return false
return nil
case <-ch[22]:
return false
return nil
case <-ch[23]:
return false
return nil
case <-ch[24]:
return false
return nil
case <-ch[25]:
return false
return nil
case <-ch[26]:
return false
return nil
case <-ch[27]:
return false
return nil
case <-ch[28]:
return false
return nil
case <-ch[29]:
return false
return nil
case <-ch[30]:
return false
return nil
case <-ch[31]:
return false
return nil
case <-ctx.Done():
return true
return ctx.Err()
}
}

6
vendor/vendor.json vendored
View file

@ -737,10 +737,10 @@
"revisionTime": "2017-07-25T22:12:15Z"
},
{
"checksumSHA1": "Q7MLoOLgXyvHBVmT/rvSeOhJo6c=",
"checksumSHA1": "FMAvwDar2bQyYAW4XMFhAt0J5xA=",
"path": "github.com/hashicorp/go-memdb",
"revision": "f2dec88c7441ddf375eabd561b0a1584b67b8ce4",
"revisionTime": "2017-08-30T23:01:53Z"
"revision": "20ff6434c1cc49b80963d45bf5c6aa89c78d8d57",
"revisionTime": "2017-08-31T20:15:40Z"
},
{
"path": "github.com/hashicorp/go-msgpack/codec",