From de558b80d4524c7aa3d266cbba6de206afa2c93d Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Fri, 8 Dec 2023 10:25:26 +0100 Subject: [PATCH] move TaskSpaceDeleter & ItemControlBlockDeleter definitions to place where TaskSpace & ItemControlBlock are complete types Signed-off-by: Michael Sippel --- redGrapes/task/task_space.cpp | 5 +++++ redGrapes/task/task_space.hpp | 10 +++++----- redGrapes/util/atomic_list.hpp | 20 ++++++++++++-------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/redGrapes/task/task_space.cpp b/redGrapes/task/task_space.cpp index 98c49a5f..50d917d7 100644 --- a/redGrapes/task/task_space.cpp +++ b/redGrapes/task/task_space.cpp @@ -16,6 +16,11 @@ namespace redGrapes { +void TaskSpaceDeleter::operator() ( TaskSpace * s ) + { + delete s; + } + TaskSpace::~TaskSpace() { } diff --git a/redGrapes/task/task_space.hpp b/redGrapes/task/task_space.hpp index 1aed1df8..1daa960d 100644 --- a/redGrapes/task/task_space.hpp +++ b/redGrapes/task/task_space.hpp @@ -28,12 +28,12 @@ namespace redGrapes struct Task; struct TaskSpace; -struct TaskSpaceDeleter { - void operator() ( TaskSpace * space ) { - delete space; - } -}; +struct TaskSpaceDeleter +{ + void operator() ( TaskSpace * space ); +}; + /*! TaskSpace handles sub-taskspaces of child tasks */ struct TaskSpace diff --git a/redGrapes/util/atomic_list.hpp b/redGrapes/util/atomic_list.hpp index bf339eef..023b0c03 100644 --- a/redGrapes/util/atomic_list.hpp +++ b/redGrapes/util/atomic_list.hpp @@ -45,16 +45,9 @@ template < struct AtomicList { struct ItemControlBlock; - struct ItemControlBlockDeleter { - void operator() ( ItemControlBlock * e ) - { - auto alloc = e->alloc; - e->~ItemControlBlock(); - memory::Block blk { (uintptr_t)e, sizeof(ItemControlBlock)+sizeof(Item) }; - alloc.deallocate( blk ); - } + void operator() ( ItemControlBlock* ); }; struct ItemControlBlock : Refcounted< ItemControlBlock, ItemControlBlockDeleter > @@ -267,6 +260,17 @@ struct AtomicList }; + +template < typename Item, typename Allocator > +void AtomicList< Item, Allocator >::ItemControlBlockDeleter::operator() ( AtomicList< Item, Allocator >::ItemControlBlock * e ) +{ + Allocator alloc = e->alloc; + e->~ItemControlBlock(); + memory::Block blk { (uintptr_t)e, 0 }; + spdlog::info("atomic list deallocate {}", blk.ptr); + alloc.deallocate( blk ); +} + } // namespace memory } // namespace redGrapes