mod env;
pub use env::*;
mod attr;
pub use attr::*;
mod future;
pub use future::*;
mod fdset;
pub(crate) use fdset::*;
mod status;
mod waker;
mod context;
pub use context::*;
mod task;
pub(crate) use task::*;
mod raw;
pub use raw::*;
mod join;
pub use join::*;
mod queue;
pub(crate) use queue::*;
mod builder;
pub use builder::*;
mod worker;
pub(crate) use worker::*;
mod group;
pub use group::Group as Runtime;
pub(crate) use group::*;
mod sender;
pub(crate) use sender::*;
mod sched;
pub use sched::*;
mod mutex;
pub use mutex::*;
use core::mem::ManuallyDrop;
use core::ops::{Deref, DerefMut};
use core::ptr::NonNull;
pub(crate) struct TaskRef {
task: NonNull<RawTask>,
}
unsafe impl Send for TaskRef {}
impl Drop for TaskRef {
fn drop(&mut self) {
self.dec_ref();
}
}
impl Clone for TaskRef {
fn clone(&self) -> Self {
self.inc_ref();
Self { task: self.task }
}
}
impl TaskRef {
pub fn new(task: NonNull<RawTask>) -> Self {
Self { task }
}
pub unsafe fn from(task: *mut RawTask) -> Self {
Self {
task: NonNull::new_unchecked(task),
}
}
pub fn leak(self) -> *mut RawTask {
ManuallyDrop::new(self).task.as_ptr()
}
}
impl Deref for TaskRef {
type Target = RawTask;
fn deref(&self) -> &Self::Target {
unsafe { self.task.as_ref() }
}
}
impl DerefMut for TaskRef {
fn deref_mut(&mut self) -> &mut Self::Target {
unsafe { self.task.as_mut() }
}
}