Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Locker ¶ added in v0.2.39
type Locker struct {
// contains filtered or unexported fields
}
Locker is a struct that represents a locker.
func NewLocker ¶ added in v0.2.39
NewLocker creates a new Locker with the given condition.
Parameters:
- cond: The condition of the locker.
Returns:
- *Locker: A pointer to the new Locker.
func (*Locker) ModifyCond ¶ added in v0.2.39
ModifyCond modifies the condition of the locker.
Parameters:
- cond: The new condition of the locker.
func (*Locker) WaitForCond ¶ added in v0.2.39
func (l *Locker) WaitForCond(do uc.RoutineFunc)
WaitForCond waits for the condition of the locker to be true.
Parameters:
- do: The function to execute when the condition is true.
type RWSafe ¶
type RWSafe[T any] struct { // contains filtered or unexported fields }
RWSafe is a thread-safe, generic data structure that allows multiple goroutines to read and write to a value in a synchronized manner.
func NewRWSafe ¶
NewRWSafe is a function that creates and returns a new instance of a RWSafe.
Parameters:
- value: The initial value to be stored in the RWSafe.
Returns:
- *RWSafe[T]: A pointer to the newly created RWSafe.
func (*RWSafe[T]) DoRead ¶
func (rw *RWSafe[T]) DoRead(f func(T))
DoRead is a method of the RWSafe type. It is used to perform a read operation on the value stored in the RWSafe. Through the function parameter, the caller can access the value in a read-only manner.
Parameters:
- f: A function that takes a value of type T as a parameter and returns nothing.
func (*RWSafe[T]) DoWrite ¶
func (rw *RWSafe[T]) DoWrite(f func(T))
DoWrite is a method of the RWSafe type. It is used to perform a write operation on the value stored in the RWSafe. Through the function parameter, the caller can access the value in a read-write manner.
Parameters:
- f: A function that takes a pointer to a value of type T as a parameter and returns nothing.