MCPcopy Create free account
hub / github.com/Code-Hex/pget / newDialRateLimiter

Function newDialRateLimiter

client.go:44–53  ·  view source on GitHub ↗
(dialer *net.Dialer)

Source from the content-addressed store, hash-verified

42}
43
44func newDialRateLimiter(dialer *net.Dialer) *dialRateLimiter {
45 // exact value doesn't matter too much, but too low will be too slow,
46 // and too high will reduce the beneficial effect on thread count
47 const concurrentDialsPerCpu = 10
48
49 return &dialRateLimiter{
50 dialer: dialer,
51 sem: make(chan struct{}, concurrentDialsPerCpu*runtime.NumCPU()),
52 }
53}
54
55func (d *dialRateLimiter) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
56 d.sem <- struct{}{}

Callers 1

newDownloadClientFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected