Use the provided atomic method to replace the attachment and return a reference to the old value rather than doing the same thing in a thread unsafe manner.