Use go functions instead of the worker pool

This commit is contained in:
Ben Sarmiento
2024-02-07 13:39:13 +01:00
parent d1b4158c96
commit 0eeb295c23
2 changed files with 4 additions and 4 deletions

View File

@@ -107,7 +107,7 @@ func (t *TorrentManager) refreshTorrents(isInitialRun bool) []string {
// StartRefreshJob periodically refreshes the torrents // StartRefreshJob periodically refreshes the torrents
func (t *TorrentManager) StartRefreshJob() { func (t *TorrentManager) StartRefreshJob() {
_ = t.workerPool.Submit(func() { go func() {
t.log.Info("Starting periodic refresh job") t.log.Info("Starting periodic refresh job")
refreshTicker := time.NewTicker(time.Duration(t.Config.GetRefreshEverySecs()) * time.Second) refreshTicker := time.NewTicker(time.Duration(t.Config.GetRefreshEverySecs()) * time.Second)
defer refreshTicker.Stop() defer refreshTicker.Stop()
@@ -131,7 +131,7 @@ func (t *TorrentManager) StartRefreshJob() {
return return
} }
} }
}) }()
} }
// getMoreInfo gets original name, size and files for a torrent // getMoreInfo gets original name, size and files for a torrent

View File

@@ -25,7 +25,7 @@ func (t *TorrentManager) StartRepairJob() {
t.repairTrigger = make(chan *Torrent) t.repairTrigger = make(chan *Torrent)
t.repairSet = mapset.NewSet[*Torrent]() t.repairSet = mapset.NewSet[*Torrent]()
// there is 1 repair worker, with max 1 blocking task // there is 1 repair worker, with max 1 blocking task
_ = t.workerPool.Submit(func() { go func() {
t.log.Info("Starting periodic repair job") t.log.Info("Starting periodic repair job")
repairTicker := time.NewTicker(time.Duration(t.Config.GetRepairEveryMins()) * time.Minute) repairTicker := time.NewTicker(time.Duration(t.Config.GetRepairEveryMins()) * time.Minute)
defer repairTicker.Stop() defer repairTicker.Stop()
@@ -42,7 +42,7 @@ func (t *TorrentManager) StartRepairJob() {
return return
} }
} }
}) }()
} }
func (t *TorrentManager) invokeRepair(torrent *Torrent) { func (t *TorrentManager) invokeRepair(torrent *Torrent) {