summaryrefslogtreecommitdiffhomepage
path: root/pkg/waiter
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/waiter')
-rw-r--r--pkg/waiter/BUILD27
-rw-r--r--pkg/waiter/waiter.go12
2 files changed, 29 insertions, 10 deletions
diff --git a/pkg/waiter/BUILD b/pkg/waiter/BUILD
index b748246da..48ce063d7 100644
--- a/pkg/waiter/BUILD
+++ b/pkg/waiter/BUILD
@@ -1,13 +1,28 @@
package(licenses = ["notice"])
+load("//tools/go_generics:defs.bzl", "go_template_instance")
load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
+go_template_instance(
+ name = "waiter_list",
+ out = "waiter_list.go",
+ package = "waiter",
+ prefix = "waiter",
+ template = "//pkg/ilist:generic_list",
+ types = {
+ "Element": "*Entry",
+ "Linker": "*Entry",
+ },
+)
+
go_library(
name = "waiter",
- srcs = ["waiter.go"],
+ srcs = [
+ "waiter.go",
+ "waiter_list.go",
+ ],
importpath = "gvisor.googlesource.com/gvisor/pkg/waiter",
visibility = ["//visibility:public"],
- deps = ["//pkg/ilist"],
)
go_test(
@@ -18,3 +33,11 @@ go_test(
],
embed = [":waiter"],
)
+
+filegroup(
+ name = "autogen",
+ srcs = [
+ "waiter_list.go",
+ ],
+ visibility = ["//:sandbox"],
+)
diff --git a/pkg/waiter/waiter.go b/pkg/waiter/waiter.go
index 93390b299..fd429f733 100644
--- a/pkg/waiter/waiter.go
+++ b/pkg/waiter/waiter.go
@@ -59,8 +59,6 @@ package waiter
import (
"sync"
-
- "gvisor.googlesource.com/gvisor/pkg/ilist"
)
// EventMask represents io events as used in the poll() syscall.
@@ -127,7 +125,7 @@ type Entry struct {
// The following fields are protected by the queue lock.
mask EventMask
- ilist.Entry
+ waiterEntry
}
type channelCallback struct{}
@@ -162,7 +160,7 @@ func NewChannelEntry(c chan struct{}) (Entry, chan struct{}) {
//
// +stateify savable
type Queue struct {
- list ilist.List `state:"zerovalue"`
+ list waiterList `state:"zerovalue"`
mu sync.RWMutex `state:"nosave"`
}
@@ -186,8 +184,7 @@ func (q *Queue) EventUnregister(e *Entry) {
// in common with the notification mask.
func (q *Queue) Notify(mask EventMask) {
q.mu.RLock()
- for it := q.list.Front(); it != nil; it = it.Next() {
- e := it.(*Entry)
+ for e := q.list.Front(); e != nil; e = e.Next() {
if mask&e.mask != 0 {
e.Callback.Callback(e)
}
@@ -201,8 +198,7 @@ func (q *Queue) Events() EventMask {
ret := EventMask(0)
q.mu.RLock()
- for it := q.list.Front(); it != nil; it = it.Next() {
- e := it.(*Entry)
+ for e := q.list.Front(); e != nil; e = e.Next() {
ret |= e.mask
}
q.mu.RUnlock()