mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 01:36:24 +01:00
fn: add SendOrQuit
This commit is contained in:
parent
a2694009cd
commit
eb72bb9712
1 changed files with 13 additions and 0 deletions
13
fn/send.go
Normal file
13
fn/send.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
package fn
|
||||
|
||||
// SendOrQuit attempts to and a message through channel c. If this succeeds,
|
||||
// then bool is returned. Otherwise if a quit signal is received first, then
|
||||
// false is returned.
|
||||
func SendOrQuit[T any, Q any](c chan<- T, msg T, quit chan Q) bool {
|
||||
select {
|
||||
case c <- msg:
|
||||
return true
|
||||
case <-quit:
|
||||
return false
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue