storage_lock_test_helper

package module
v0.0.0-...-294180f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2023 License: MIT Imports: 8 Imported by: 0

README

Storage Lock Test

一、这是什么

用于测试StorageLock的实现是否OK的工具库。

二、安装依赖

go get -u github.com/storage-lock/go-storage-lock-test-helper

三、Example

TODO

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// PlayerNum 有多少个人参与
	PlayerNum = 100

	// EveryOnePlayTimes 参与的每个人都操作多少次
	EveryOnePlayTimes = 100
)

Functions

func BasicTest

func BasicTest[Connection any](t *testing.T, factory *storage_lock_factory.StorageLockFactory[Connection])

BasicTest 锁的基本功能测试

func ConcurrencyTest

func ConcurrencyTest[Connection any](t *testing.T, factory *storage_lock_factory.StorageLockFactory[Connection])

ConcurrencyTest 并发测试

func TestStorageLock

func TestStorageLock[Connection any](t *testing.T, factory *storage_lock_factory.StorageLockFactory[Connection])

TestStorageLock 测试锁

Types

type Counter

type Counter struct {
	// contains filtered or unexported fields
}

Counter 计数器

func NewCounter

func NewCounter() *Counter

func (*Counter) Add

func (x *Counter) Add(n int)

func (*Counter) Close

func (x *Counter) Close()

func (*Counter) Get

func (x *Counter) Get() int

func (*Counter) Wait

func (x *Counter) Wait()

type LockPlayer

type LockPlayer[Connection any] struct {
	// contains filtered or unexported fields
}

LockPlayer 竞争锁的人

func NewLockPlayer

func NewLockPlayer[Connection any](lockId string, factory *storage_lock_factory.StorageLockFactory[Connection]) (*LockPlayer[Connection], error)

func (*LockPlayer[Connection]) Do

func (x *LockPlayer[Connection]) Do(ctx context.Context, f func()) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL