fn check_deleting()

in plasma-stream/src/server/sender.rs [133:160]


    fn check_deleting(&self) -> Result<(), ObjectSendError> {
        // ensure thread-safety by acquiring a lock to the set of objects scheduled for
        // deletion; `unwrap()` is OK here because no thread will panic wile holding the lock.
        let mut deleting = self.deleting.lock().unwrap();

        // check if any of the IDs are in the deleting set
        let mut in_deleting = Vec::new();
        for oid in self.object_ids.iter() {
            if deleting.contains(oid) {
                in_deleting.push(*oid);
            }
        }

        // if they were, return an error
        if !in_deleting.is_empty() {
            return Err(ObjectSendError::ObjectDeletionScheduled(
                self.peer_addr,
                in_deleting,
            ));
        }

        // update the deleting set if the objects will be deleted
        if self.delete_after_send {
            deleting.extend(self.object_ids.iter());
        }

        Ok(())
    }