various optimizations
This commit is contained in:
parent
220f4e6525
commit
55c3c7a464
@ -21,9 +21,8 @@ func WriteIntoDelayed[T any](ch chan<- T, delay time.Duration, values ...T) {
|
||||
|
||||
// WriteIntoWriter reads all values from ch and writes them via fmt.Fprintln to all writers
|
||||
func WriteIntoWriter[T any](ch <-chan T, writers ...io.Writer) {
|
||||
for value := range ch {
|
||||
for _, w := range writers {
|
||||
fmt.Fprintln(w, value)
|
||||
}
|
||||
}
|
||||
w := io.MultiWriter(writers...)
|
||||
Each(ch, func(value T) {
|
||||
fmt.Fprintln(w, value)
|
||||
})
|
||||
}
|
||||
|
@ -3,7 +3,8 @@ package channel
|
||||
import "time"
|
||||
|
||||
// CloseOnTimeout returns a channel which receives all values from the source.
|
||||
// If no value was received in the given timeout duration, the returned channel will be closed
|
||||
// If no value was received in the given timeout duration, the returned channel will be closed.
|
||||
// The input channel will not be closed.
|
||||
func CloseOnTimeout[T any](source <-chan T, timeout time.Duration) <-chan T {
|
||||
output := make(chan T, cap(source))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user