Commit Graph

228 Commits

Author SHA1 Message Date
Yorick Peterse 29791dec13
Temporarily disable async-io tests
These will fail until a new version of polling is released and async-io
is updated.
2020-10-02 01:32:44 +02:00
Yorick Peterse ba05307af1
Separate adding and modifying of file descriptors
This replaces Poller.insert() and Poller.interest() with Poller.add()
and Poller.modify(), and renames Poller.remove() to Poller.delete().

The method Poller.add() is used for adding a new file descriptor, while
Poller.modify() is used for updating an existing one. Poller.remove() is
renamed to Poller.delete() so the naming scheme of these methods follows
that of epoll, wepoll, etc.

This new setup means that adding a new socket only requires a single
call of Poller.add(), instead of a combination of Poller.insert() and
Poller.interest(). This reduces the amount of system calls necessary,
and leads to a more pleasant API.

On systems that use kqueue or ports, the behaviour of Poller.add() and
Poller.modify() is the same. This is because on these systems adding an
already existing file descriptor will just update its configuration.
This however is an implementation detail and should not be relied upon
by users.

Migrating to this new API is pretty simple, simply replace this:

    poller.insert(&socket);
    poller.interest(&socket, event);

With this:

    poller.add(&socket, event);

And for cases where Poller.interest() was used for updating an existing
file descriptor, simply replace it will a call to Poller.modify().

See https://github.com/stjepang/polling/issues/16 and
https://github.com/stjepang/polling/pull/17 for more information.
2020-10-01 21:50:59 +02:00
Yorick Peterse 4e5c3ce836
Don't automatically make descriptors non-blocking
This adds redundant system call overhead for file descriptors which have
already been turned into non-blocking file descriptors. In addition, the
polling crate doesn't need to implement platform specific code for
enabling non-blocking mode. Instead, users of polling can do so using
(for example) standard library methods such as
TcpListener.set_nonblocking().

See https://github.com/stjepang/polling/issues/16 for more information.
2020-10-01 20:06:07 +02:00
Stjepan Glavina 5309d571b2 Bump to v1.1.0 2020-09-20 17:45:49 +02:00
Stjepan Glavina 272bb11eaf Add feature 2020-09-20 17:45:24 +02:00
Stjepan Glavina 8c7ce8fb5b Bump to v1.0.3 2020-09-16 11:46:25 +02:00
Stjepan Glavina 8a77220000
Merge pull request #15 from JayceFayne/deps
remove `libc` dependency on windows
2020-09-16 11:45:32 +02:00
Jayce Fayne 2ecb5564e8 remove `libc` dependency on windows 2020-09-16 11:23:03 +02:00
Stjepan Glavina 8e35897e53 Bump to v1.0.2 2020-09-15 20:53:33 +02:00
Stjepan Glavina c2e3322b1e
Merge pull request #10 from oblique/master
Check if `epoll_create1` is implemented by its error code
2020-09-15 20:51:19 +02:00
oblique f7f67e8745 Fix linkage error for android-16 toolchain 2020-09-15 14:01:09 +03:00
oblique 62103c1ef0 Check if `epoll_create1` is implemented by its error code
If binary is statically linked to libc then `libc::dlsym`
will always return `NULL`. This is the case when a target
with musl is used.

To fix this we check if error code of `epoll_create1` is `ENOSYS`.
2020-09-15 14:01:09 +03:00
Stjepan Glavina 4fc3040bff Pass timeout in ms to epoll_wait 2020-09-14 21:06:16 +02:00
Stjepan Glavina a954600d6a Bump MSRV to 1.40.0 2020-09-14 20:44:44 +02:00
Stjepan Glavina 46634fc32a Fix CI 2020-09-14 20:38:59 +02:00
Stjepan Glavina d8c32a0140 Test async-io 2020-09-14 20:31:23 +02:00
Stjepan Glavina 7738ca0b25 Remove doc-comment because the readme then needs the ugly #-prefixed line 2020-09-07 19:53:31 +02:00
Stjepan Glavina 1992605564 Bump to v1.0.1 2020-09-07 19:41:24 +02:00
Stjepan Glavina b05877c3ec Bump to v1.0.0 2020-09-07 16:44:39 +02:00
Stjepan Glavina 8c2f5e4169 Bump to v0.1.9 2020-09-06 11:10:54 +02:00
Stjepan Glavina 6d4724ba35 Test on Linux x32 2020-09-06 10:56:48 +02:00
Stjepan Glavina a8e3673939
Merge pull request #14 from sunfishcode/master
Fix compilation on x32
2020-09-06 10:54:10 +02:00
Dan Gohman d22ed8fd7b Fix compilation on x32
Fix compilation on x86_64-unknown-linux-gnux32, where
libc's timespec's `tv_nsec` is [defined as `i64`]. See also
[this bug] bug for further discussion.

