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:
Matthew Parkinson
2019-07-15 17:49:40 +01:00
parent df1896d55f
commit 280c2ae25c
2 changed files with 113 additions and 125 deletions

View File

@@ -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