Make the crate no_std (#15)
* Remove crossbeam
* Rewrite notification and registration
* Make crate no_std
* Add a comment
diff --git a/src/join_handle.rs b/src/join_handle.rs
index 9357d32..49d529b 100644
--- a/src/join_handle.rs
+++ b/src/join_handle.rs
@@ -1,10 +1,10 @@
-use std::fmt;
-use std::future::Future;
-use std::marker::{PhantomData, Unpin};
-use std::pin::Pin;
-use std::ptr::NonNull;
-use std::sync::atomic::Ordering;
-use std::task::{Context, Poll};
+use core::fmt;
+use core::future::Future;
+use core::marker::{PhantomData, Unpin};
+use core::pin::Pin;
+use core::ptr::NonNull;
+use core::sync::atomic::Ordering;
+use core::task::{Context, Poll};
use crate::header::Header;
use crate::state::*;
@@ -71,7 +71,7 @@
// Notify the awaiter that the task has been closed.
if state & AWAITER != 0 {
- (*header).notify();
+ (*header).notify(None);
}
break;
@@ -190,7 +190,7 @@
if state & CLOSED != 0 {
// Even though the awaiter is most likely the current task, it could also be
// another task.
- (*header).notify_unless(cx.waker());
+ (*header).notify(Some(cx.waker()));
return Poll::Ready(None);
}
@@ -199,7 +199,7 @@
// Replace the waker with one associated with the current task. We need a
// safeguard against panics because dropping the previous waker can panic.
abort_on_panic(|| {
- (*header).swap_awaiter(Some(cx.waker().clone()));
+ (*header).register(cx.waker());
});
// Reload the state after registering. It is possible that the task became
@@ -230,7 +230,7 @@
// Notify the awaiter. Even though the awaiter is most likely the current
// task, it could also be another task.
if state & AWAITER != 0 {
- (*header).notify_unless(cx.waker());
+ (*header).notify(Some(cx.waker()));
}
// Take the output from the task.