Skip to content

Commit 6f6594b

Browse files
authored
Create README.md
1 parent c194378 commit 6f6594b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
usage
2+
```
3+
package main
4+
5+
import (
6+
"fmt"
7+
cxlockrw "github.com/cloudxaas/golock/rw"
8+
"runtime"
9+
)
10+
11+
func main() {
12+
numShards := runtime.NumCPU() * 64
13+
lock := cxlockrw.NewShardedRWLock(numShards)
14+
defer lock.Close()
15+
16+
// Example usage of the sharded read-write lock
17+
key := "exampleKey"
18+
lock.RLock(key)
19+
fmt.Println("Read operation under RLock")
20+
lock.RUnlock(key)
21+
22+
lock.Lock(key)
23+
fmt.Println("Write operation under Lock")
24+
lock.Unlock(key)
25+
}
26+
```

0 commit comments

Comments
 (0)