Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enif_select() for asynchronous IO notifications #1264

Merged
merged 8 commits into from Feb 23, 2017

Conversation

Projects
None yet
2 participants
@sverker
Copy link
Contributor

commented Dec 1, 2016

Function enif_select() is a new way for NIFs to wait for asynchronous notifications
when file descriptors become ready for either read or write operations.

Similar to driver_select() but for NIFs, with no need for dedicated threads
(custom, async or dirty) to do the waiting.

In short a NIF calls enif_select() for a file descriptor
then returns to Erlang to wait for a ready_input or ready_output message
then makes a NIF call to continue read or write.

The purpose of this PR is mainly for people to try it out and give some early feedback on the API.

For usage documentation see erl_nif.xml or the nif_SUITE:select test case code in this PR.

I have also done two example usages in this separate branch https://github.com/sverker/otp/commits/sverker/enif_select-examples:

  • sverk_tcp - a client side TCP socket
  • ttsl_nif - a NIF adaptation of the ttsl driver which is the terminal low-level interface for the Erlang shell.

sverker added some commits Oct 21, 2016

erts: Refactor add_active_fd
to not inline cold reallocation code.
erts: Change handling of error event for driver_select
Make the code simpler.

May change the behavior as we may call both iready and oready
when getting an error. But doesn't that seem more correct.
@sverker

This comment has been minimized.

Copy link
Contributor Author

commented Dec 19, 2016

Added more tests, some bug fixes and API tweaks.

@sverker sverker merged commit 4c5d331 into erlang:master Feb 23, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.