kaspad/util/locks/receive_from_chan_when_done.go
Ori Newman 7e81757e2f
[NOD-1161] Name goroutines and log them by the name (#804)
* [NOD-1161] Name goroutines and log them by the name

* [NOD-1161] Fix some goroutine names
2020-07-20 13:00:23 +03:00

12 lines
320 B
Go

package locks
// ReceiveFromChanWhenDone takes a blocking function and returns a channel that sends an empty struct when the function is done.
func ReceiveFromChanWhenDone(callback func()) <-chan struct{} {
ch := make(chan struct{})
spawn("ReceiveFromChanWhenDone", func() {
callback()
close(ch)
})
return ch
}