Skip to content

Commit

Permalink
chore: rename a function in internal/queue/queue.AsyncTaskQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
panjf2000 committed Nov 30, 2021
1 parent 148ee16 commit dfa473d
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion internal/netpoll/epoll_default_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (p *Poller) Polling(callback func(fd int, ev uint32) error) error {
queue.PutTask(task)
}
atomic.StoreInt32(&p.netpollWakeSig, 0)
if (!p.asyncTaskQueue.Empty() || !p.priorAsyncTaskQueue.Empty()) && atomic.CompareAndSwapInt32(&p.netpollWakeSig, 0, 1) {
if (!p.asyncTaskQueue.IsEmpty() || !p.priorAsyncTaskQueue.IsEmpty()) && atomic.CompareAndSwapInt32(&p.netpollWakeSig, 0, 1) {
for _, err = unix.Write(p.wfd, b); err == unix.EINTR || err == unix.EAGAIN; _, err = unix.Write(p.wfd, b) {
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/netpoll/epoll_optimized_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (p *Poller) Polling() error {
queue.PutTask(task)
}
atomic.StoreInt32(&p.netpollWakeSig, 0)
if (!p.asyncTaskQueue.Empty() || !p.priorAsyncTaskQueue.Empty()) && atomic.CompareAndSwapInt32(&p.netpollWakeSig, 0, 1) {
if (!p.asyncTaskQueue.IsEmpty() || !p.priorAsyncTaskQueue.IsEmpty()) && atomic.CompareAndSwapInt32(&p.netpollWakeSig, 0, 1) {
for _, err = unix.Write(p.wpa.FD, b); err == unix.EINTR || err == unix.EAGAIN; _, err = unix.Write(p.wpa.FD, b) {
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/netpoll/kqueue_default_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (p *Poller) Polling(callback func(fd int, filter int16) error) error {
queue.PutTask(task)
}
atomic.StoreInt32(&p.netpollWakeSig, 0)
if (!p.asyncTaskQueue.Empty() || !p.priorAsyncTaskQueue.Empty()) && atomic.CompareAndSwapInt32(&p.netpollWakeSig, 0, 1) {
if (!p.asyncTaskQueue.IsEmpty() || !p.priorAsyncTaskQueue.IsEmpty()) && atomic.CompareAndSwapInt32(&p.netpollWakeSig, 0, 1) {
for _, err = unix.Kevent(p.fd, wakeChanges, nil, nil); err == unix.EINTR || err == unix.EAGAIN; _, err = unix.Kevent(p.fd, wakeChanges, nil, nil) {
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/netpoll/kqueue_optimized_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (p *Poller) Polling() error {
queue.PutTask(task)
}
atomic.StoreInt32(&p.netpollWakeSig, 0)
if (!p.asyncTaskQueue.Empty() || !p.priorAsyncTaskQueue.Empty()) && atomic.CompareAndSwapInt32(&p.netpollWakeSig, 0, 1) {
if (!p.asyncTaskQueue.IsEmpty() || !p.priorAsyncTaskQueue.IsEmpty()) && atomic.CompareAndSwapInt32(&p.netpollWakeSig, 0, 1) {
for _, err = unix.Kevent(p.fd, wakeChanges, nil, nil); err == unix.EINTR || err == unix.EAGAIN; _, err = unix.Kevent(p.fd, wakeChanges, nil, nil) {
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/queue/lock_free_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ retry:
goto retry
}

// Empty indicates whether this queue is empty or not.
func (q *lockFreeQueue) Empty() bool {
// IsEmpty indicates whether this queue is empty or not.
func (q *lockFreeQueue) IsEmpty() bool {
return atomic.LoadInt32(&q.length) == 0
}

Expand Down
2 changes: 1 addition & 1 deletion internal/queue/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ func PutTask(task *Task) {
type AsyncTaskQueue interface {
Enqueue(*Task)
Dequeue() *Task
Empty() bool
IsEmpty() bool
}

0 comments on commit dfa473d

Please sign in to comment.