- Sort Score
- Num 10 results
- Language All
Results 1 - 1 of 1 for NewSingleton (0.57 seconds)
-
internal/once/singleton.go
package once // Singleton contains a pointer to T that must be set once. // Until the value is set all Get() calls will block. type Singleton[T any] struct { v *T set chan struct{} } // NewSingleton creates a new unset singleton. func NewSingleton[T any]() *Singleton[T] { return &Singleton[T]{set: make(chan struct{}), v: nil} } // Get will return the singleton value. func (s *Singleton[T]) Get() *T { <-s.set return s.v }
Created: Sun Apr 05 19:28:12 GMT 2026 - Last Modified: Thu Aug 15 12:04:40 GMT 2024 - 952 bytes - Click Count (0)