refactor: use time.Ticker

This commit is contained in:
Derrick Hammer 2024-01-20 11:16:54 -05:00
parent ea4a22c52d
commit 43c4590439
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 6 additions and 2 deletions

View File

@ -80,13 +80,17 @@ func (l *Lock) Lock(ctx context.Context, requestUnlock func()) error {
} }
go func() { go func() {
ticker := time.NewTicker(l.holderPollInterval)
defer ticker.Stop()
for { for {
select { select {
case <-l.stopHolderPoll: case <-l.stopHolderPoll:
return return
case <-time.After(l.holderPollInterval): case <-ticker.C:
requested, err := l.lockRecord.IsReleaseRequested(db) requested, err := l.lockRecord.IsReleaseRequested(db)
if err == nil { if err != nil {
// Handle error
continue continue
} }