Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func (b *Batcher) Load() interface{} {
- b.mu.Lock()
- defer b.mu.Unlock()
- if !b.first {
- b.con.Wait()
- if !b.second {
- b.con.Wait()
- }
- b.second = false
- b.value = b.valueSlow.Load()
- b.first = true
- b.con.Broadcast()
- }
- b.first = false
- b.mu.Unlock()
- b.value = b.valueSlow.Load()
- b.mu.Lock()
- b.second = true
- b.con.Broadcast()
- b.first = true
- return b.value
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement