adding bounded arena allocator to renderer
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
//! Atomic based spin mutex
|
||||
const std = @import("std");
|
||||
|
||||
mutex: std.atomic.Mutex = .unlocked,
|
||||
|
||||
pub fn lock(self: *@This()) void {
|
||||
if (self.mutex.tryLock()) {
|
||||
@branchHint(.likely);
|
||||
return;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if (self.mutex.tryLock()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unlock(self: *@This()) void {
|
||||
self.mutex.unlock();
|
||||
}
|
||||
Reference in New Issue
Block a user