-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: add transfer_ticket. Refactoring: receiver
- Loading branch information
1 parent
5259b08
commit 89b577c
Showing
18 changed files
with
225 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package indexer | ||
|
||
import "sync" | ||
|
||
// Map - | ||
type Map[K comparable, V any] struct { | ||
m map[K]V | ||
mx *sync.RWMutex | ||
} | ||
|
||
// NewMap - | ||
func NewMap[K comparable, V any]() Map[K, V] { | ||
return Map[K, V]{ | ||
m: make(map[K]V), | ||
mx: new(sync.RWMutex), | ||
} | ||
} | ||
|
||
// Set - | ||
func (m Map[K, V]) Set(key K, value V) { | ||
m.mx.Lock() | ||
m.m[key] = value | ||
m.mx.Unlock() | ||
} | ||
|
||
// Get - | ||
func (m Map[K, V]) Get(key K) (V, bool) { | ||
m.mx.RLock() | ||
value, ok := m.m[key] | ||
m.mx.RUnlock() | ||
return value, ok | ||
} | ||
|
||
// Exists - | ||
func (m Map[K, V]) Exists(key K) bool { | ||
m.mx.RLock() | ||
_, ok := m.m[key] | ||
m.mx.RUnlock() | ||
return ok | ||
} | ||
|
||
// Delete - | ||
func (m Map[K, V]) Delete(key K) { | ||
m.mx.Lock() | ||
delete(m.m, key) | ||
m.mx.Unlock() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.