From 1be8e62045883db7440a57435669be549e042b6a Mon Sep 17 00:00:00 2001 From: gammazero <11790789+gammazero@users.noreply.github.com> Date: Sun, 24 Nov 2024 04:03:48 -1000 Subject: [PATCH] use chanqueue for unbounded channel --- .../internal/providerquerymanager/providerquerymanager.go | 8 ++++---- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bitswap/client/internal/providerquerymanager/providerquerymanager.go b/bitswap/client/internal/providerquerymanager/providerquerymanager.go index c5994e4fe..19a099c76 100644 --- a/bitswap/client/internal/providerquerymanager/providerquerymanager.go +++ b/bitswap/client/internal/providerquerymanager/providerquerymanager.go @@ -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" @@ -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 @@ -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() { diff --git a/go.mod b/go.mod index 9a0c8dc66..292fbb95a 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 566acffd2..2e41a5014 100644 --- a/go.sum +++ b/go.sum @@ -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=