363361 (7) [Avatar] Offline
#1
Chapter 7 Listing 7.5 lock_free_stack::pop

Quick question. After this line in lock_free_stack::try_reclaim

node *nodes_to_delete = to_be_deleted.exchange(nullptr);


Isn't the current thread the only one with a pointer to nodes_to_delete? So why isn't it safe to delete nodes_to_delete at this point even if threads_in_pop is greater than zero?

Thanks,
363361 (7) [Avatar] Offline
#2
Sorry - this question is answered further in the text book.