"golang.org/x/time/rate"
"golang.org/x/xerrors"
+ "github.com/anacrolix/chansync"
+
"github.com/anacrolix/torrent/bencode"
- "github.com/anacrolix/torrent/internal/chansync"
"github.com/anacrolix/torrent/internal/limiter"
"github.com/anacrolix/torrent/iplist"
"github.com/anacrolix/torrent/metainfo"
if err != nil {
panic(err)
}
- cl.dhtServers = append(cl.dhtServers, anacrolixDhtServerWrapper{ds})
+ cl.dhtServers = append(cl.dhtServers, AnacrolixDhtServerWrapper{ds})
cl.onClose = append(cl.onClose, func() { ds.Close() })
}
}
}
}
+func (cl *Client) Listeners() []Listener {
+ return cl.listeners
+}
+
// Registers a Listener, and starts Accepting on it. You must Close Listeners provided this way
// yourself.
func (cl *Client) AddListener(l Listener) {
crawshaw.io/sqlite v0.3.3-0.20210127221821-98b1f83c5508
github.com/RoaringBitmap/roaring v0.6.0 // indirect
github.com/alexflint/go-arg v1.3.0
+ github.com/anacrolix/chansync v0.0.0-20210524073341-a336ebc2de92 // indirect
github.com/anacrolix/confluence v1.7.1-0.20210311004351-d642adb8546c // indirect
github.com/anacrolix/dht/v2 v2.9.1
github.com/anacrolix/envpprof v1.1.1
github.com/alexflint/go-arg v1.3.0/go.mod h1:9iRbDxne7LcR/GSvEr7ma++GLpdIU1zrghf2y2768kM=
github.com/alexflint/go-scalar v1.0.0 h1:NGupf1XV/Xb04wXskDFzS0KWOLH632W/EO4fAFi+A70=
github.com/alexflint/go-scalar v1.0.0/go.mod h1:GpHzbCOZXEKMEcygYQ5n/aa4Aq84zbxjy3MxYW0gjYw=
+github.com/anacrolix/chansync v0.0.0-20210524073341-a336ebc2de92 h1:WGk37RyXPWcIALJxTkTNrXN3yLQp7hSFa3x5GkrK/Rs=
+github.com/anacrolix/chansync v0.0.0-20210524073341-a336ebc2de92/go.mod h1:DZsatdsdXxD0WiwcGl0nJVwyjCKMDv+knl1q2iBjA2k=
github.com/anacrolix/confluence v1.7.1-0.20210221224747-9cb14aa2c53a/go.mod h1:T0JHvSaf9UfoiUdCtCOUuRroHm/tauUJTbLc6/vd5YA=
github.com/anacrolix/confluence v1.7.1-0.20210221225853-90405640e928/go.mod h1:NoLcfoRet+kYttjLXJRmh4qBVrylJsfIItik5GGj21A=
github.com/anacrolix/confluence v1.7.1-0.20210311004351-d642adb8546c h1:HfbeiZS/0hwdotwtQhllrd3PagmuLgCN9O8CHJgzPGQ=
+++ /dev/null
-package chansync
-
-import (
- "github.com/anacrolix/sync"
-)
-
-// Can be used as zero-value. Due to the caller needing to bring their own synchronization, an
-// eqiuvalent to "sync".Cond.Signal is not provided. BroadcastCond is intended to be selected on
-// with other channels.
-type BroadcastCond struct {
- mu sync.Mutex
- ch chan struct{}
-}
-
-func (me *BroadcastCond) Broadcast() {
- me.mu.Lock()
- defer me.mu.Unlock()
- if me.ch != nil {
- close(me.ch)
- me.ch = nil
- }
-}
-
-// Should be called before releasing locks on resources that might trigger subsequent Broadcasts.
-// The channel is closed when the condition changes.
-func (me *BroadcastCond) Signaled() Signaled {
- me.mu.Lock()
- defer me.mu.Unlock()
- if me.ch == nil {
- me.ch = make(chan struct{})
- }
- return me.ch
-}
+++ /dev/null
-package chansync
-
-// Here we'll strongly-type channels to assist correct usage, if possible.
-
-type (
- Signaled <-chan struct{}
- Done <-chan struct{}
-)
+++ /dev/null
-package chansync
-
-import "sync"
-
-// SetOnce is a boolean value that can only be flipped from false to true.
-type SetOnce struct {
- ch chan struct{}
- initOnce sync.Once
- closeOnce sync.Once
-}
-
-// Returns a channel that is closed when the event is flagged.
-func (me *SetOnce) Done() Done {
- me.init()
- return me.ch
-}
-
-func (me *SetOnce) init() {
- me.initOnce.Do(func() {
- me.ch = make(chan struct{})
- })
-}
-
-// Set only returns true the first time it is called.
-func (me *SetOnce) Set() (first bool) {
- me.closeOnce.Do(func() {
- me.init()
- first = true
- close(me.ch)
- })
- return
-}
-
-func (me *SetOnce) IsSet() bool {
- me.init()
- select {
- case <-me.ch:
- return true
- default:
- return false
- }
-}
"io"
"time"
+ "github.com/anacrolix/chansync"
"github.com/anacrolix/log"
"github.com/anacrolix/sync"
- "github.com/anacrolix/torrent/internal/chansync"
pp "github.com/anacrolix/torrent/peer_protocol"
)
"github.com/anacrolix/missinggo/v2/prioritybitmap"
"github.com/anacrolix/multiless"
+ "github.com/anacrolix/chansync"
"github.com/anacrolix/torrent/bencode"
- "github.com/anacrolix/torrent/internal/chansync"
"github.com/anacrolix/torrent/metainfo"
"github.com/anacrolix/torrent/mse"
pp "github.com/anacrolix/torrent/peer_protocol"
"github.com/anacrolix/missinggo/v2/bitmap"
- "github.com/anacrolix/torrent/internal/chansync"
+ "github.com/anacrolix/chansync"
request_strategy "github.com/anacrolix/torrent/request-strategy"
"github.com/anacrolix/torrent/types"
)