Skip to content

feat: Add an option to wait for events in tox_iterate.#2979

Draft
iphydf wants to merge 1 commit into
TokTok:masterfrom
iphydf:tox-event
Draft

feat: Add an option to wait for events in tox_iterate.#2979
iphydf wants to merge 1 commit into
TokTok:masterfrom
iphydf:tox-event

Conversation

@iphydf

@iphydf iphydf commented Jan 16, 2026

Copy link
Copy Markdown
Member

This change is Reviewable

@iphydf iphydf added this to the v0.2.22 milestone Jan 16, 2026
@github-actions github-actions Bot added the enhancement New feature for the user, not a new feature for build script label Jan 16, 2026
@iphydf
iphydf force-pushed the tox-event branch 20 times, most recently from b100f28 to 2a028db Compare January 16, 2026 17:46
@iphydf
iphydf marked this pull request as ready for review January 16, 2026 18:32
@iphydf
iphydf requested a review from a team as a code owner January 16, 2026 18:32
@iphydf
iphydf force-pushed the tox-event branch 2 times, most recently from 99c5b7e to 64fb992 Compare January 17, 2026 00:58
@iphydf
iphydf marked this pull request as draft January 17, 2026 01:16
@iphydf
iphydf force-pushed the tox-event branch 3 times, most recently from 9ba0659 to ee78824 Compare January 17, 2026 02:57
@iphydf
iphydf force-pushed the tox-event branch 16 times, most recently from 408e219 to 87c41aa Compare January 19, 2026 19:52
@iphydf
iphydf marked this pull request as ready for review January 19, 2026 19:54
.del_callback
= [](void *self, Socket sock) { return static_cast<FakeEvent *>(self)->del(sock); },
.run_callback =
[](void *self, Ev_Result results[], uint32_t max_results, int32_t timeout_ms) {

Check notice

Code scanning / CodeQL

No raw arrays in interfaces Note test

Raw arrays should not be used in interfaces. A container class should be used instead.
return monitored_.erase(fd) > 0;
}

int32_t FakeEvent::run(Ev_Result results[], uint32_t max_results, int32_t timeout_ms)

Check notice

Code scanning / CodeQL

No raw arrays in interfaces Note test

Raw arrays should not be used in interfaces. A container class should be used instead.
Comment thread toxcore/tox.c
Comment on lines +1273 to +1276
if (n > 0) {
/* Events occurred, but do_messenger will poll all sockets anyway. */
// TODO(iphydf): Optimize do_messenger to only process ready sockets.
}

Check notice

Code scanning / CodeQL

Futile conditional Note

If-statement with an empty then-branch and no else-branch.
@iphydf
iphydf force-pushed the tox-event branch 2 times, most recently from e93f1cc to f45bd0b Compare January 24, 2026 21:30
@codecov

codecov Bot commented Jan 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 54.64286% with 127 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.89%. Comparing base (b144e8d) to head (f45bd0b).

Files with missing lines Patch % Lines
testing/support/doubles/fake_event_test.cc 0.00% 55 Missing ⚠️
testing/support/doubles/fake_event.cc 32.72% 37 Missing ⚠️
toxcore/TCP_server.c 77.41% 14 Missing ⚠️
toxcore/tox_events.c 65.21% 8 Missing ⚠️
toxcore/tox.c 76.66% 7 Missing ⚠️
toxcore/TCP_connection.c 50.00% 3 Missing ⚠️
testing/fuzzing/bootstrap_fuzz_test.cc 75.00% 1 Missing ⚠️
testing/support/src/tox_runner.cc 0.00% 1 Missing ⚠️
toxcore/forwarding_fuzz_test.cc 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2979      +/-   ##
==========================================
+ Coverage   68.84%   69.89%   +1.04%     
==========================================
  Files         184      188       +4     
  Lines       33818    34193     +375     
==========================================
+ Hits        23283    23900     +617     
+ Misses      10535    10293     -242     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Introduce `Ev` abstraction for event loops.
- Implement `os_event` using epoll (Linux) and AFD/poll (Windows/other).
- Update `toxcore` networking to use `Ev`.
- Add `experimental_iterate_timeout_ms` option to blocking wait.
- Add `FakeEvent` for testing.
@iphydf iphydf modified the milestones: v0.2.22, v0.2.23 Jan 27, 2026
@iphydf
iphydf marked this pull request as draft February 9, 2026 08:26
@Green-Sky Green-Sky modified the milestones: v0.2.23, v0.2.24 Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature for the user, not a new feature for build script

Development

Successfully merging this pull request may close these issues.

3 participants