Crates.io | rx_rust_mp |
lib.rs | rx_rust_mp |
version | 1.0.0 |
source | src |
created_at | 2023-02-02 09:40:55.820011 |
updated_at | 2023-08-04 08:59:24.283116 |
description | A protoype implementation of the ReactiveX API in Rust using a message passing approach |
homepage | |
repository | https://github.com/AntonOellerer/rx_rust_mp |
max_upload_size | |
id | 774649 |
size | 43,890 |
Message Passing implementation prototype of the ReactiveX API
This is a protoype only implementing the operators I needed for my master thesis. I created it after discovering that the official implementation hasn't been updated for 8 years, and the unofficial rxRust uses a shared memory model internally, making parallel computation of stream data quasi-impossible.
The library itself is pretty simple, there is one trait Observable
,
which provides the implementations creating each operator, and requires implementing structs to implement the actual_subscribe
function. Due to this, every struct implementing Observable
can be chained into a stream.
At the end of the stream declaration subscribe
has to be called,
being given a function to execute on each incoming value, and a pool to schedule each task on.
This subscribe
function calls the actual_subscribe
of the operator above it, handing it the pool and the Sender
part of a mpsc channel,
which is repeated for each operator until the create
or from_iter
function at the top of the stream declaration is reached.
Each operator needs to at least store a reference to the struct above, so that it can refer to it once the stream is constructed on subscribe
.
The general workflow of each operators actual_subscribe
function is
(1)
actual_subscribe
functionactual_subscribe
function of the previous object, passing it the sending end of the channel created in (1)
and the thread poolThis is of course not a strict recipe, as each operator has to do different things.