Skip to content

Commit

Permalink
do not close already closed channel
Browse files Browse the repository at this point in the history
  • Loading branch information
janveltm committed Mar 13, 2024
1 parent a9ffe31 commit 095ab4b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions opwindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ func (q *OpWindow) Enqueue(ctx context.Context, id ID, op *Op) error {
item, ok := q.m[id]
if ok {
if len(item.OpSet.set) >= q.width {
close(item.IsFull)
if !item.IsFullClosed {
close(item.IsFull)
item.IsFullClosed = true
}
q.mu.Unlock()
return ErrQueueSaturatedWidth
}
Expand Down Expand Up @@ -163,8 +166,9 @@ func (q *OpWindow) Dequeue(ctx context.Context) (*OpSet, error) {
}

type queueItem struct {
ID ID
ProcessAt time.Time
OpSet *OpSet
IsFull chan struct{}
ID ID
ProcessAt time.Time
OpSet *OpSet
IsFull chan struct{}
IsFullClosed bool
}

0 comments on commit 095ab4b

Please sign in to comment.