syncmap

package
v0.0.0-...-9289bc5 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PropsMap32

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

Map is like a Go map[interface{}]interface{} but is safe for concurrent use by multiple goroutines without additional locking or coordination. Loads, stores, and deletes run in amortized constant time.

The Map type is specialized. Most code should use a plain Go map instead, with separate locking or coordination, for better type safety and to make it easier to maintain other invariants along with the map content.

The Map type is optimized for two common use cases: (1) when the entry for a given key is only ever written once but read many times, as in caches that only grow, or (2) when multiple goroutines read, write, and overwrite entries for disjoint sets of keys. In these two cases, use of a Map may significantly reduce lock contention compared to a Go map paired with a separate Mutex or RWMutex.

The zero Map is empty and ready for use. A Map must not be copied after first use.

func (*PropsMap32) CloneToMap

func (m *PropsMap32) CloneToMap() map[string]int32

func (*PropsMap32) Delete

func (m *PropsMap32) Delete(key string)

Delete deletes the value for a key.

func (*PropsMap32) Load

func (m *PropsMap32) Load(key string) (value int32, ok bool)

Load 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.

func (*PropsMap32) LoadAndDelete

func (m *PropsMap32) LoadAndDelete(key string) (value int32, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.

func (*PropsMap32) LoadOrStore

func (m *PropsMap32) LoadOrStore(key string, value int32) (actual int32, loaded bool)

LoadOrStore 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.

func (*PropsMap32) MarshalJSON

func (m *PropsMap32) MarshalJSON() ([]byte, error)

func (*PropsMap32) Patch

func (m *PropsMap32) Patch(item *types.Item) (err error)

func (*PropsMap32) Range

func (m *PropsMap32) Range(f func(key string, value int32) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

Range may be O(N) with the number of elements in the map even if f returns false after a constant number of calls.

func (*PropsMap32) Store

func (m *PropsMap32) Store(key string, value int32)

Store sets the value for a key.

type PropsMap64

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

Map is like a Go map[interface{}]interface{} but is safe for concurrent use by multiple goroutines without additional locking or coordination. Loads, stores, and deletes run in amortized constant time.

The Map type is specialized. Most code should use a plain Go map instead, with separate locking or coordination, for better type safety and to make it easier to maintain other invariants along with the map content.

The Map type is optimized for two common use cases: (1) when the entry for a given key is only ever written once but read many times, as in caches that only grow, or (2) when multiple goroutines read, write, and overwrite entries for disjoint sets of keys. In these two cases, use of a Map may significantly reduce lock contention compared to a Go map paired with a separate Mutex or RWMutex.

The zero Map is empty and ready for use. A Map must not be copied after first use.

func (*PropsMap64) CloneToMap

func (m *PropsMap64) CloneToMap() map[string]int64

func (*PropsMap64) Delete

func (m *PropsMap64) Delete(key string)

Delete deletes the value for a key.

func (*PropsMap64) Load

func (m *PropsMap64) Load(key string) (value int64, ok bool)

Load 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.

func (*PropsMap64) LoadAndDelete

func (m *PropsMap64) LoadAndDelete(key string) (value int64, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.

func (*PropsMap64) LoadOrStore

func (m *PropsMap64) LoadOrStore(key string, value int64) (actual int64, loaded bool)

LoadOrStore 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.

func (*PropsMap64) MarshalJSON

func (m *PropsMap64) MarshalJSON() ([]byte, error)

func (*PropsMap64) Patch

func (m *PropsMap64) Patch(item *types.Item) (err error)

func (*PropsMap64) Range

func (m *PropsMap64) Range(f func(key string, value int64) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

Range may be O(N) with the number of elements in the map even if f returns false after a constant number of calls.

func (*PropsMap64) Store

func (m *PropsMap64) Store(key string, value int64)

Store sets the value for a key.

type PuzzleCollectionStatus

type PuzzleCollectionStatus struct {
	CompleteRound       int32   `json:"collectionRound,omitempty"`        // 收集完成轮数
	CompleteTime        int64   `json:"complete_time,omitempty"`          // 收集完成时间
	Puzzles             []int32 `json:"collectionPuzzles,omitempty"`      // 收集状态
	LastPuzzlePlayRound int32   `json:"last_puzzle_play_round,omitempty"` // 当收集到最后一个碎片的时候 开始计数,一共玩了多少句 (用于用户收集碎片的补偿值计算 map中的puzzle_game字段)
}

func (*PuzzleCollectionStatus) GetCollectionPuzzleCount

func (p *PuzzleCollectionStatus) GetCollectionPuzzleCount(fragments []int32) int32

type PuzzleMap

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

Map is like a Go map[interface{}]interface{} but is safe for concurrent use by multiple goroutines without additional locking or coordination. Loads, stores, and deletes run in amortized constant time.

The Map type is specialized. Most code should use a plain Go map instead, with separate locking or coordination, for better type safety and to make it easier to maintain other invariants along with the map content.

The Map type is optimized for two common use cases: (1) when the entry for a given key is only ever written once but read many times, as in caches that only grow, or (2) when multiple goroutines read, write, and overwrite entries for disjoint sets of keys. In these two cases, use of a Map may significantly reduce lock contention compared to a Go map paired with a separate Mutex or RWMutex.

The zero Map is empty and ready for use. A Map must not be copied after first use.

func (*PuzzleMap) CloneToMap

func (m *PuzzleMap) CloneToMap() map[string]*PuzzleCollectionStatus

func (*PuzzleMap) Delete

func (m *PuzzleMap) Delete(key string)

Delete deletes the value for a key.

func (*PuzzleMap) Load

func (m *PuzzleMap) Load(key string) (value *PuzzleCollectionStatus, ok bool)

Load 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.

func (*PuzzleMap) LoadAndDelete

func (m *PuzzleMap) LoadAndDelete(key string) (value *PuzzleCollectionStatus, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.

func (*PuzzleMap) LoadOrStore

func (m *PuzzleMap) LoadOrStore(key string, value *PuzzleCollectionStatus) (actual *PuzzleCollectionStatus, loaded bool)

LoadOrStore 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.

func (*PuzzleMap) MarshalJSON

func (m *PuzzleMap) MarshalJSON() ([]byte, error)

func (*PuzzleMap) Patch

func (m *PuzzleMap) Patch(item *types.Item) (err error)

func (*PuzzleMap) Range

func (m *PuzzleMap) Range(f func(key string, value *PuzzleCollectionStatus) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

Range may be O(N) with the number of elements in the map even if f returns false after a constant number of calls.

func (*PuzzleMap) Store

func (m *PuzzleMap) Store(key string, value *PuzzleCollectionStatus)

Store sets the value for a key.

Jump to

Keyboard shortcuts

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