mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-15 06:43:54 +00:00
Expose HistoricalFIFO's pop with cancel channel
This commit is contained in:
parent
d49ca164ef
commit
a496e8dd20
@ -222,7 +222,7 @@ func (f *HistoricalFIFO) Poll(id string, t EventType) bool {
|
|||||||
func (q *HistoricalFIFO) Await(timeout time.Duration) interface{} {
|
func (q *HistoricalFIFO) Await(timeout time.Duration) interface{} {
|
||||||
cancel := make(chan struct{})
|
cancel := make(chan struct{})
|
||||||
ch := make(chan interface{}, 1)
|
ch := make(chan interface{}, 1)
|
||||||
go func() { ch <- q.pop(cancel) }()
|
go func() { ch <- q.CancelablePop(cancel) }()
|
||||||
select {
|
select {
|
||||||
case <-time.After(timeout):
|
case <-time.After(timeout):
|
||||||
close(cancel)
|
close(cancel)
|
||||||
@ -232,10 +232,10 @@ func (q *HistoricalFIFO) Await(timeout time.Duration) interface{} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (f *HistoricalFIFO) Pop() interface{} {
|
func (f *HistoricalFIFO) Pop() interface{} {
|
||||||
return f.pop(nil)
|
return f.CancelablePop(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *HistoricalFIFO) pop(cancel chan struct{}) interface{} {
|
func (f *HistoricalFIFO) CancelablePop(cancel <-chan struct{}) interface{} {
|
||||||
popEvent := (Entry)(nil)
|
popEvent := (Entry)(nil)
|
||||||
defer func() {
|
defer func() {
|
||||||
f.carrier(popEvent)
|
f.carrier(popEvent)
|
||||||
@ -383,7 +383,7 @@ func (f *HistoricalFIFO) merge(id string, obj UniqueCopyable) (notifications []E
|
|||||||
// NewHistorical returns a Store which can be used to queue up items to
|
// NewHistorical returns a Store which can be used to queue up items to
|
||||||
// process. If a non-nil Mux is provided, then modifications to the
|
// process. If a non-nil Mux is provided, then modifications to the
|
||||||
// the FIFO are delivered on a channel specific to this fifo.
|
// the FIFO are delivered on a channel specific to this fifo.
|
||||||
func NewHistorical(ch chan<- Entry) FIFO {
|
func NewHistorical(ch chan<- Entry) *HistoricalFIFO {
|
||||||
carrier := dead
|
carrier := dead
|
||||||
if ch != nil {
|
if ch != nil {
|
||||||
carrier = func(msg Entry) {
|
carrier = func(msg Entry) {
|
||||||
|
Loading…
Reference in New Issue
Block a user