mirror of
https://github.com/openp2p-cn/openp2p.git
synced 2025-10-06 17:17:05 +08:00
25 lines
505 B
Go
25 lines
505 B
Go
package openp2p
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestSelectPriority(t *testing.T) {
|
|
writeData := make(chan []byte, WriteDataChanSize)
|
|
writeDataSmall := make(chan []byte, WriteDataChanSize/30)
|
|
for i := 0; i < 100; i++ {
|
|
writeData <- []byte("data")
|
|
writeDataSmall <- []byte("small data")
|
|
}
|
|
for i := 0; i < 100; i++ {
|
|
select {
|
|
case buff := <-writeDataSmall:
|
|
fmt.Printf("got small data:%s\n", string(buff))
|
|
case buff := <-writeData:
|
|
fmt.Printf("got data:%s\n", string(buff))
|
|
}
|
|
}
|
|
|
|
}
|