Skip to content

cloudxaas/golock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

88833b4 · Apr 7, 2024

History

14 Commits
Apr 6, 2024
Apr 7, 2024
Apr 6, 2024
Apr 6, 2024

Repository files navigation

usage

package main

import (
	"fmt"
	cxlockrw "github.com/cloudxaas/golock/rw"
	"runtime"
)

func main() {
	numShards := runtime.NumCPU() * 64
	lock := cxlockrw.NewShardedRWLock(numShards)
	defer lock.Close()

	// Example usage of the sharded read-write lock
	key := "exampleKey"
	lock.RLock(key)
	fmt.Println("Read operation under RLock")
	lock.RUnlock(key)

	lock.Lock(key)
	fmt.Println("Write operation under Lock")
	lock.Unlock(key)
}

About

Global sharded rw lock using cgo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages