24 lines
662 B
Rust
24 lines
662 B
Rust
//! Removes client RPC registrations when their call completes or is canceled.
|
|
//! The pending map is locked only for synchronous bookkeeping, including in Drop.
|
|
|
|
use std::collections::HashMap;
|
|
use std::sync::Mutex;
|
|
|
|
use akode_exec_server_protocol::RequestId;
|
|
|
|
use super::PendingRequest;
|
|
|
|
pub(super) struct PendingRequestGuard<'a> {
|
|
pub(super) pending: &'a Mutex<HashMap<RequestId, PendingRequest>>,
|
|
pub(super) request_id: RequestId,
|
|
}
|
|
|
|
impl Drop for PendingRequestGuard<'_> {
|
|
fn drop(&mut self) {
|
|
self.pending
|
|
.lock()
|
|
.unwrap_or_else(std::sync::PoisonError::into_inner)
|
|
.remove(&self.request_id);
|
|
}
|
|
}
|