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 20 commits into
base: dev
Choose a base branch
from
Open

Libuv #384

wants to merge 20 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!

This was referenced Dec 6, 2023
@TimWhiting TimWhiting force-pushed the libuv branch 3 times, most recently from 1a9587a to 5e97fe9 Compare December 31, 2023 02:07
@TimWhiting TimWhiting marked this pull request as draft January 13, 2024 17:48
@TimWhiting TimWhiting force-pushed the libuv branch 5 times, most recently from 8358743 to c2905c2 Compare January 15, 2024 15:31
@TimWhiting TimWhiting marked this pull request as ready for review January 22, 2024 16:05
@TimWhiting TimWhiting force-pushed the libuv branch 2 times, most recently from 8c2d1a2 to c7258ce Compare February 16, 2024 22:57
@TimWhiting TimWhiting force-pushed the libuv branch 5 times, most recently from 9b9450c to 7705130 Compare February 19, 2024 21:45
@TimWhiting TimWhiting force-pushed the libuv branch 2 times, most recently from 97529c3 to f217dc2 Compare May 11, 2024 02:39
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

@TimWhiting TimWhiting May 23, 2024

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.

2 participants