Documentation ¶
Index ¶
- type ConcurrentSlice
- func (s *ConcurrentSlice[T]) Append(val ...T)
- func (s *ConcurrentSlice[T]) Copy() ConcurrentSlice[T]
- func (s *ConcurrentSlice[T]) Get(index int) T
- func (s *ConcurrentSlice[T]) Len() int
- func (cs *ConcurrentSlice[T]) MarshalJSON() ([]byte, error)
- func (s *ConcurrentSlice[T]) Reset()
- func (s *ConcurrentSlice[T]) Set(index int, val T)
- func (cs *ConcurrentSlice[T]) String() string
- func (s *ConcurrentSlice[T]) ToSlice() []T
- func (cs *ConcurrentSlice[T]) UnmarshalJSON(data []byte) error
- type Waker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConcurrentSlice ¶ added in v1.0.0
type ConcurrentSlice[T any] struct { // contains filtered or unexported fields }
ConcurrentSlice is a thread-safe slice.
It is safe to use from multiple goroutines without additional locking. It should be referenced by pointer.
Initialize using NewConcurrentSlice().
func NewConcurrentSlice ¶ added in v1.0.0
func NewConcurrentSlice[T any](initial ...T) *ConcurrentSlice[T]
NewConcurrentSlice creates a new thread-safe slice.
func (*ConcurrentSlice[T]) Append ¶ added in v1.0.0
func (s *ConcurrentSlice[T]) Append(val ...T)
Append adds an element to the slice
func (*ConcurrentSlice[T]) Copy ¶ added in v1.0.0
func (s *ConcurrentSlice[T]) Copy() ConcurrentSlice[T]
Copy returns a new deep copy of concurrentSlice with the same elements
func (*ConcurrentSlice[T]) Get ¶ added in v1.0.0
func (s *ConcurrentSlice[T]) Get(index int) T
Get returns the value at the given index
func (*ConcurrentSlice[T]) Len ¶ added in v1.0.0
func (s *ConcurrentSlice[T]) Len() int
Len returns the length of the slice
func (*ConcurrentSlice[T]) MarshalJSON ¶ added in v1.0.0
func (cs *ConcurrentSlice[T]) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*ConcurrentSlice[T]) Reset ¶ added in v1.0.0
func (s *ConcurrentSlice[T]) Reset()
Reset removes all elements from the slice
func (*ConcurrentSlice[T]) Set ¶ added in v1.0.0
func (s *ConcurrentSlice[T]) Set(index int, val T)
Set updates the value at the given index. If the index is greater than the length of the slice, it panics. If the index is equal to the length of the slice, the value is appended. Otherwise, the value at the index is updated.
func (*ConcurrentSlice[T]) String ¶ added in v1.0.0
func (cs *ConcurrentSlice[T]) String() string
func (*ConcurrentSlice[T]) ToSlice ¶ added in v1.0.0
func (s *ConcurrentSlice[T]) ToSlice() []T
ToSlice returns a copy of the underlying slice
func (*ConcurrentSlice[T]) UnmarshalJSON ¶ added in v1.0.0
func (cs *ConcurrentSlice[T]) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
type Waker ¶
type Waker struct {
// contains filtered or unexported fields
}
Waker is used to wake up a sleeper when some event occurs. It debounces multiple wakeup calls occurring between each sleep, and wakeups are non-blocking to avoid having to coordinate goroutines.