[defined as `i64`]: https://github.com/rust-lang/libc/blob/master/src/unix/mod.rs#L61
[this bug]: https://sourceware.org/bugzilla/show_bug.cgi?id=16437
2020-09-05 22:17:26 -07:00
Stjepan Glavina f03bb7acf0 Bump to v0.1.8 2020-09-03 12:56:12 +02:00
Stjepan Glavina bc3dc1ec6e Replace log::debug with log::trace 2020-09-03 12:55:46 +02:00
Stjepan Glavina 6e4bd15786 Bump to v0.1.7 2020-09-01 07:06:52 +02:00
Stjepan Glavina 8974861fa0
Merge pull request #12 from stjepang/insert-oneshot
Specify oneshot when inserting into epoll/wepoll
2020-09-01 07:06:09 +02:00
Stjepan Glavina 91bf9a4cf6 Fix compilation error 2020-09-01 06:49:20 +02:00
Stjepan Glavina 4b4b774116 Cleanup 2020-09-01 06:48:09 +02:00
Stjepan Glavina 3fdcd68e23 Specify oneshot when inserting into epoll/wepoll 2020-09-01 06:42:08 +02:00
Stjepan Glavina d106cef8c4 Bump to v0.1.6 2020-08-29 17:34:45 +02:00
Stjepan Glavina 654ddca8a6 Add logging 2020-08-29 16:07:51 +02:00
Stjepan Glavina 54ac671d8e Bump to v0.1.5 2020-08-15 09:15:49 +02:00
Stjepan Glavina 2b944c8f7d
Merge pull request #9 from stjepang/timeout-test
Add timeout test
2020-08-15 09:14:57 +02:00
Stjepan Glavina bf546cb173 Fix warnings 2020-08-15 09:12:45 +02:00
Stjepan Glavina 8f1c4e530d Set timeout to 0 when non-blocking epoll_wait 2020-08-15 09:05:58 +02:00
Stjepan Glavina 94b263817d Add missing import 2020-08-15 08:45:10 +02:00
Stjepan Glavina e5a8b08578 Use timeout_ms again 2020-08-15 08:40:12 +02:00
Stjepan Glavina 7a1d7386ba Set interest after configuring timerfd 2020-08-15 08:31:00 +02:00
Stjepan Glavina 49cdfb8d5a Add notify tests 2020-08-15 08:23:45 +02:00
Stjepan Glavina cd0c0925c7 Loop 2020-08-15 08:18:12 +02:00
Stjepan Glavina 453d2b2d5e Add test 2020-08-15 08:16:22 +02:00
Stjepan Glavina d183433d9e Add timeout test 2020-08-15 08:14:52 +02:00
Stjepan Glavina ebbd46c40f Bump to v0.1.4 2020-08-14 17:05:47 +02:00
Stjepan Glavina 665f5f66d1
Merge pull request #8 from stjepang/sub-ns-linux
Sub-nanosecond precision for epoll
2020-08-14 17:04:15 +02:00
Stjepan Glavina a7bae2f5c4 Return from wait if there was a notification 2020-08-14 16:33:28 +02:00
Stjepan Glavina 3364fabe0e Fix a comment 2020-08-14 16:08:59 +02:00
Stjepan Glavina f9fb1849e3 Small fixes 2020-08-14 16:08:13 +02:00
Stjepan Glavina 3f721e5498 Add notified flag 2020-08-14 16:07:53 +02:00
Stjepan Glavina d13ddbe0ff Fix timeout calculation on windows 2020-08-14 16:02:30 +02:00