Macro corundum::pool [−][src]
macro_rules! pool { ($name : ident) => { ... }; }
Expand description
This macro creates a new pool module and aliases for persistent types. It
generates type BuddyAlloc
which a persistent allocator type. It is
recommended to alias the BuddyAlloc
type for tidiness.
The aliased types are
Pbox<T>
=corundum::boxed::Pbox
<T,
BuddyAlloc
>
Prc<T>
=corundum::prc::Prc
<T,
BuddyAlloc
>
Parc<T>
=corundum::sync::Parc
<T,
BuddyAlloc
>
PMutex<T>
=corundum::sync::PMutex
<T,
BuddyAlloc
>
PCell<T>
=corundum::cell::PCell
<T,
BuddyAlloc
>
PRefCell<T>
=corundum::cell::PRefCell
<T,
BuddyAlloc
>
VCell<T>
=corundum::cell::VCell
<T,
BuddyAlloc
>
TCell<T>
=corundum::cell::TCell
<T,
BuddyAlloc
>
PVec<T>
=corundum::vec::Vec
<T,
BuddyAlloc
>
PString
=corundum::str::String
<
BuddyAlloc
>
Examples
To associate a single pool to the program, it is enough to define a pool type using this macro.
corundum::pool!(my_alloc); use my_alloc::*; type P = BuddyAlloc; let _pool = P::open_no_root("p.pool", O_CF).unwrap(); P::transaction(|j| { let temp = Pbox::new(10, j); }).unwrap();
If multiple pools are needed, multiple pool modules can be defined and used.
use corundum::alloc::heap::*; corundum::pool!(pool1); corundum::pool!(pool2); type P1 = pool1::BuddyAlloc; type P2 = pool2::BuddyAlloc; let _p1 = P1::open_no_root("p1.pool", O_CF).unwrap(); let _p2 = P2::open_no_root("p2.pool", O_CF).unwrap(); P1::transaction(|j1| { let temp = pool1::Pbox::new(10, j1); P2::transaction(|j2| { let temp = pool2::Pbox::new(20, j2); }).unwrap(); }).unwrap();