Skip to content

Commit

Permalink
factor out some more code
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleSanderson authored Nov 24, 2024
1 parent f790c4a commit 0986608
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,11 @@ func (c *upgradereq) getAllTorrents() (*timeentry, error) {

var te ttlcache.Item[*timeentry]
var val *timeentry
resetOrRun := func() *sync.RWMutex {

err := GetOrUpdate(func() *sync.RWMutex {
te = getOrInitialize()
val = te.GetValue()
return &val.m
}

resetOrRun()
err := GetOrUpdate(func() *sync.RWMutex {
return resetOrRun()
}, func() bool {
return val.e != nil
}, func() error {
Expand Down

0 comments on commit 0986608

Please sign in to comment.