#parallel #status #bar

nightly bin+lib parsli

Parallel status lines for Rust

8 releases

0.1.4 Aug 18, 2023
0.1.3 Aug 18, 2023
0.1.2 Dec 21, 2022
0.0.3 Jun 21, 2022

#498 in Concurrency

Download history 1/week @ 2023-11-08 2/week @ 2023-11-15 10/week @ 2023-11-22 26/week @ 2023-11-29 9/week @ 2023-12-06 16/week @ 2023-12-20 16/week @ 2023-12-27 6/week @ 2024-01-17 9/week @ 2024-01-24 8/week @ 2024-01-31 1/week @ 2024-02-07 67/week @ 2024-02-14 287/week @ 2024-02-21

371 downloads per month

MIT license

406 lines

Parallel Status Lines

crates.io rustc

parsli is an opinionated Rust library to visualize the execution of dependent tasks. It is designed to be as flexible as possible, while abstracting away the management of dependencies and command-line visualization.


Everything is managed through the ThreadPool struct, which takes care of dependencies and status lines.

use parsli::ThreadPool;

// Execute 4 tasks in parallel
let mut pool = ThreadPool::new(4);

A task has a name, dependencies and some function it has to execute. This function takes three arguments

  • line: The status line of this thread that can be controlled.
  • name: The name of this task.
  • ctx: A hashmap with results of the tasks this one depends oni. This is a basic example on how to instantiate a task.
use std::thread::sleep;
use std::time::Duration;
use parsli::{Task, Line, Ctx};

let mytask = Task::new(|line: Line, name: String, ctx: Ctx<String>| {
    Ok("this is the result".to_string())

Tasks can be added to the pool with the ThreadPool::add_task function.

pool.add_task("mytask", vec![], mytask);

When all tasks have been added to the pool, it can be started with ThreadPool::start.


Full example

use std::thread::sleep;
use std::time::Duration;
use parsli::{Ctx, Line, ThreadPool, Task};

/// This is a minimal example on how to use parsli
fn main() {
    let mut pool = ThreadPool::new(4);
    let dummy = Task::new(|line: Line, name: String, ctx: Ctx<String>| {
        sleep(Duration::from_millis(1000 + 10 * (rand::random::<u8>() as u64)));
        if name != "clang.install".to_string() {
            Ok("this is the result".to_string())
        } else {
            Err("this task went terribly wrong".to_string())
    pool.add_task("llvm.fetch", vec![], dummy.clone());
    pool.add_task("clang.configure", vec!["llvm.fetch"], dummy.clone());
    pool.add_task("compiler-rt.configure", vec!["llvm.fetch"], dummy.clone());
    pool.add_task("clang.compile", vec!["clang.configure"], dummy.clone());
    pool.add_task("compiler-rt.compile", vec!["compiler-rt.configure"], dummy.clone());
    pool.add_task("clang.install", vec!["clang.compile"], dummy.clone());
    pool.add_task("compiler-rt.install", vec!["compiler-rt.compile"], dummy.clone());



~107K SLoC