mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-06 19:38:41 +03:00
wip: initial delayed purging of arenas
This commit is contained in:
parent
bd66d54765
commit
7cf60deb12
5 changed files with 202 additions and 13 deletions
|
@ -284,6 +284,17 @@ static inline bool mi_atomic_once( mi_atomic_once_t* once ) {
|
|||
return mi_atomic_cas_strong_acq_rel(once, &expected, 1); // try to set to 1
|
||||
}
|
||||
|
||||
typedef _Atomic(uintptr_t) mi_atomic_guard_t;
|
||||
|
||||
// Allows only one thread to execute at a time
|
||||
#define mi_atomic_guard(guard) \
|
||||
uintptr_t _mi_guard_expected = 0; \
|
||||
for(bool _mi_guard_once = true; \
|
||||
_mi_guard_once && mi_atomic_cas_strong_acq_rel(guard,&_mi_guard_expected,1); \
|
||||
(mi_atomic_store_release(guard,0), _mi_guard_once = false) )
|
||||
|
||||
|
||||
|
||||
// Yield
|
||||
#if defined(__cplusplus)
|
||||
#include <thread>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue