mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-09 14:43:19 +00:00
built the WaitForStop functionality into the Stop method
This commit is contained in:
@@ -165,8 +165,15 @@ func (tm *TrustMetric) Pause() {
|
||||
}
|
||||
|
||||
// Stop tells the metric to stop recording data over time intervals
|
||||
// This method also blocks until the metric has completely stopped
|
||||
func (tm *TrustMetric) Stop() {
|
||||
tm.stop <- struct{}{}
|
||||
|
||||
wait := make(chan struct{})
|
||||
|
||||
if tm.AddStopWaitChannel(wait) {
|
||||
<-wait
|
||||
}
|
||||
}
|
||||
|
||||
// BadEvents indicates that an undesirable event(s) took place
|
||||
@@ -307,15 +314,6 @@ func (tm *TrustMetric) AddTimeIntervalWaitChannel(interval chan struct{}) bool {
|
||||
return added
|
||||
}
|
||||
|
||||
// WaitForStop blocks until the metric has completely stopped
|
||||
func (tm *TrustMetric) WaitForStop() {
|
||||
stop := make(chan struct{})
|
||||
|
||||
if tm.AddStopWaitChannel(stop) {
|
||||
<-stop
|
||||
}
|
||||
}
|
||||
|
||||
// SignalStopped fires all the maintained signal channels and sets
|
||||
// metric stopped status to true
|
||||
func (tm *TrustMetric) SignalStopped() {
|
||||
|
||||
@@ -77,8 +77,6 @@ func TestTrustMetricStopPause(t *testing.T) {
|
||||
tm.NextTimeInterval()
|
||||
tm.NextTimeInterval()
|
||||
tm.Stop()
|
||||
// Wait for the stop to take place
|
||||
tm.WaitForStop()
|
||||
|
||||
second := tm.Copy().numIntervals
|
||||
// Allow more intervals to pass and check that the number of intervals match
|
||||
|
||||
Reference in New Issue
Block a user