Removes all occurrences of an item from an array safely, ensuring that only
exact matches are removed.
In concurrent scenarios, it's possible that the item at a found index may have
changed before the removal occurs. This function checks that the removed item
is indeed the one intended for removal, and if not, it re-inserts it back into
the array.
Removes all occurrences of an item from an array safely, ensuring that only exact matches are removed.
In concurrent scenarios, it's possible that the item at a found index may have changed before the removal occurs. This function checks that the removed item is indeed the one intended for removal, and if not, it re-inserts it back into the array.