package upgrader

import (
	
)

func newThreshold( int) *threshold {
	 := &threshold{
		threshold: ,
	}
	.cond.L = &.mu
	return 
}

type threshold struct {
	mu   sync.Mutex
	cond sync.Cond

	count     int
	threshold int
}

// Acquire increments the counter. It will not block.
func ( *threshold) () {
	.mu.Lock()
	.count++
	.mu.Unlock()
}

// Release decrements the counter.
func ( *threshold) () {
	.mu.Lock()
	if .count == 0 {
		panic("negative count")
	}
	if .threshold == .count {
		.cond.Broadcast()
	}
	.count--
	.mu.Unlock()
}

// Wait waits for the counter to drop below the threshold
func ( *threshold) () {
	.mu.Lock()
	for .count >= .threshold {
		.cond.Wait()
	}
	.mu.Unlock()
}