Documentation
¶
Overview ¶
Package syncrand provides synchronized (thread-safe) wrappers of "math/rand".Source64 and "math/rand".Rand.
Index ¶
- func Global() *rand.Rand
- func GlobalSource() rand.Source64
- func IsThreadSafe(source rand.Source64) bool
- func New(seed int64) *rand.Rand
- func NewFromSource(source rand.Source64) *rand.Rand
- func NewSource(seed int64) rand.Source64
- func SetGlobalSource(source rand.Source64)
- func WrapSource(source rand.Source64) rand.Source64
- type WrappedSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Global ¶
Global returns this package's global instance of Rand. It is guaranteed to be thread-safe.
func GlobalSource ¶
GlobalSource returns this package's global instance of Source64, which backs the Rand returned by Global(). It is guaranteed to be thread-safe.
func IsThreadSafe ¶ added in v0.4.2
IsThreadSafe returns true if its argument is known to be thread-safe.
func NewFromSource ¶
NewFromSource returns a new Rand that is backed by the given source. It is guaranteed to be thread-safe.
func NewSource ¶
NewSource returns a new Source64 that is seeded with the given seed. It is guaranteed to be thread-safe.
func SetGlobalSource ¶
SetGlobalSource atomically replaces the global instance of Source64 with the provided one. If it is not thread-safe, then it is wrapped in an implementation of WrappedSource that _is_ thread-safe.