Skip to content
Snippets Groups Projects
Commit a2ed7beb authored by Per Lindgren's avatar Per Lindgren
Browse files

pool using cs

parents 3d3557f9 a93a4ca1
No related branches found
No related tags found
No related merge requests found
use core::mem;
use poolman::PoolMan;
static P: PoolMan<u32, 2> = PoolMan::new([0; 2]);
fn main() {
P.init();
{
let e = P.alloc().unwrap();
println!("e {}", *e);
mem::drop(e);
let mut e1 = P.alloc().unwrap();
println!("e1 {}", *e1);
*e1 = 2;
println!("e1 {}", *e1);
let e2 = P.alloc().unwrap();
println!("e2 {}", *e2);
}
let e = P.alloc().unwrap();
println!("e {}", *e);
}
use core::mem;
use poolman::PoolMan;
#[derive(Debug)]
struct IDrop(u32);
impl core::ops::Drop for IDrop {
fn drop(&mut self) {
println!("drop value: {}", self.0);
}
}
static P: PoolMan<IDrop, 2> = PoolMan::new([IDrop(10), IDrop(11)]);
fn main() {
P.init();
{
let e = P.alloc().unwrap();
println!("e {:?}", *e);
mem::drop(e);
let mut e1 = P.alloc().unwrap();
println!("e1 {:?}", *e1);
*e1 = IDrop(2);
println!("e1 {:?}", *e1);
let e2 = P.alloc().unwrap();
println!("e2 {:?}", *e2);
}
let e = P.alloc().unwrap();
println!("e {:?}", *e);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment