Task only becomes ready when the future is dropped
diff --git a/src/task.rs b/src/task.rs
index 7a1a5e0..d4da255 100644
--- a/src/task.rs
+++ b/src/task.rs
@@ -4,10 +4,12 @@
use core::mem::{self, ManuallyDrop};
use core::pin::Pin;
use core::ptr::NonNull;
+use core::sync::atomic::Ordering;
use core::task::{Context, Poll, Waker};
use crate::header::Header;
use crate::raw::RawTask;
+use crate::state::*;
use crate::JoinHandle;
/// Creates a new task.
@@ -315,6 +317,14 @@
// Drop the future.
((*header).vtable.drop_future)(ptr);
+ // Mark the task as unscheduled.
+ let state = (*header).state.fetch_and(!SCHEDULED, Ordering::AcqRel);
+
+ // Notify the awaiter that the future has been dropped.
+ if state & AWAITER != 0 {
+ (*header).notify(None);
+ }
+
// Drop the task reference.
((*header).vtable.drop_task)(ptr);
}