From c93e2f55f2ec64a464eb61fc3c1f2f0c5fa4afbe 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 --- redGrapes/task/task_space.cpp | 5 +++++ redGrapes/task/task_space.hpp | 10 +++++----- redGrapes/util/atomic_list.hpp | 21 ++++++++++++--------- 3 files changed, 22 insertions(+), 14 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 fa14b6e7..61619285 100644 --- a/redGrapes/util/atomic_list.hpp +++ b/redGrapes/util/atomic_list.hpp @@ -45,17 +45,10 @@ template < > struct AtomicList { - struct ItemControlBlock; - + 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 > @@ -306,6 +299,16 @@ 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 }; + alloc.deallocate( blk ); +} + } // namespace memory } // namespace redGrapes