Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

cancel cursor actor on drop (#1041)

Brendan Allanb05d7b5ed7ba
diff --git a/crates/recording/src/cursor.rs b/crates/recording/src/cursor.rs
index c17e1c186..fb8a83de3 100644
--- a/crates/recording/src/cursor.rs
+++ b/crates/recording/src/cursor.rs
@@ -4,7 +4,7 @@ use cap_project::{CursorClickEvent, CursorMoveEvent, XY};
use cap_timestamp::Timestamps;
use std::{collections::HashMap, path::PathBuf};
use tokio::sync::oneshot;
-use tokio_util::sync::CancellationToken;
+use tokio_util::sync::{CancellationToken, DropGuard};
pub struct Cursor {
pub file_name: String,
@@ -24,13 +24,13 @@ pub struct CursorActorResponse {
}
pub struct CursorActor {
- stop: CancellationToken,
+ stop: DropGuard,
rx: oneshot::Receiver<CursorActorResponse>,
}
impl CursorActor {
pub async fn stop(self) -> CursorActorResponse {
- self.stop.cancel();
+ drop(self.stop);
self.rx.await.unwrap()
}
}
@@ -180,7 +180,7 @@ pub fn spawn_cursor_recorder(
});
CursorActor {
- stop: stop_token,
+ stop: stop_token.drop_guard(),
rx,
}
}