From: Eric Wong <e@80x24.org>
To: Daniele Orlandi <daniele@orlandi.com>
Cc: sleepy-penguin@bogomips.org
Subject: Re: Events are still delivered after an IO object is deleted from epoll
Date: Mon, 7 Dec 2015 04:13:30 +0000 [thread overview]
Message-ID: <20151207041330.GA5074@dcvr.yhbt.net> (raw)
In-Reply-To: <5664FAC6.8040705@orlandi.com>
Daniele Orlandi <daniele@orlandi.com> wrote:
> In #receive, sometimes I close and remove an "io" object from the epoll
> via #del (e.g. in a timerfd I close ad remove a socket)
>
> However it appears that if there are queued events the block may still
> be called afterwise.
>
> Not a big deal, easily workaround-able, but you may want to give a look
> at it.
That's because the default maxevents for wait; so the underlying
epoll_wait syscall is still retrieving 64 events at once into the Ruby
process.
Try passing 1 as the maxevents argument:
@actor_epoll.wait(1) do |events, io|
receive(events, io)
end
Retrieving more events into the kernel at once improves throughput
performance and benefits typical single-threaded event loops.
However, my typical usage is actually maxevents=1; but I'm a weirdo who
abuses epoll as a thread queue :)
Anyways, I've been thinking about revamping the API a bit;
so maybe this could return an array instead.
Thanks for the feedback!
next parent reply other threads:[~2015-12-07 4:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5664FAC6.8040705@orlandi.com>
2015-12-07 4:13 ` Eric Wong [this message]
2015-12-07 3:40 Events are still delivered after an IO object is deleted from epoll Daniele Orlandi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/sleepy_penguin/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151207041330.GA5074@dcvr.yhbt.net \
--to=e@80x24.org \
--cc=daniele@orlandi.com \
--cc=sleepy-penguin@bogomips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/sleepy_penguin.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).