ComputationalRadiationPhysics / redGrapes

Resource-based, Declarative task-Graphs for Parallel, Event-driven Scheduling :grapes:
https://redgrapes.rtfd.io
Mozilla Public License 2.0
20 stars 5 forks source link

Task refcounting #41

Open michaelsippel opened 10 months ago

michaelsippel commented 10 months ago

Tasks are handled by a plain pointer and destruction of a Task is controlled by Event::notify(). It uses an atomic count, a somewhat whacky refcount which only counts down on the two events which could ever possibly end the lifetime of a task: post_event or result_get_event. (In case the result of a task needs to be kept in the future , because the value wasnt retrieved from the future yet)

However in delete_from_resources() and init_graph() there is still an additional lock required in order to avoid the creation of a dependency in the scheduling graph to some Task which is currently being destroyed. Adding proper refcounting to Tasks would deprecate the need for this spinlock. It should be considered to avoid unneccesary increment/decrement on the atomic counter.