gambit/helper/mutex.go

43 lines
585 B
Go
Raw Normal View History

2023-07-05 22:22:48 +00:00
package helper
import (
"sync"
"tuxpa.in/a/gambit"
)
type Sync struct {
gambit.Bandit
mu sync.RWMutex
}
func (s *Sync) Select(r float64) int {
s.mu.Lock()
defer s.mu.Unlock()
return s.Select(r)
}
func (s *Sync) Update(a int, r float64) error {
s.mu.Lock()
defer s.mu.Unlock()
return s.Update(a, r)
}
func (s *Sync) Reset(n int) error {
s.mu.Lock()
defer s.mu.Unlock()
return s.Reset(n)
}
func (s *Sync) Count(res *[]int) {
s.mu.Lock()
defer s.mu.Unlock()
s.Count(res)
}
func (s *Sync) Reward(res *[]float64) {
s.mu.Lock()
defer s.mu.Unlock()
s.Reward(res)
}