update go-structr to add (+then rely on) QueueCtx{} type

This commit is contained in:
kim
2024-04-25 17:39:40 +01:00
parent 382790cf7f
commit 4cba8174e7
10 changed files with 272 additions and 106 deletions

View File

@ -120,21 +120,11 @@ func (w *MsgWorker[T]) process(ctx context.Context) {
panic("not yet initialized")
}
loop:
for {
select {
// Worker ctx done.
case <-ctx.Done():
return
// New message enqueued!
case <-w.Queue.Wait():
}
// Try pop next message.
msg, ok := w.Queue.Pop()
// Block until pop next message.
msg, ok := w.Queue.PopCtx(ctx)
if !ok {
continue loop
return
}
// Attempt to process popped message type.