Skip to content

Commit b05d7b5

Browse files
authored
cancel cursor actor on drop (#1041)
1 parent 1ca1fa7 commit b05d7b5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

crates/recording/src/cursor.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use cap_project::{CursorClickEvent, CursorMoveEvent, XY};
44
use cap_timestamp::Timestamps;
55
use std::{collections::HashMap, path::PathBuf};
66
use tokio::sync::oneshot;
7-
use tokio_util::sync::CancellationToken;
7+
use tokio_util::sync::{CancellationToken, DropGuard};
88

99
pub struct Cursor {
1010
pub file_name: String,
@@ -24,13 +24,13 @@ pub struct CursorActorResponse {
2424
}
2525

2626
pub struct CursorActor {
27-
stop: CancellationToken,
27+
stop: DropGuard,
2828
rx: oneshot::Receiver<CursorActorResponse>,
2929
}
3030

3131
impl CursorActor {
3232
pub async fn stop(self) -> CursorActorResponse {
33-
self.stop.cancel();
33+
drop(self.stop);
3434
self.rx.await.unwrap()
3535
}
3636
}
@@ -180,7 +180,7 @@ pub fn spawn_cursor_recorder(
180180
});
181181

182182
CursorActor {
183-
stop: stop_token,
183+
stop: stop_token.drop_guard(),
184184
rx,
185185
}
186186
}

0 commit comments

Comments
 (0)