Last active
May 30, 2019 13:37
-
-
Save jrhemstad/66b74024c2a5d78294035a6905b65ff8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace detail | |
{ | |
inline memory_resource* default_resource(){ | |
static memory_resource res(); | |
return &res; | |
} | |
inline std::atomic<memory_resource*>& get_global() | |
{ | |
static std::atomic<memory_resource*> global{default_resource()}; | |
return global; | |
} | |
} | |
inline memory_resource<> * get_global_resource() | |
{ | |
return std::atomic_load_explicit(&get_global(), std::memory_order::memory_order_acquire); | |
} | |
inline void set_global_resource(memory_resource * new_res) | |
{ | |
std::atomic_exchange_explicit(&get_global(), new_res, std::memory_order::memory_order_acq_rel); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment