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

feat(listener): poll a port multiple times until either "max_poll" or returned "None" #78

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hasezoey
Copy link
Contributor

@hasezoey hasezoey commented May 4, 2024

Fixes #71

Description

This PR adds a way to poll a Port more than once per Port::should_poll, as the implementation of Poll::poll should be non-blocking and return Ok(None) in the case there is nothing. (though there also exists #77)

Because i didnt want to break any existing Ports and because of #77 (and MockPoll), i set the default max_poll to 1 (to basically match the behavior of what it was before this PR).

This change is necessary, as already explained in #71, if EnableMouseCapture is set (in crossterm, which is the default in 1.9.2), then there are a LOT of events generated very quickly, but before this PR you would only get one event, then wait, then one event, then wait instead of "all" at once. (which can make the TUI very unresponsive)

Type of change

Please select relevant options.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • My code follows the contribution guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I formatted the code with cargo fmt
  • I checked my code using cargo clippy and reports no warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have introduced no new C-bindings
  • The changes I've made are Windows, MacOS, UNIX, Linux compatible (or I've handled them using cfg target_os)
  • I increased or maintained the code coverage for the project, compared to the previous commit

Alternative

Alternatively to this PR we could also change the result of Poll::poll to return a vec, though i personally would not like to move this aggregation to the Poll implementation if possible.

@hasezoey
Copy link
Contributor Author

hasezoey commented May 5, 2024

Update: i now also added function port_1 (for the lack of a better name) to EventListenerCfg to add a manually constructed port (which was seemingly not possible before)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] - Ports are seemingly only polled once per event loop
1 participant