Skip to content

Commit 0a0552c

Browse files
committed
add doPool
1 parent 8b19b47 commit 0a0552c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ go.mod: $(MAKEFILE_LIST)
3131
echo 'module github.com/xdrpp/goxdr' > go.mod
3232
echo 'go 1.24.0' >> go.mod
3333
echo 'require golang.org/x/tools v0.31.0' >> go.mod
34+
echo 'require github.com/panjf2000/ants/v2 v2.11.3' >> go.mod
35+
echo 'require golang.org/x/sync v0.12.0' >> go.mod
3436

3537
depend: always
3638
cd / && go install golang.org/x/tools/cmd/goyacc@latest

rpc/driver.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"sync"
1010
"sync/atomic"
1111

12+
"github.com/panjf2000/ants/v2"
1213
"github.com/xdrpp/goxdr/xdr"
1314
)
1415

@@ -201,6 +202,7 @@ type Driver struct {
201202
cs CallSet
202203
started int32
203204

205+
doPool *ants.Pool
204206
msgPool *MsgPool
205207
}
206208

@@ -239,12 +241,17 @@ func NewDriver(ctx context.Context, mp *MsgPool, t Transport) *Driver {
239241
ctx = context.Background()
240242
}
241243
ctx, cancel := context.WithCancel(ctx)
244+
doPool, err := ants.NewPool(200)
245+
if err != nil {
246+
panic(err)
247+
}
242248
ret := Driver{
243249
Log: DefaultLog,
244250
Lock: &sync.Mutex{},
245251
ctx: ctx,
246252
cancel: cancel,
247253
in: ReceiveChan(ctx, t),
254+
doPool: doPool,
248255
msgPool: mp,
249256
}
250257
ret.out, ret.outClose = SendChan(t, func(xid uint32, _ error) {

0 commit comments

Comments
 (0)