Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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.