Skip to content

Commit

Permalink
do not close already closed channel (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
janveltm authored Mar 13, 2024
1 parent a9ffe31 commit e9e7de0
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 e9e7de0

Please sign in to comment.