File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ # Sync-Generic
2+
3+ A Go package providing generic wrappers around standard library synchronization primitives.
4+
5+ - Type safety at compile time
6+ - No need for type assertions in your code
7+ - Full API compatibility with standard library
8+
9+ ## Features
10+
11+ - ` Pool[T] ` - Type-safe generic wrapper for ` sync.Pool `
12+ - ` Map[K, V] ` - Type-safe generic wrapper for ` sync.Map `
13+
14+ ## Usage
15+
16+ ``` go
17+ // Pool example
18+ func _ () {
19+ pool := new (sync.Pool [[]byte ]).New (func () []byte { return make ([]byte , 1024 ) })
20+ buffer := pool.Get ()
21+ defer pool.Put (buffer)
22+ // use buffer
23+ }
24+ ```
25+
26+ ``` go
27+ // Map example
28+ func _ () {
29+ cache := new (sync.Map [string , int ])
30+ value , ok := cache.LoadOrStore (" count" , 42 )
31+ }
32+ ```
You can’t perform that action at this time.
0 commit comments