oops, be a good citizen
Signed-off-by: Xe Iaso <me@christine.website>
This commit is contained in:
parent
aa58cbb9df
commit
bbeaa584c0
2
queue.go
2
queue.go
|
@ -22,6 +22,8 @@ func (q Queue[T]) Pop() T {
|
||||||
return <-q.data
|
return <-q.data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TryPop tries to pop from a queue. If it stalls long enough for the context
|
||||||
|
// to time out, it panics.
|
||||||
func (q Queue[T]) TryPop(ctx context.Context) T {
|
func (q Queue[T]) TryPop(ctx context.Context) T {
|
||||||
select {
|
select {
|
||||||
case val := <-q.data:
|
case val := <-q.data:
|
||||||
|
|
Loading…
Reference in New Issue