April 19, 2023
On Wednesday, 19 April 2023 at 16:15:53 UTC, Adam D Ruppe wrote:
> On Tuesday, 18 April 2023 at 08:13:05 UTC, Dmitry Olshansky wrote:
>> This maps to D beautifully:
>
> I recently wrote a new stream class that works kinda like this and thought about doing put() and front etc, but I wanted heterogeneous types.
>
> Still, it kinda did work.
>
> https://github.com/adamdruppe/arsd/blob/master/core.d#L5040
>
> there's the test rn to show how it works


Cool stuff, as usual!

--
Dmitry Olshansky
April 19, 2023

On Wednesday, 19 April 2023 at 16:07:18 UTC, Jacob Shtokolov wrote:

>

On Tuesday, 18 April 2023 at 14:26:00 UTC, Sebastiaan Koppe wrote:

>

I think it will work beautifully until the day you want to do it asynchronously.

Ranges can be async, in this case, you just need to return the Result type (pending|error|success) and provide hints to something that will be pulling from this range.

Maybe. But not without major hurdles. And you forgot (async) cancellation, which is a big deal, ask Rust.

April 19, 2023

On Wednesday, 19 April 2023 at 19:13:25 UTC, Sebastiaan Koppe wrote:

>

On Wednesday, 19 April 2023 at 16:07:18 UTC, Jacob Shtokolov wrote:

>

On Tuesday, 18 April 2023 at 14:26:00 UTC, Sebastiaan Koppe wrote:

>

I think it will work beautifully until the day you want to do it asynchronously.

Ranges can be async, in this case, you just need to return the Result type (pending|error|success) and provide hints to something that will be pulling from this range.

Maybe. But not without major hurdles. And you forgot (async) cancellation, which is a big deal, ask Rust.

Cancelation is trivial, you can break a fiber at any safe point (where it yields)

--
Dmitry Olshansky

April 19, 2023

On Wednesday, 19 April 2023 at 19:50:35 UTC, Dmitry Olshansky wrote:

>

Cancelation is trivial, you can break a fiber at any safe point (where it yields)

Interrupting a fiber and cancelling work aren't the same thing. The latter might involve some cleanup, which itself might be async.

Quote from Rust's wg-async https://rust-lang.github.io/wg-async/vision/roadmap/scopes.html#cancellation:

>

In today's Rust, any async function can be synchronously cancelled at any await point: the code simply stops executing, and destructors are run for any extant variables. This leads to a lot of bugs.

Also a blog post on uring and rust, https://without.boats/blog/io-uring/

Suffice to say its tricky.

April 20, 2023

On Wednesday, 19 April 2023 at 20:46:23 UTC, Sebastiaan Koppe wrote:

>

On Wednesday, 19 April 2023 at 19:50:35 UTC, Dmitry Olshansky wrote:

>

Cancelation is trivial, you can break a fiber at any safe point (where it yields)

Interrupting a fiber and cancelling work aren't the same thing. The latter might involve some cleanup, which itself might be async.

Quote from Rust's wg-async https://rust-lang.github.io/wg-async/vision/roadmap/scopes.html#cancellation:

>

In today's Rust, any async function can be synchronously cancelled at any await point: the code simply stops executing, and destructors are run for any extant variables. This leads to a lot of bugs.

I think your structured concurrency stuff would fit nicely in photon, maybe we should get in touch and discuss it.

>

Also a blog post on uring and rust, https://without.boats/blog/io-uring/

Suffice to say its tricky.

April 20, 2023
On Tuesday, 18 April 2023 at 08:13:05 UTC, Dmitry Olshansky wrote:
> A streaming parser is doing 2 things:
> - waiting for input
> - processing the current input and spitting out Events
>
> This maps to D beautifully:
>
> 1. Waiting for input means it's an OutputRange with explicit put method!
>
> 2. Processing events means it's an InputRange of events. It may even be ForwardRange, mine first of this kind is Forward range.

This is how `requests` handle input stream from the remote end and convert it to "input stream" of http response body chunks.

Input is a stream of bytes, arbitrary splitted by remote end or by network, etc. Moreover,response content can be gzipped, chunk-encoded and whatever else. So you have to process each network input with several "processors", like "inflate", "chunk-encoded decoder" and so on.

      +------------+   +--------------+   +---------+   +-----------------+
      |input range |   | chunk-encoded|   |   gzip  |   | input range     |
Net->-| of byte[]  |->-|   decoder    |->-| decoder |->-| of response body|->- App
      |            |   |              |   |         |   | chunks: byte[]  |
      +------------+   +--------------+   +---------+   +-----------------+

There is some problems like push all unprocessed data to the right end of the picture at the end of the network stream and maybe some other... But essentially it works.

Immutability of underlying data on every step of this processing stream helps very much.
April 21, 2023

On Thursday, 20 April 2023 at 00:17:05 UTC, Dmitry Olshansky wrote:

>

I think your structured concurrency stuff would fit nicely in photon, maybe we should get in touch and discuss it.

I actually considered going with photon before starting to implement C++'s Senders/Receivers.

Its an awesome idea, but what held me back was the portability concerns around fibers. WebAssembly doesn't support them for instance.

We also needed support for async algorithms. Racing TCP connections is a classic example, where you initiate 2 connections in parallel and continue with whoever responds first. Key is doing that in a structured way, so there is no possibility of leaking something.

There is probably a way we could integrate the 2 libs, I already have a MR for supporting D fibers, so we can probably extend it to whatever executor photon has.

I bet there is a way to autowrap any regular blocking libraries that way, and get both structured concurrency and async syscalls. Interesting.

1 2
Next ›   Last »