3.4.5. Garbage collection

When a task is being removed it is necessary that threads that have the task in their nbor list can access it, until they have finished updating, and removed the task from their nbor list. This is achieved by maintaining a count task_t%n_needed, which keeps track of how many threads that currently have the task in their nbor lists.

Tasks that are removed by derifinement are therefor kept on a garbage list until the count has dropped to zero.

There are only two procedure that create or delete nbor lists: init_nbors, and remove_nbor_list. These maintain the n_neeeded count, using atomic increments and decrements.