Commit Graph

34 Commits

Author SHA1 Message Date
John Nunley dc4c5b4ec0
bugfix: Prevent large timeouts from causing panics (#71) 2023-01-07 19:35:46 -08:00
John Nunley 181acc67d0
Add level and edge triggered modes to the poller (#59)
* Add level and edge triggered modes to the poller

* Refractor error handling

* Add tests for new modes
2022-12-30 14:43:47 -08:00
John Nunley 00e7eefc4d
Add error message for Wepoll (#54)
* Add error message for Wepoll

* Avoid unsupported error kind where it is not supported
2022-11-30 20:26:28 -08:00
Taiki Endo 6f459f89a9 Use std::os::raw::c_int instead of std::ffi::c_int 2022-11-29 22:21:43 +09:00
John Nunley 8982599ddf
Port to windows-sys (#47) 2022-11-26 20:50:12 -08:00
Taiki Endo de312d15b6 Reduce size of sys::Events 2022-08-21 23:40:10 +09:00
John Nunley 323473ec1a
Expose raw handles for the `Poller` (#39)
* expose raw handles

* add comment explaining no_*
2022-08-18 09:52:28 -07:00
Taiki Endo dec94cb423 Clean up CI config 2022-01-09 01:50:42 +09:00
Taiki Endo 4ac15ff339
Merge pull request #26 from Kestrer/master
Support VxWorks, Fuchsia and other Unix systems by using poll
2021-09-11 18:09:28 +09:00
Kestrer c174c9b7bb Prevent timeout overflow for poll and wepoll 2021-05-26 10:33:24 +01:00
Philip Degarmo 2295ca07b8 Switch wepoll-sys to wepoll-ffi to reduce licenses used in dependency tree (discussed in #35) 2021-05-25 22:56:05 -07:00
Taiki Endo c009653b99 Replace deprecated compare_and_swap with compare_exchange 2020-12-24 21:18:55 +09:00
Stjepan Glavina b562ab84ea Use notified flag to make timeouts correct 2020-10-02 18:31:00 +02:00
Stjepan Glavina a3c748bcd0 Use more explicit type conversions 2020-10-02 18:19:15 +02:00
Stjepan Glavina 8b656241d5 Use saturating_add to prevent overflow 2020-10-02 18:17:45 +02:00
Stjepan Glavina d4667889b4 Switch to wepoll-sys 2020-10-02 17:41:55 +02:00
Stjepan Glavina 0a299cf060 Small cleanup 2020-10-02 17:34:53 +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
Jayce Fayne 2ecb5564e8 remove `libc` dependency on windows 2020-09-16 11:23:03 +02:00
Stjepan Glavina bc3dc1ec6e Replace log::debug with log::trace 2020-09-03 12:55:46 +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 654ddca8a6 Add logging 2020-08-29 16:07:51 +02:00
Stjepan Glavina d183433d9e Add timeout test 2020-08-15 08:14:52 +02:00
Stjepan Glavina a7bae2f5c4 Return from wait if there was a notification 2020-08-14 16:33:28 +02:00
Stjepan Glavina d13ddbe0ff Fix timeout calculation on windows 2020-08-14 16:02:30 +02:00
Stjepan Glavina 9d9b8361e5 Fix compilation errors 2020-08-14 15:26:54 +02:00
Stjepan Glavina f1f3d4609c Another try on windows 2020-08-14 15:18:44 +02:00
Stjepan Glavina d645f95ecb Fix compilation errors 2020-08-14 14:59:24 +02:00
Stjepan Glavina 992ee10ee7 Round up to a whole millisecond 2020-08-14 14:47:32 +02:00
Stjepan Glavina 11f77ff54b Some polish 2020-08-14 14:38:02 +02:00
Stjepan Glavina d763bb2d90 Fix compilation errors 2020-08-06 15:10:39 +02:00
Stjepan Glavina 5b32dd8e82 Initial commit 2020-08-06 15:05:24 +02:00