Skip to content

Commit d70f9e1

Browse files
committed
docs: add README
1 parent f83b96f commit d70f9e1

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
```

0 commit comments

Comments
 (0)