summaryrefslogtreecommitdiffstats
path: root/vendor/gopkg.in/ldap.v2/atomic_value_go13.go
blob: 04920bb2600ca592642b5a30c9cd498f02e33e98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// +build !go1.4

package ldap

import (
	"sync"
)

// This is a helper type that emulates the use of the "sync/atomic.Value"
// struct that's available in Go 1.4 and up.
type atomicValue struct {
	value interface{}
	lock  sync.RWMutex
}

func (av *atomicValue) Store(val interface{}) {
	av.lock.Lock()
	av.value = val
	av.lock.Unlock()
}

func (av *atomicValue) Load() interface{} {
	av.lock.RLock()
	ret := av.value
	av.lock.RUnlock()

	return ret
}