lib: Add epoch-based SMR
This commit is contained in:
@@ -29,6 +29,15 @@ void page_hold(struct page* page) {
|
||||
atomic_fetch_add(&page->holds, 1, ATOMIC_RELAXED);
|
||||
}
|
||||
|
||||
bool page_try_hold(struct page* page) {
|
||||
size_t holds = atomic_load(&page->holds, ATOMIC_RELAXED);
|
||||
while (holds) {
|
||||
if (atomic_compare_exchange_weak(&page->holds, &holds, holds + 1, ATOMIC_ACQUIRE, ATOMIC_RELAXED))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void page_unhold(struct page* page) {
|
||||
if (atomic_fetch_sub(&page->holds, 1, ATOMIC_RELEASE) != 1)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user