#arch-linux

r2d2-alpm

R2D2 resource pools for managing ALPM connections

3 unstable releases

0.2.1 Sep 14, 2024
0.2.0 Mar 18, 2024
0.1.0 Feb 17, 2022

#405 in Unix APIs

Download history 3/week @ 2024-07-08 7/week @ 2024-07-15 6/week @ 2024-07-22 35/week @ 2024-07-29 19/week @ 2024-08-05 8/week @ 2024-08-12 5/week @ 2024-08-19 14/week @ 2024-09-02 182/week @ 2024-09-09 84/week @ 2024-09-16 43/week @ 2024-09-23 24/week @ 2024-09-30 11/week @ 2024-10-07 10/week @ 2024-10-14

96 downloads per month
Used in 2 crates

MIT and GPL-3.0 licenses

6KB
55 lines

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


lib.rs:

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.

Dependencies

~1.2–6MB
~32K SLoC