mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
use WithoutCancel interface w/ Pop(nil)
This commit is contained in:
parent
af95e3fe0e
commit
26593f1a6a
@ -441,7 +441,7 @@ func (s *offerStorage) ageOffers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *offerStorage) nextListener() *offerListener {
|
func (s *offerStorage) nextListener() *offerListener {
|
||||||
obj := s.listeners.Pop(nil)
|
obj := s.listeners.Pop(queue.WithoutCancel())
|
||||||
if listen, ok := obj.(*offerListener); !ok {
|
if listen, ok := obj.(*offerListener); !ok {
|
||||||
//programming error
|
//programming error
|
||||||
panic(fmt.Sprintf("unexpected listener object %v", obj))
|
panic(fmt.Sprintf("unexpected listener object %v", obj))
|
||||||
|
@ -358,7 +358,7 @@ func TestDFIFO_sanity_check(t *testing.T) {
|
|||||||
|
|
||||||
// pop last
|
// pop last
|
||||||
before := time.Now()
|
before := time.Now()
|
||||||
x := df.Pop(nil)
|
x := df.Pop(WithoutCancel())
|
||||||
assert.Equal(a.(*testjob).instance, 2)
|
assert.Equal(a.(*testjob).instance, 2)
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
@ -395,7 +395,7 @@ func TestDFIFO_Offer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
before := time.Now()
|
before := time.Now()
|
||||||
x := dq.Pop(nil)
|
x := dq.Pop(WithoutCancel())
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
waitPeriod := now.Sub(before)
|
waitPeriod := now.Sub(before)
|
||||||
|
@ -75,7 +75,7 @@ func TestFIFO_basic(t *testing.T) {
|
|||||||
lastInt := _int(0)
|
lastInt := _int(0)
|
||||||
lastUint := _uint(0)
|
lastUint := _uint(0)
|
||||||
for i := 0; i < amount*2; i++ {
|
for i := 0; i < amount*2; i++ {
|
||||||
switch obj := f.Pop(nil).(type) {
|
switch obj := f.Pop(WithoutCancel()).(type) {
|
||||||
case _int:
|
case _int:
|
||||||
if obj <= lastInt {
|
if obj <= lastInt {
|
||||||
t.Errorf("got %v (int) out of order, last was %v", obj, lastInt)
|
t.Errorf("got %v (int) out of order, last was %v", obj, lastInt)
|
||||||
@ -100,7 +100,7 @@ func TestFIFO_addUpdate(t *testing.T) {
|
|||||||
got := make(chan *testObj, 2)
|
got := make(chan *testObj, 2)
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
got <- f.Pop(nil).(*testObj)
|
got <- f.Pop(WithoutCancel()).(*testObj)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ func TestFIFO_addReplace(t *testing.T) {
|
|||||||
got := make(chan *testObj, 2)
|
got := make(chan *testObj, 2)
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
got <- f.Pop(nil).(*testObj)
|
got <- f.Pop(WithoutCancel()).(*testObj)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -158,24 +158,24 @@ func TestFIFO_detectLineJumpers(t *testing.T) {
|
|||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
defer close(done)
|
defer close(done)
|
||||||
if e, a := 13, f.Pop(nil).(*testObj).value; a != e {
|
if e, a := 13, f.Pop(WithoutCancel()).(*testObj).value; a != e {
|
||||||
err = fmt.Errorf("expected %d, got %d", e, a)
|
err = fmt.Errorf("expected %d, got %d", e, a)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
f.Add(&testObj{"foo", 14}) // ensure foo doesn't jump back in line
|
f.Add(&testObj{"foo", 14}) // ensure foo doesn't jump back in line
|
||||||
|
|
||||||
if e, a := 1, f.Pop(nil).(*testObj).value; a != e {
|
if e, a := 1, f.Pop(WithoutCancel()).(*testObj).value; a != e {
|
||||||
err = fmt.Errorf("expected %d, got %d", e, a)
|
err = fmt.Errorf("expected %d, got %d", e, a)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if e, a := 30, f.Pop(nil).(*testObj).value; a != e {
|
if e, a := 30, f.Pop(WithoutCancel()).(*testObj).value; a != e {
|
||||||
err = fmt.Errorf("expected %d, got %d", e, a)
|
err = fmt.Errorf("expected %d, got %d", e, a)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if e, a := 14, f.Pop(nil).(*testObj).value; a != e {
|
if e, a := 14, f.Pop(WithoutCancel()).(*testObj).value; a != e {
|
||||||
err = fmt.Errorf("expected %d, got %d", e, a)
|
err = fmt.Errorf("expected %d, got %d", e, a)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -102,4 +102,5 @@ type UniqueDeadlined interface {
|
|||||||
Deadlined
|
Deadlined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithoutCancel returns a chan that may never be closed and always blocks
|
||||||
func WithoutCancel() <-chan struct{} { return nil }
|
func WithoutCancel() <-chan struct{} { return nil }
|
||||||
|
Loading…
Reference in New Issue
Block a user