mirror of
https://github.com/tursom/GoCollections.git
synced 2025-03-25 10:10:07 +08:00
34 lines
528 B
Go
34 lines
528 B
Go
/*
|
|
* Copyright (c) 2022 tursom. All rights reserved.
|
|
* Use of this source code is governed by a GPL-3
|
|
* license that can be found in the LICENSE file.
|
|
*/
|
|
|
|
package util
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/tursom/GoCollections/util/time"
|
|
)
|
|
|
|
func TestPipeline(t *testing.T) {
|
|
c := make(chan int)
|
|
r := NewPipeline(c, 4, func(t int) int {
|
|
return t * t * t * t
|
|
})
|
|
|
|
go func() {
|
|
defer close(c)
|
|
for i := 0; i < 1024; i++ {
|
|
c <- i
|
|
}
|
|
time.Sleep(time.Second)
|
|
}()
|
|
|
|
for i := range r.RCh() {
|
|
fmt.Println(i)
|
|
}
|
|
}
|