You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

29 lines
533 B

package manager
import (
"sync/atomic"
"github.com/gotd/td/tg"
)
// AtomicConfig is atomic tg.Config.
type AtomicConfig struct {
atomic.Value
}
// NewAtomicConfig creates new AtomicConfig.
func NewAtomicConfig(cfg tg.Config) *AtomicConfig {
a := &AtomicConfig{}
a.Store(cfg)
return a
}
// Load loads atomically config and returns it.
func (c *AtomicConfig) Load() tg.Config {
return c.Value.Load().(tg.Config)
}
// Store saves given config atomically.
func (c *AtomicConfig) Store(cfg tg.Config) {
c.Value.Store(cfg)
}