.\" Automatically generated by Pandoc 2.0.6 .\" .TH "PMEM2_GET_FLUSH_FN" "3" "2022-08-25" "PMDK - pmem2 API version 1.0" "PMDK Programmer's Manual" .hy .\" SPDX-License-Identifier: BSD-3-Clause .\" Copyright 2020, Intel Corporation .SH NAME .PP \f[B]pmem2_get_flush_fn\f[]() \- get a flush function .SH SYNOPSIS .IP .nf \f[C] #include\ typedef\ void\ (*pmem2_flush_fn)(const\ void\ *ptr,\ size_t\ size); struct\ pmem2_map; pmem2_flush_fn\ pmem2_get_flush_fn(struct\ pmem2_map\ *map); \f[] .fi .SH DESCRIPTION .PP The \f[B]pmem2_get_flush_fn\f[]() function returns a pointer to a function responsible for efficiently flushing data in the range owned by the \f[I]map\f[]. .PP Flushing data using \f[I]pmem2_flush_fn\f[] \f[B]does not\f[] guarantee that the data is stored durably by the time it returns. To get this guarantee, application should either use the persist operation (see \f[B]pmem2_get_persist_fn\f[](3)) or follow \f[I]pmem2_flush_fn\f[] by a drain operation (see \f[B]pmem2_get_drain_fn\f[](3)). .PP There are no alignment restrictions on the range described by \f[I]ptr\f[] and \f[I]size\f[], but \f[I]pmem2_flush_fn\f[] may expand the range as necessary to meet platform alignment requirements. .PP There is nothing atomic or transactional about \f[I]pmem2_flush_fn\f[]. Any unwritten stores in the given range will be written, but some stores may have already been written by virtue of normal cache eviction/replacement policies. Correctly written code must not depend on stores waiting until \f[I]pmem2_flush_fn\f[] is called to be flushed \[en] they can be flushed at any time before \f[I]pmem2_flush_fn\f[] is called. .PP If two (or more) mappings share the same \f[I]pmem2_flush_fn\f[] and they are adjacent to each other, it is safe to call this function for a range spanning those mappings. .SH RETURN VALUE .PP The \f[B]pmem2_get_flush_fn\f[]() function never returns NULL. .PP The \f[B]pmem2_get_flush_fn\f[]() for the same \f[I]map\f[] always returns the same function. This means that it's safe to cache its return value. However, this function is very cheap (because it returns a precomputed value), so caching may not be necessary. .SH SEE ALSO .PP \f[B]pmem2_get_drain_fn\f[](3), \f[B]pmem2_get_persist_fn\f[](3), \f[B]pmem2_map_new\f[](3), \f[B]libpmem2\f[](7) and \f[B]\f[]