update example codes of integrating with http server

This commit is contained in:
Andy Pan 2018-12-03 14:32:47 +08:00
commit aad3999c75
3 changed files with 3 additions and 2 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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++ {