moreatomic

package
v2.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2021 License: ISC Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool struct {
	// contains filtered or unexported fields
}

func (*Bool) Get

func (b *Bool) Get() bool

func (*Bool) Set

func (b *Bool) Set(val bool)

type CtxMutex

type CtxMutex struct {
	// contains filtered or unexported fields
}

func NewCtxMutex

func NewCtxMutex() *CtxMutex

func (*CtxMutex) Lock

func (m *CtxMutex) Lock(ctx context.Context) error

func (*CtxMutex) TryUnlock

func (m *CtxMutex) TryUnlock() bool

TryUnlock returns true if the mutex has been unlocked.

func (*CtxMutex) Unlock

func (m *CtxMutex) Unlock()

type Int64

type Int64 int64

func NewInt64

func NewInt64(v int64) *Int64

func (*Int64) Get

func (i *Int64) Get() int64

func (*Int64) Set

func (i *Int64) Set(v int64)

type Map

type Map struct {
	// contains filtered or unexported fields
}

Map is a thread-safe map that is a wrapper around sync.Map with slight API additions.

func NewMap

func NewMap(ctor func() interface{}) *Map

func (*Map) Load

func (sm *Map) Load(k interface{}) (lv interface{}, ok bool)

Load loads an existing value; it returns ok set to false if there is no value with that key.

func (*Map) LoadOrStore

func (sm *Map) LoadOrStore(k interface{}) (lv interface{}, loaded bool)

LoadOrStore loads an existing value or stores a new value created from the given constructor then return that value.

func (*Map) Reset

func (sm *Map) Reset() error

Reset swaps the internal map out with a fresh one, dropping the old map. This method never errors.

type Snowflake

type Snowflake int64

func (*Snowflake) Get

func (s *Snowflake) Get() discord.Snowflake

func (*Snowflake) Set

func (s *Snowflake) Set(id discord.Snowflake)

type SnowflakeSet

type SnowflakeSet struct {
	// contains filtered or unexported fields
}

func NewSnowflakeSet

func NewSnowflakeSet() *SnowflakeSet

NewSnowflakeSet creates a new SnowflakeSet.

func (*SnowflakeSet) Add

func (s *SnowflakeSet) Add(flake discord.Snowflake)

Add adds the passed discord.Snowflake to the set.

func (*SnowflakeSet) Contains

func (s *SnowflakeSet) Contains(flake discord.Snowflake) (ok bool)

Contains checks whether the passed discord.Snowflake is present in the set.

func (*SnowflakeSet) Delete

func (s *SnowflakeSet) Delete(flake discord.Snowflake) bool

Delete deletes the passed discord.Snowflake from the set and returns true if the element is present. If not, Delete is a no-op and returns false.

type String

type String struct {
	// contains filtered or unexported fields
}

func (*String) Get

func (s *String) Get() string

func (*String) Set

func (s *String) Set(str string)

type Time

type Time struct {
	// contains filtered or unexported fields
}

func Now

func Now() *Time

func (*Time) Get

func (t *Time) Get() time.Time

func (*Time) HasBeen

func (t *Time) HasBeen(dura time.Duration) bool

HasBeen checks if it has been this long since the last time. If yes, it will set the time.

func (*Time) Set

func (t *Time) Set(time time.Time)

Directories

Path Synopsis
Package syncmod contains a clone of package sync's map.go file with unused methods removed and some tweaks with LoadOrStore.
Package syncmod contains a clone of package sync's map.go file with unused methods removed and some tweaks with LoadOrStore.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL