Function pmem::msync [] [src]

pub fn msync<T>(x: &T) -> Result<(), Error>

Forces any changes in an object to be stored durably.

This function works on either persistent memory or a memory mapped file on traditional storage. msync() takes steps to ensure the alignment of addresses and lengths passed down meet the requirements of that system call. It calls msync() with the MS_SYNC flag as described in msync(2). Typically the application only checks for the existence of persistent memory once, and then uses that result throughout the program, for example:

Example

fn some_method<T>(x: &T) {
    // do this call once, after the pmem is memory mapped
    let is_pmem = pmem::is_pmem(x);

    // ...make some changes to x

    // make the changes durable
    if is_pmem {
        pmem::persist(&x);
    } else{
        pmem::msync(&x).unwrap();
    }
}