memory-pool

Crates.iomemory-pool
lib.rsmemory-pool
version0.1.0
sourcesrc
created_at2015-05-03 11:22:39.846869
updated_at2015-12-11 23:54:10.497015
descriptionA global, thread-safe memory pool.
homepagehttps://github.com/koute/memory-pool
repositoryhttps://github.com/koute/memory-pool
max_upload_size
id2009
size8,433
Koute (koute)

documentation

README

A global, thread-safe memory pool

A Rust library providing a global, thread-safe memory pool, ideal for when you need a temporary scratch buffer but you don't want to be constantly allocating memory.

memory_pool::borrow( |aux: &mut String| {
    aux.push_str( "Do you like cupcakes?" );
});
memory_pool::borrow( |vec: &mut Vec< u32 >| {
    vec.push( 1 );
    vec.push( 2 );
    vec.push( 3 );
});

You can also manually acquire and release memory:

let buffer: String = memory_pool::acquire();
buffer.push_str( "I like cupcakes!" );
memory_pool::release( buffer );

Usage

Add this to your Cargo.toml:

[dependencies]
memory-pool = "0.0.1"

Then add this to your crate root:

extern crate memory_pool;
Commit count: 4

cargo fmt