package tdsync

import (
	
)

// Ready is simple signal primitive which sends signal once.
// This is not allowed to use zero value.
type Ready struct {
	wait chan struct{}
	done int32
}

// NewReady creates new Ready.
func () *Ready {
	return &Ready{
		wait: make(chan struct{}),
	}
}

func ( *Ready) () {
	.wait = make(chan struct{})
	atomic.StoreInt32(&.done, 0)
}

// Signal sends ready signal.
// Can be called multiple times.
func ( *Ready) () {
	if atomic.CompareAndSwapInt32(&.done, 0, 1) {
		close(.wait)
	}
}

// Ready returns waiting channel.
func ( *Ready) () <-chan struct{} {
	return .wait
}