Skip to content

Commit

Permalink
Inotify::read_events handles only a buffer's worth of events.
Browse files Browse the repository at this point in the history
Fixes #156.

Change the documentation of `Inotify::read_events` to match the actual behavior:
return an iterator over only as many events can fit in the supplied buffer, not
over any available events.

It would be possible to make `Events` behave as documented, but it would need to
hold a strong reference to `fd` and a mutable reference to `buffer`, and it
seems awkward. The `notify` crate's use of `read_events` is easily switched by
requesting level-sensitive notification on the inotify file descriptor, which is
designed for exactly this sort of situation.
  • Loading branch information
jimblandy committed Nov 4, 2020
1 parent 802b1ff commit a3d5f0c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/inotify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ impl Inotify {
result
}

/// Returns any available events
/// Returns one buffer's worth of available events
///
/// Returns an iterator over all events that are currently available. If no
/// events are available, an iterator is still returned. If you need a
/// method that will block until at least one event is available, please
/// consider [`read_events_blocking`].
/// Reads as many events as possible into `buffer`, and returns an iterator
/// over them. If no events are available, an iterator is still returned. If
/// you need a method that will block until at least one event is available,
/// please consider [`read_events_blocking`].
///
/// Please note that inotify will merge identical unread events into a
/// single event. This means this method can not be used to count the number
Expand Down

0 comments on commit a3d5f0c

Please sign in to comment.