MCPcopy
hub / github.com/SurgeDM/Surge / NewWorkerPool

Function NewWorkerPool

internal/download/pool.go:60–78  ·  view source on GitHub ↗
(progressCh chan<- any, maxDownloads int)

Source from the content-addressed store, hash-verified

58)
59
60func NewWorkerPool(progressCh chan<- any, maxDownloads int) *WorkerPool {
61 if maxDownloads < 1 {
62 maxDownloads = 3 // Default to 3 if invalid
63 }
64 pool := &WorkerPool{
65 taskChan: make(chan string, 100), // We make it buffered to avoid blocking add
66 progressCh: progressCh,
67 progressDone: make(chan struct{}),
68 downloads: make(map[string]*activeDownload),
69 queued: make(map[string]types.DownloadConfig),
70 maxDownloads: maxDownloads,
71 globalLimiter: engine.NewRateLimiter(0, 0),
72 downloadLimiters: make(map[string]*engine.RateLimiter),
73 }
74 for i := 0; i < maxDownloads; i++ {
75 go pool.worker()
76 }
77 return pool
78}
79
80// syncConfigFromState syncs Filename, DestPath, and Mirrors from the associated state.
81func syncConfigFromState(cfg *types.DownloadConfig) {

Calls 2

workerMethod · 0.95
NewRateLimiterFunction · 0.92