A Generic Logic for Proving Linearizability