Skip to content

Commit fcc055c

Browse files
George-Miaodrmingdrmer
authored andcommitted
feat: hide internal detail of CompioJoinHandle
1 parent d3f0232 commit fcc055c

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

rt-compio/src/lib.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,22 @@ mod watch;
2828
pub struct CompioRuntime;
2929

3030
#[derive(Debug)]
31-
pub struct CompioJoinError(pub Box<dyn Any + Send>);
31+
pub struct CompioJoinError(Box<dyn Any + Send>);
3232

3333
impl Display for CompioJoinError {
3434
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
3535
write!(f, "Spawned task panicked")
3636
}
3737
}
3838

39-
pub struct CompioJoinHandle<T>(pub Option<compio::runtime::JoinHandle<T>>);
40-
41-
impl<T> CompioJoinHandle<T> {
42-
pub fn cancel(mut self) {
43-
if let Some(task) = self.0.take() {
44-
task.cancel();
45-
}
46-
}
47-
}
39+
pub struct CompioJoinHandle<T>(Option<compio::runtime::JoinHandle<T>>);
4840

4941
impl<T> Drop for CompioJoinHandle<T> {
5042
fn drop(&mut self) {
51-
if let Some(task) = self.0.take() {
52-
task.detach();
43+
let Some(j) = self.0.take() else {
44+
return;
5345
}
46+
j.detach();
5447
}
5548
}
5649

@@ -68,12 +61,6 @@ impl<T> Future for CompioJoinHandle<T> {
6861
}
6962
}
7063

71-
impl<T> FusedFuture for CompioJoinHandle<T> {
72-
fn is_terminated(&self) -> bool {
73-
self.0.is_none()
74-
}
75-
}
76-
7764
pub type BoxedFuture<T> = Pin<Box<dyn Future<Output = T>>>;
7865

7966
pin_project_lite::pin_project! {

0 commit comments

Comments
 (0)