{"modulePath":"github.com/plgd-dev/kit","version":"v0.0.0-20210614190235-99984a49de48","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package sync\n\n## Types\n\n```go\ntype Map struct {\n\t// contains filtered or unexported fields\n}\n```\nMap is like a Go map\\[interface{}]interface{} but is safe for concurrent use by multiple goroutines.\n\n```go\nfunc NewMap() *Map\n```\nNewMap creates map.\n\n```go\nfunc (m *Map) Delete(key interface{})\n```\nDelete deletes the value for a key.\n\n```go\nfunc (m *Map) DeleteWithFunc(key interface{}, onDeleteFunc func(value interface{}))\n```\n\n```go\nfunc (m *Map) Length() int\n```\nLength returns number of stored values.\n\n```go\nfunc (m *Map) Load(key interface{}) (value interface{}, ok bool)\n```\nLoad returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.\n\n```go\nfunc (m *Map) LoadOrStore(key, value interface{}) (actual interface{}, loaded bool)\n```\nLoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.\n\n```go\nfunc (m *Map) LoadOrStoreWithFunc(key interface{}, onLoadFunc func(value interface{}) interface{}, createFunc func() interface{}) (actual interface{}, loaded bool)\n```\n\n```go\nfunc (m *Map) LoadWithFunc(key interface{}, onLoadFunc func(value interface{}) interface{}) (value interface{}, ok bool)\n```\n\n```go\nfunc (m *Map) PullOut(key interface{}) (value interface{}, ok bool)\n```\nPullOut loads and deletes the value for a key.\n\n```go\nfunc (m *Map) PullOutAll() (data map[interface{}]interface{})\n```\nPullOutAll extracts internal map data and replace it with empty map.\n\n```go\nfunc (m *Map) PullOutWithFunc(key interface{}, onLoadFunc func(value interface{}) interface{}) (value interface{}, ok bool)\n```\n\n```go\nfunc (m *Map) Range(f func(key, value interface{}) bool)\n```\nRange calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.\n\n```go\nfunc (m *Map) Replace(key, value interface{}) (oldValue interface{}, oldLoaded bool)\n```\nReplace replaces the existing value with a new value and returns old value for the key.\n\n```go\nfunc (m *Map) ReplaceWithFunc(key interface{}, onReplaceFunc func(oldValue interface{}, oldLoaded bool) (newValue interface{}, delete bool)) (oldValue interface{}, oldLoaded bool)\n```\n\n```go\nfunc (m *Map) Store(key, value interface{})\n```\nStore sets the value for a key.\n\n```go\nfunc (m *Map) StoreWithFunc(key interface{}, createFunc func() interface{})\n```\n\n```go\ntype Once struct {\n\t// contains filtered or unexported fields\n}\n```\nOnce performs exactly one action. See sync.Once for more details.\n\n```go\nfunc (o *Once) Done() bool\n```\nDone returns true after Try executes succesfully.\n\n```go\nfunc (o *Once) Try(f func() bool)\n```\nTry executes the function f exactly once for this instance of Once. If the function f returns false, it enables further execution attempts.\n\n```go\ntype Pool struct {\n\t// contains filtered or unexported fields\n}\n```\nPool is a synchronized key-value store with customizable factory for missing items.\n\n```go\nfunc NewPool() *Pool\n```\nNewPool creates a pool.\n\n```go\nfunc (p *Pool) Delete(key string) (_ interface{}, ok bool)\n```\nDelete pops an item from the pool or false.\n\n```go\nfunc (p *Pool) Get(key string) (_ interface{}, ok bool)\n```\nGet returns an item from the pool or false.\n\n```go\nfunc (p *Pool) GetOrCreate(ctx context.Context, key string) (interface{}, error)\n```\nGetOrCreate returns an item and calls the factory on a mis. Warning: The factory function is called under the lock, therefore it must not call any Pool's methods to avoid deadlocks.\n\n```go\nfunc (p *Pool) Put(key string, item interface{})\n```\nPut adds an item to the pool.\n\n```go\nfunc (p *Pool) SetFactory(f PoolFunc)\n```\nSetFactory sets the pool factory for GetOrCreate.\n\n```go\ntype PoolFunc func(ctx context.Context, key string) (interface{}, error)\n```\nPoolFunc is triggered on a miss by GetOrCreate, so that it may add the missing item to the pool.\n\n```go\ntype RefCounter struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewRefCounter(data interface{}, releaseDataFunc ReleaseDataFunc) *RefCounter\n```\nNewRefCounter creates RefCounter\n\n```go\nfunc (r *RefCounter) Acquire()\n```\nAcquire increments counter\n\n```go\nfunc (r *RefCounter) Count() int64\n```\nCount returns current counter value.\n\n```go\nfunc (r *RefCounter) Data() interface{}\n```\nData returns data\n\n```go\nfunc (r *RefCounter) Release(ctx context.Context) error\n```\nRelease decrements counter, when counter reach 0, releaseDataFunc will be called\n\n```go\ntype ReleaseDataFunc = func(ctx context.Context, data interface{}) error\n```\n\n","path":"github.com/plgd-dev/kit/sync","name":"sync","synopsis":"","isRedistributable":true}
