mirror of
https://github.com/panjf2000/ants.git
synced 2025-12-16 18:11:03 +00:00
update example codes of integrating with http server
This commit is contained in:
commit
aad3999c75
@ -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…
x
Reference in New Issue
Block a user