mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-10 00:51:07 +00:00
util/eventbus: make internal queue a generic type
In preparation for making the queues carry additional event metadata. Updates #15160 Signed-off-by: David Anderson <dave@tailscale.com>
This commit is contained in:

committed by
Dave Anderson

parent
96202a7c0c
commit
bf40bc4fa0
@@ -27,7 +27,7 @@ type subscriber interface {
|
||||
// processing other potential sources of wakeups, which is how we end
|
||||
// up at this awkward type signature and sharing of internal state
|
||||
// through dispatch.
|
||||
dispatch(ctx context.Context, vals *queue, acceptCh func() chan any) bool
|
||||
dispatch(ctx context.Context, vals *queue[any], acceptCh func() chan any) bool
|
||||
Close()
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func newSubscribeState(c *Client) *subscribeState {
|
||||
}
|
||||
|
||||
func (q *subscribeState) pump(ctx context.Context) {
|
||||
var vals queue
|
||||
var vals queue[any]
|
||||
acceptCh := func() chan any {
|
||||
if vals.Full() {
|
||||
return nil
|
||||
@@ -155,7 +155,7 @@ func (s *Subscriber[T]) subscribeType() reflect.Type {
|
||||
return reflect.TypeFor[T]()
|
||||
}
|
||||
|
||||
func (s *Subscriber[T]) dispatch(ctx context.Context, vals *queue, acceptCh func() chan any) bool {
|
||||
func (s *Subscriber[T]) dispatch(ctx context.Context, vals *queue[any], acceptCh func() chan any) bool {
|
||||
t := vals.Peek().(T)
|
||||
for {
|
||||
// Keep the cases in this select in sync with subscribeState.pump
|
||||
|
Reference in New Issue
Block a user