Refactor ThreadAlloc
Made common code between the Libc and C++ based releasing of allocators part of a parent class, which each implementation subclasses.
This commit is contained in:
@@ -87,4 +87,17 @@ namespace snmalloc
|
||||
return array[i & (rlength - 1)];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper class to execute a specified function on destruction.
|
||||
*/
|
||||
template<void f()>
|
||||
class OnDestruct
|
||||
{
|
||||
public:
|
||||
~OnDestruct()
|
||||
{
|
||||
f();
|
||||
}
|
||||
};
|
||||
} // namespace snmalloc
|
||||
|
||||
Reference in New Issue
Block a user