The test doesn't need to be atomic, since only one thread will free it if they both atomically decrement and then compare against 0 afterward.