r2d2-alpm

Crates.ior2d2-alpm
lib.rsr2d2-alpm
version0.2.0
sourcesrc
created_at2022-02-17 03:31:17.208157
updated_at2024-03-18 22:38:20.714171
descriptionR2D2 resource pools for managing ALPM connections.
homepage
repositoryhttps://github.com/fosskers/aura
max_upload_size
id533764
size5,610
Colin Woodbury (fosskers)

documentation

README

r2d2-alpm

Types and utilities for the spawing of a r2d2::Pool that handles multiple connections to an Arch Linux Alpm database.

Usage

To create a Pool that delegates Alpm connections within (for instance) some Rayon threads:

use r2d2::Pool;
use r2d2_alpm::AlpmManager;
use rayon::prelude::*;

let mngr = AlpmManager::from_file("/etc/pacman.conf").unwrap();
let pool = Pool::builder().max_size(4).build(mngr).unwrap();

(0..10).into_par_iter().for_each(|n| {
    // `Pool::get` will wait for a configurable length
    // of time for a free connection before giving up.
    if let Ok(alpm) = pool.get() {
        // Use the ALPM handle freely here.
    }
});

Like std::sync::Arc, Pool is cheap to Clone, and can be passed around freely to subthreads.

License: MIT

Commit count: 2883

cargo fmt