Documentation
¶
Index ¶
- type Map
- func (m *Map[K, V]) Borrow(key K) (ptr *V, release func(), ok bool)
- func (m *Map[K, V]) BorrowWithInit(key K, init func() V) (ptr *V, release func())
- func (m *Map[K, V]) Del(key K)
- func (m *Map[K, V]) Get(key K) V
- func (m *Map[K, V]) GetOrInit(key K, init func() V) V
- func (m *Map[K, V]) Keys() []K
- func (m *Map[K, V]) Len() int
- func (m *Map[K, V]) Lookup(key K) (V, bool)
- func (m *Map[K, V]) Reset()
- func (m *Map[K, V]) Set(key K, val V)
- type RWLocker
- type RWLockerFactory
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶ added in v0.261.0
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Example ¶
package main import ( "go.llib.dev/frameless/pkg/synckit" ) func main() { var m synckit.Map[string, int] m.Set("foo", 42) // 42 set for "foo" key m.Get("foo") // -> 42 m.Lookup("foo") // -> 42, true m.Lookup("bar") // -> 0, false if ptr, release, ok := m.Borrow("foo"); ok { // the value of "foo" is borrowed *ptr = 24 release() } m.Reset() // map is cleared m.GetOrInit("foo", func() int { // -> 42 return 42 }) }
func (*Map[K, V]) BorrowWithInit ¶ added in v0.261.0
func (m *Map[K, V]) BorrowWithInit(key K, init func() V) (ptr *V, release func())
type RWLockerFactory ¶
type RWLockerFactory[K comparable] struct { // ReadOptimised will make RLocker and rsync perform much faster, // at the expense of having a global read locking when a read lock is made before a write locking. // This cause a side effect that acquiring write locks for other keys will hang until the read operation is done. // // In the end, this shortcut leads to a whopping <350% increase in read operation speed, // while also supporting write operations as well. // However, it causes only a 0.17% decrease in write speed performance. ReadOptimised bool // contains filtered or unexported fields }
func (*RWLockerFactory[K]) RWLocker ¶
func (l *RWLockerFactory[K]) RWLocker(key K) RWLocker
Click to show internal directories.
Click to hide internal directories.