Use a separate mutex to protect all_tasks, avoiding a lock-order-reversal