7 releases

0.3.0-alpha.8 Jul 29, 2019
0.3.0-alpha.7 Jun 24, 2019
0.3.0-alpha.6 May 12, 2019
0.3.0-alpha.5 Apr 29, 2019
0.3.0-alpha.1 Feb 26, 2019

#1095 in Concurrency

Download history 100/week @ 2024-07-26 102/week @ 2024-08-02 131/week @ 2024-08-09 93/week @ 2024-08-16 90/week @ 2024-08-23 108/week @ 2024-08-30 89/week @ 2024-09-06 89/week @ 2024-09-13 120/week @ 2024-09-20 98/week @ 2024-09-27 64/week @ 2024-10-04 75/week @ 2024-10-11 84/week @ 2024-10-18 54/week @ 2024-10-25 101/week @ 2024-11-01 48/week @ 2024-11-08

302 downloads per month
Used in naja_async_runtime

MIT/Apache

15KB
290 lines

juliex - a minimal futures executor

juliex is a concurrent executor for Rust futures. It is implemented as a threadpool executor using a single, shared queue. Algorithmically, it is very similar to the Threadpool executor provided by the futures crate. The main difference is that juliex uses a crossbeam channel and performs a single allocation per spawned future, whereas the futures Threadpool uses std concurrency primitives and multiple allocations.

Similar to romio - an IO reactor - juliex currently provides no user configuration. It exposes the most minimal API possible.

Example

#![feature(async_await)]

use std::io;

use futures::StreamExt;
use futures::executor;
use futures::io::AsyncReadExt;

use romio::{TcpListener, TcpStream};

fn main() -> io::Result<()> {
    executor::block_on(async {
        let mut listener = TcpListener::bind(&"127.0.0.1:7878".parse().unwrap())?;
        let mut incoming = listener.incoming();

        println!("Listening on 127.0.0.1:7878");

        while let Some(stream) = incoming.next().await {
            let stream = stream?;
            let addr = stream.peer_addr()?;

            juliex::spawn(async move {
                println!("Accepting stream from: {}", addr);

                echo_on(stream).await.unwrap();

                println!("Closing stream from: {}", addr);
            });
        }

        Ok(())
    })
}

async fn echo_on(stream: TcpStream) -> io::Result<()> {
    let (mut reader, mut writer) = stream.split();
    reader.copy_into(&mut writer).await?;
    Ok(())
}

Safety

This crate uses unsafe internally around atomic access. Invariants around this are manually checked.

License

MIT OR Apache-2.0

Dependencies

~1.5MB
~24K SLoC