Replace uses of std::function by function_ref.
This commit is contained in:
@@ -62,7 +62,7 @@ namespace snmalloc
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4702)
|
||||
# endif
|
||||
SNMALLOC_FAST_PATH void* init_thread_allocator(std::function<void*(void*)>& f)
|
||||
SNMALLOC_FAST_PATH void* init_thread_allocator(function_ref<void*(void*)> f)
|
||||
{
|
||||
error("Critical Error: This should never be called.");
|
||||
return f(nullptr);
|
||||
@@ -101,7 +101,7 @@ namespace snmalloc
|
||||
*/
|
||||
class ThreadAllocCommon
|
||||
{
|
||||
friend void* init_thread_allocator(std::function<void*(void*)>&);
|
||||
friend void* init_thread_allocator(function_ref<void*(void*)>);
|
||||
|
||||
protected:
|
||||
/**
|
||||
@@ -195,12 +195,11 @@ namespace snmalloc
|
||||
auto*& alloc = get_reference();
|
||||
if (unlikely(needs_initialisation(alloc)) && !destructor_has_run)
|
||||
{
|
||||
std::function<void*(void*)> f = [](void*) { return nullptr; };
|
||||
// Call `init_thread_allocator` to perform down call in case
|
||||
// register_clean_up does more.
|
||||
// During teardown for the destructor based ThreadAlloc this will set
|
||||
// alloc to GlobalPlaceHolder;
|
||||
init_thread_allocator(f);
|
||||
init_thread_allocator([](void*) { return nullptr; });
|
||||
}
|
||||
return alloc;
|
||||
# endif
|
||||
@@ -277,7 +276,7 @@ namespace snmalloc
|
||||
* path.
|
||||
* The second component of the return indicates if this TLS is being torndown.
|
||||
*/
|
||||
SNMALLOC_FAST_PATH void* init_thread_allocator(std::function<void*(void*)>& f)
|
||||
SNMALLOC_FAST_PATH void* init_thread_allocator(function_ref<void*(void*)> f)
|
||||
{
|
||||
auto*& local_alloc = ThreadAlloc::get_reference();
|
||||
// If someone reuses a noncachable call, then we can end up here
|
||||
|
||||
Reference in New Issue
Block a user