case 1: if there is an ordering between setting and reading it, then there is no need for atomic;
case 2: if there is no ordering then /even with atomic/ the delete can see the unset value and the test is broken.
AFAICS the move of 'trigger()' ensures we have case 1 and atomic<> is therefore unnecessary.
In fact atomic<> is confusing: As Daniel says it implies we have case 2 (when it ensures is that the value loaded is "safe").
I see no value in making 'dispatcher' atomic:
case 1: if there is an ordering between setting and reading it, then there is no need for atomic;
case 2: if there is no ordering then /even with atomic/ the delete can see the unset value and the test is broken.
AFAICS the move of 'trigger()' ensures we have case 1 and atomic<> is therefore unnecessary.
In fact atomic<> is confusing: As Daniel says it implies we have case 2 (when it ensures is that the value loaded is "safe").