mirror of https://github.com/panjf2000/ants.git
update example codes of integrating with http server
This commit is contained in:
parent
6a62b85079
commit
2093372461
|
@ -119,7 +119,7 @@ func main() {
|
||||||
pool, _ := ants.NewPoolWithFunc(100, func(payload interface{}) {
|
pool, _ := ants.NewPoolWithFunc(100, func(payload interface{}) {
|
||||||
request, ok := payload.(*Request)
|
request, ok := payload.(*Request)
|
||||||
if !ok {
|
if !ok {
|
||||||
request = Request{Param:[]byte(""), Result: make(chan []byte)}
|
return
|
||||||
}
|
}
|
||||||
reverseParam := func(s []byte) []byte {
|
reverseParam := func(s []byte) []byte {
|
||||||
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
|
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
|
||||||
|
|
|
@ -118,7 +118,7 @@ func main() {
|
||||||
pool, _ := ants.NewPoolWithFunc(100, func(payload interface{}) {
|
pool, _ := ants.NewPoolWithFunc(100, func(payload interface{}) {
|
||||||
request, ok := payload.(*Request)
|
request, ok := payload.(*Request)
|
||||||
if !ok {
|
if !ok {
|
||||||
request = Request{Param:[]byte(""), Result: make(chan []byte)}
|
return
|
||||||
}
|
}
|
||||||
reverseParam := func(s []byte) []byte {
|
reverseParam := func(s []byte) []byte {
|
||||||
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
|
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
|
||||||
|
|
|
@ -71,6 +71,7 @@ func TestAntsPoolWithFunc(t *testing.T) {
|
||||||
curMem = mem.TotalAlloc/MiB - curMem
|
curMem = mem.TotalAlloc/MiB - curMem
|
||||||
t.Logf("memory usage:%d MB", curMem)
|
t.Logf("memory usage:%d MB", curMem)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNoPool(t *testing.T) {
|
func TestNoPool(t *testing.T) {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
|
|
Loading…
Reference in New Issue