davenport 0.1.1

Ergonomic thread-local workspaces for intermediate data
Documentation
  • Coverage
  • 55.56%
    5 out of 9 items documented1 out of 8 items with examples
  • Size
  • Source code size: 27.32 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 443.73 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Andlon/davenport
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Andlon

davenport

davenport is a Rust microcrate that provides ergonomic thread-local workspaces for intermediate data.

use davenport::{define_thread_local_workspace, with_thread_local_workspace};

#[derive(Default)]
pub struct MyWorkspace {
    index_buffer: Vec<usize>
}

define_thread_local_workspace!(WORKSPACE);

fn median_floor(indices: &[usize]) -> Option<usize> {
    with_thread_local_workspace(&WORKSPACE, |workspace: &mut MyWorkspace| {
        // Re-use buffer from previous call to this function
        let buffer = &mut workspace.index_buffer;
        buffer.clear();
        buffer.copy_from_slice(&indices);
        buffer.sort_unstable();
        buffer.get(indices.len() / 2).copied()
    })
}

See the documentation for an in-depth explanation of the crate.

License

Licensed under the terms of both MIT and Apache 2.0 at your option. See LICENSE-MIT and LICENSE-APACHE for the detailed license text.