https://github.com/koute/memory-pool
A global, thread-safe memory pool.
https://github.com/koute/memory-pool
Last synced: about 1 year ago
JSON representation
A global, thread-safe memory pool.
- Host: GitHub
- URL: https://github.com/koute/memory-pool
- Owner: koute
- License: mit
- Created: 2015-05-03T11:20:58.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-05-03T11:38:25.000Z (about 11 years ago)
- Last Synced: 2025-03-25T04:26:50.742Z (about 1 year ago)
- Language: Rust
- Size: 113 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# A global, thread-safe memory pool
[](https://travis-ci.org/koute/memory-pool)
[API documentation](https://koute.github.io/memory-pool/memory_pool/index.html)
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.
```rust
memory_pool::borrow( |aux: &mut String| {
aux.push_str( "Do you like cupcakes?" );
});
```
```rust
memory_pool::borrow( |vec: &mut Vec< u32 >| {
vec.push( 1 );
vec.push( 2 );
vec.push( 3 );
});
```
You can also manually acquire and release memory:
```rust
let mut buffer: String = memory_pool::acquire();
buffer.push_str( "I like cupcakes!" );
memory_pool::release( buffer );
```
## Usage
Add this to your `Cargo.toml`:
```toml
[dependencies]
memory-pool = "0.1.0"
```
Then add this to your crate root:
```rust
extern crate memory_pool;
```