49 lines
665 B
Go
49 lines
665 B
Go
package algo
|
|
|
|
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)
|
|
}
|
|
|
|
func (s *Sync) Size() int {
|
|
s.mu.Lock()
|
|
defer s.mu.Unlock()
|
|
return s.Size()
|
|
}
|