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

RFC 0007: Event loop refactor #7

Merged
merged 27 commits into from
Nov 15, 2024
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift click to select a range
9a93501
Event loop refactor
straight-shoota May 2, 2024
04a7c37
Fix filename
straight-shoota May 7, 2024
c70c896
Fill guide-level explanation
straight-shoota May 7, 2024
ba1e1a4
Add abstract interface description
straight-shoota May 7, 2024
3e40217
Fix associate *Socket* subsection with *Optional event loop features*
straight-shoota May 27, 2024
3bff4d1
fixup
straight-shoota May 27, 2024
9afc76f
Resolve *`read` and `write` behaviour*
straight-shoota May 28, 2024
9ab3a8e
Resolve *Timeout and Resume events*
straight-shoota May 28, 2024
0647def
Fix typo
straight-shoota May 28, 2024
113e401
Drop `EventLoop#send`, `#receive`
straight-shoota May 28, 2024
b1978fa
Separate `EventLoop` interface into modules
straight-shoota May 28, 2024
a42930c
typo
straight-shoota May 28, 2024
5db0edb
Add `run` and `interrupt` for completeness
straight-shoota May 28, 2024
a08f935
fixup
straight-shoota May 29, 2024
5b7f663
Improve API docs for `EventLoop::Socket`
straight-shoota May 29, 2024
8b9b09b
Update text/0007-event_loop-refactor.md
straight-shoota May 30, 2024
04462e8
Apply suggestions from code review
straight-shoota May 31, 2024
8eee22e
Update implemented API
straight-shoota Nov 12, 2024
6334e16
Resolve `Socket` question
straight-shoota Nov 12, 2024
526b3d8
cleanup
straight-shoota Nov 12, 2024
53a1861
Add reference to RFC 0009
straight-shoota Nov 12, 2024
1061a51
Fix `write`/`read` docs
straight-shoota Nov 14, 2024
246c87f
Drop unresolved questions
straight-shoota Nov 14, 2024
f74db24
Turn _Type for sizes_ into a future possibility
straight-shoota Nov 14, 2024
70942fa
Turn more open questions into future possibilities
straight-shoota Nov 14, 2024
b7da5cc
Drop *Rationale and alternatives*
straight-shoota Nov 14, 2024
252f546
Add *Rationale and alternatives*
straight-shoota Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add run and interrupt for completeness
  • Loading branch information
straight-shoota committed May 28, 2024
commit 5db0edb56267396c156ff1922bb5fe002c4df680
27 changes: 26 additions & 1 deletion text/0007-event_loop-refactor.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 73,35 @@ Further extensions can widen the scope of the event loop.
# Reference-level explanation

The new `EventLoop` interface consits of individual module interfaces which
defines operations on the event loop related to a specific concept:
defines operations on the event loop related to a specific concept.
The `run` and `interrupt` methods are shown for completenes, but they are part
of [RFC 0002](https://github.com/crystal-lang/rfcs/pull/2) ([#14568](https://github.com/crystal-lang/crystal/pull/14568)).

```cr
abstract class Crystal::System::EventLoop
# Runs the loop.
#
# Returns immediately if events are activable. Set `blocking` to false to
# return immediately if there are no activable events; set it to true to wait
# for activable events, which will block the current thread until then.
#
# Returns `true` on normal returns (e.g. has activated events, has pending
# events but blocking was false) and `false` when there are no registered
# events.
abstract def run(blocking : Bool) : Bool

# Tells a blocking run loop to no longer wait for events to activate. It may
# for example enqueue a NOOP event with an immediate (or past) timeout. Having
# activated an event, the loop shall return, allowing the blocked thread to
# continue.
#
# Should be a NOOP when the loop isn't running or is running in a nonblocking
# mode.
#
# NOTE: we assume that multiple threads won't run the event loop at the same
# time in parallel, but this assumption may change in the future!
abstract def interrupt : Nil

include FileDescriptor
include Socket

Expand Down