diff options
author | Tamir Duberstein <tamird@google.com> | 2020-06-24 13:54:58 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-06-24 13:56:38 -0700 |
commit | 10930b0f8c1ff2ac83c7a30cc1f78112a35e3183 (patch) | |
tree | 200c919580a694aa79d1b1fe80982fc100090ffc /pkg/waiter | |
parent | b070e218c6fe61c6ef98e0a3af5ad58d7e627632 (diff) |
Remove waiter.Entry.Context
This field is redundant since state can be stored in the callback.
PiperOrigin-RevId: 318134855
Diffstat (limited to 'pkg/waiter')
-rw-r--r-- | pkg/waiter/waiter.go | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/pkg/waiter/waiter.go b/pkg/waiter/waiter.go index 707eb085b..67a950444 100644 --- a/pkg/waiter/waiter.go +++ b/pkg/waiter/waiter.go @@ -128,13 +128,6 @@ type EntryCallback interface { // // +stateify savable type Entry struct { - // Context stores any state the waiter may wish to store in the entry - // itself, which may be used at wake up time. - // - // Note that use of this field is optional and state may alternatively be - // stored in the callback itself. - Context interface{} - Callback EntryCallback // The following fields are protected by the queue lock. @@ -142,13 +135,14 @@ type Entry struct { waiterEntry } -type channelCallback struct{} +type channelCallback struct { + ch chan struct{} +} // Callback implements EntryCallback.Callback. -func (*channelCallback) Callback(e *Entry) { - ch := e.Context.(chan struct{}) +func (c *channelCallback) Callback(*Entry) { select { - case ch <- struct{}{}: + case c.ch <- struct{}{}: default: } } @@ -164,7 +158,7 @@ func NewChannelEntry(c chan struct{}) (Entry, chan struct{}) { c = make(chan struct{}, 1) } - return Entry{Context: c, Callback: &channelCallback{}}, c + return Entry{Callback: &channelCallback{ch: c}}, c } // Queue represents the wait queue where waiters can be added and |