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

Libuv #384

Open
wants to merge 15 commits into
base: dev
Choose a base branch
from
Open

Libuv #384

wants to merge 15 commits into from

Conversation

TimWhiting
Copy link
Collaborator

@TimWhiting TimWhiting commented Dec 6, 2023

Implemented: (Low Level, Callback, LibUV wrapper)
Streams
File I/O
Net / TCP I/O
Timer
FS Poll
FS Event
Signals
TTY

Implemented: Async API
Basic File I/O
Basic TCP I/O
Timer (Also implemented for js and wasm)

Implemented: llhttp parser

Missing LibUV: UDP, Threading, Process, uv async channels, Prepare/Check/Idle

Missing (external libraries): SSL!

lib/std/core.kk Outdated
@@ -72,6 +72,12 @@ pub alias io-total = <ndet,console,net,fsys,ui,st<global>>
// The `:io-noexn` effect is used for functions that perform arbitrary I/O operations, but raise no exceptions
pub alias io-noexn = <div,io-total>

// The `:event-loop` effect signifies that a function requires an initialized event loop
pub type event-loop :: X
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is one major change. Adding event loop to the core effects.
The async library requires that there be an event loop around it, or at the very least a timer that can call callbacks.

In principle we could just use an implicit parameter for the handler for the async effect, to get the event loop and wrap it.

The problem with that approach is that if you use any libuv apis directly in callback style without the async library then you have to manually remember to initialize the event loop.
We could in principle make a custom error and detect uninitialized event loops at runtime, but that would introduce runtime overhead for each libuv call that uses callbacks, so I opted to create this new effect instead.

I will note that I did use the implicit parameter approach for the timer requirements of the async lib so that in principle you can swap out the libuv library for some other event loop library.

@TimWhiting TimWhiting force-pushed the libuv branch 5 times, most recently from ddc9572 to 9b2c2b0 Compare May 25, 2024 01:10
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.

None yet

2 participants