Struct jemalloc_ctl::thread::DeallocatedP[][src]

pub struct DeallocatedP(_);

A type providing access to the total number of bytes deallocated by the current thread.

The get method doesn't return the value directly, but actually a pointer to the value. This allows for very fast repeated lookup, since there is no function call overhead. The pointer type cannot be sent to other threads, but DeallocatedP::get can be called on different threads and will return the appropriate pointer for each of them.

Example

extern crate jemallocator;
extern crate jemalloc_ctl;

use jemalloc_ctl::thread::DeallocatedP;

#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

fn main() {
    let deallocated = DeallocatedP::new().unwrap();
    let deallocated = deallocated.get().unwrap();

    let a = deallocated.get();
    let buf = vec![0; 1024 * 1024];
    let b = deallocated.get();
    drop(buf);
    let c = deallocated.get();

    assert_eq!(a, b);
    assert!(b < c);
}

Methods

impl DeallocatedP
[src]

Returns a new Deallocated.

Returns a thread-local pointer to the total number of bytes deallocated by this thread.

Trait Implementations

impl Copy for DeallocatedP
[src]

impl Clone for DeallocatedP
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations