Types and utilities for the spawing of a r2d2::Pool
that handles
multiple connections to an Arch Linux Alpm
database.
To create a Pool
that delegates Alpm
connections within (for instance)
some Rayon threads:
```rust use r2d2::Pool; use r2d2_alpm::AlpmManager; use rayon::prelude::*;
let mngr = AlpmManager::fromfile("/etc/pacman.conf").unwrap(); let pool = Pool::builder().maxsize(4).build(mngr).unwrap();
(0..10).intopariter().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