Skip to content

Commit

Permalink
use chanqueue for unbounded channel
Browse files Browse the repository at this point in the history
  • Loading branch information
gammazero committed Nov 24, 2024
1 parent 9326f0a commit 1be8e62
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sync/atomic"
"time"

"github.com/gammazero/channelqueue"
"github.com/gammazero/chanqueue"
"github.com/gammazero/deque"
"github.com/ipfs/boxo/bitswap/client/internal"
"github.com/ipfs/go-cid"
Expand Down Expand Up @@ -76,7 +76,7 @@ type ProviderQueryManager struct {
ctx context.Context
network ProviderQueryNetwork
providerQueryMessages chan providerQueryMessage
providerRequestsProcessing *channelqueue.ChannelQueue[*findProviderRequest]
providerRequestsProcessing *chanqueue.ChanQueue[*findProviderRequest]

findProviderTimeout atomic.Int64

Expand Down Expand Up @@ -304,10 +304,10 @@ func (pqm *ProviderQueryManager) run() {
defer pqm.cleanupInProcessRequests()

var wg sync.WaitGroup
pqm.providerRequestsProcessing = channelqueue.New[*findProviderRequest](-1)
pqm.providerRequestsProcessing = chanqueue.New[*findProviderRequest]()
defer func() {
pqm.providerRequestsProcessing.Close()
// Afers workers done, close and drain channelqueue.
// Afers workers done, close and drain ChanQueue.
go func() {
wg.Wait()
for range pqm.providerRequestsProcessing.Out() {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/cskr/pubsub v1.0.2
github.com/dustin/go-humanize v1.0.1
github.com/gabriel-vasile/mimetype v1.4.6
github.com/gammazero/channelqueue v0.2.2
github.com/gammazero/chanqueue v1.0.0
github.com/gammazero/deque v1.0.0
github.com/gogo/protobuf v1.3.2
github.com/google/uuid v1.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7z
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc=
github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc=
github.com/gammazero/channelqueue v0.2.2 h1:ufNzIbeDBxNfHj0m5uwUfOwvTmHF/O40hu2ZNnvF+/8=
github.com/gammazero/channelqueue v0.2.2/go.mod h1:824o5HHE+yO1xokh36BIuSv8YWwXW0364ku91eRMFS4=
github.com/gammazero/chanqueue v1.0.0 h1:FER/sMailGFA3DDvFooEkipAMU+3c9Bg3bheloPSz6o=
github.com/gammazero/chanqueue v1.0.0/go.mod h1:fMwpwEiuUgpab0sH4VHiVcEoji1pSi+EIzeG4TPeKPc=
github.com/gammazero/deque v1.0.0 h1:LTmimT8H7bXkkCy6gZX7zNLtkbz4NdS2z8LZuor3j34=
github.com/gammazero/deque v1.0.0/go.mod h1:iflpYvtGfM3U8S8j+sZEKIak3SAKYpA5/SQewgfXDKo=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
Expand Down

0 comments on commit 1be8e62

Please sign in to comment.