Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for NewUnbounded (0.24 sec)

  1. pkg/channels/unbounded_test.go

    		}
    	}
    }
    
    // TestSingleWriter starts one reader and one writer goroutine and makes sure
    // that the reader gets all the value added to the buffer by the writer.
    func TestSingleWriter(t *testing.T) {
    	ub := NewUnbounded[int]()
    	reads := []int{}
    
    	var wg sync.WaitGroup
    	wg.Add(1)
    	go func() {
    		defer wg.Done()
    		ch := ub.Get()
    		for i := 0; i < numWriters*numWrites; i++ {
    			r := <-ch
    			reads = append(reads, r)
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Wed Aug 31 19:53:39 UTC 2022
    - 2.3K bytes
    - Viewed (0)
  2. pkg/channels/unbounded.go

    // internal/transport/transport.go for an example of this.
    type Unbounded[T any] struct {
    	c       chan T
    	mu      sync.Mutex
    	backlog []T
    }
    
    // NewUnbounded returns a new instance of Unbounded.
    func NewUnbounded[T any]() *Unbounded[T] {
    	return &Unbounded[T]{c: make(chan T, 1)}
    }
    
    // Put adds t to the unbounded buffer.
    // Put will never block
    func (b *Unbounded[T]) Put(t T) {
    	b.mu.Lock()
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Wed Aug 31 19:53:39 UTC 2022
    - 2.8K bytes
    - Viewed (0)
Back to top