mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-06 02:52:19 +00:00
826f6ce377
* Move ETL to erigon-lib * Add coded * Remove walk Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
31 lines
398 B
Go
31 lines
398 B
Go
package common
|
|
|
|
import "errors"
|
|
|
|
var ErrStopped = errors.New("stopped")
|
|
var ErrUnwind = errors.New("unwound")
|
|
|
|
func Stopped(ch <-chan struct{}) error {
|
|
if ch == nil {
|
|
return nil
|
|
}
|
|
select {
|
|
case <-ch:
|
|
return ErrStopped
|
|
default:
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func SafeClose(ch chan struct{}) {
|
|
if ch == nil {
|
|
return
|
|
}
|
|
select {
|
|
case <-ch:
|
|
// Channel was already closed
|
|
default:
|
|
close(ch)
|
|
}
|
|
}
|