PMEM2_GET_DRAIN_FN(3)

✨ pmem2_get_drain_fn() β€” get a drain function ✨

okay bestie, welcome to the PMDK Programmer's Manual πŸ’– this one's a lil baby page but it's IMPORTANT, so grab your iced coffee and let's go 🧚


🌸 NAME 🌸

pmem2_get_drain_fn() β€” get a drain function


πŸŽ€ SYNOPSIS πŸŽ€

#include <libpmem2.h>

typedef void (*pmem2_drain_fn)(void);

struct pmem2_map;

pmem2_drain_fn pmem2_get_drain_fn(struct pmem2_map *map);

πŸ’… DESCRIPTION πŸ’…

so. pmem2_get_drain_fn() hands you back a pointer to a function β€” and that function's whole job is to drain flushes efficiently (the flushes from pmem2_get_flush_fn(3), iykyk) in the range that map owns. πŸ‘‘

and what does "draining" even mean here, bestie? it means making sure the flushes that happened before this operation don't get reordered to after it. periodt. πŸ”₯

ngl it's not strictly true, but you can lowkey think of draining as just waiting for the previous flushes to finish. that's the vibe. ✨

also β€” and this is the good part β€” if two (or more) mappings share the same drain function, it is safe to call this function once for all flushes belonging to those mappings. no cap. 🫢


🌈 RETURN VALUE 🌈

pmem2_get_drain_fn() never returns NULL. not ever. πŸ’€πŸ™ˆ

and for the same map, it always returns the same function. which means it's totally safe to cache its return value, bestie β€” go off. πŸ’…

that said… this function is very cheap (it just returns a precomputed value, main character behavior honestly), so caching might not even be necessary. your call. πŸ¦‹


⭐ SEE ALSO ⭐


πŸ’Œ and that's the whole page, bestie β€” go drain those flushes and slay πŸ’–

this icon was brought to you by PMDK, dated 2025-07-24 β€” mwah, catch you in the next manpage πŸŽ€πŸŒΈβœ¨

πŸ“¦ where this page comes from