Disclaimer: I'm looking for an alternative to using mutex's or shared_ptr to solve this problem.
At the moment I'm using raw pointers in a tree model and the way my model works is that elements are put into a bin (and marked as such) before they are deleted. Once something is in the bin, there's no way to access it, so I'm wondering whether tbb provides any way that I can schedule the deletion such that once all the current tasks are finished, the bin's elements can be deleted.
This works because whilst I can't guarantee that the current tasks don't reference those elements, I can guarantee that any tasks created after that point won't be referencing those elements. Ideally I would like to not stop other tasks from starting. It's almost like I'm saying "When all the current tasks are finished (ignoring any tasks created after this point), run this function/delete this bin."
I'm guessing this is way out of left field and not possible at all, but I thought I'd ask.