Skip to content

Commit

Permalink
try to keep capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaci committed Oct 4, 2024
1 parent 25dbaee commit 0989b9d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions aio_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (p *poller) wakeup() error {

// Wait waits for events happen on the file descriptors.
func (p *poller) Wait(chSignal chan Signal) {
var pe pollerEvents
var eventSet pollerEvents
events := make([]syscall.Kevent_t, maxEvents)
sig := Signal{
done: make(chan struct{}, 1),
Expand Down Expand Up @@ -176,12 +176,12 @@ func (p *poller) Wait(chSignal chan Signal) {
e.ev |= EV_WRITE
}

pe = append(pe, e)
eventSet = append(eventSet, e)
}
}

// notify watcher
sig.events = pe
sig.events = eventSet

select {
case chSignal <- sig:
Expand All @@ -192,7 +192,7 @@ func (p *poller) Wait(chSignal chan Signal) {
// wait for the watcher to finish processing
select {
case <-sig.done:
pe = pe[:0]
eventSet = eventSet[:0:cap(eventSet)]
case <-p.die:
return
}
Expand Down
2 changes: 1 addition & 1 deletion aio_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (p *poller) Wait(chSignal chan Signal) {
// wait for the watcher to finish processing
select {
case <-sig.done:
eventSet = eventSet[:0]
eventSet = eventSet[:0:cap(eventSet)]
case <-p.die:
return
}
Expand Down

0 comments on commit 0989b9d

Please sign in to comment.