From a48bec700add1c50997bd1f1fbdc3823212f0a31 Mon Sep 17 00:00:00 2001 From: Mahmut Bulut Date: Sat, 12 Oct 2019 19:50:11 +0200 Subject: [PATCH] Stub --- lightproc/src/lib.rs | 5 +++++ lightproc/src/lightproc.rs | 4 ++++ lightproc/src/proc_data.rs | 12 ++++++++++++ lightproc/src/proc_handle.rs | 24 ++++++++++++++++++++++++ lightproc/src/proc_vtable.rs | 8 ++++++++ lightproc/src/state.rs | 0 6 files changed, 53 insertions(+) create mode 100644 lightproc/src/proc_data.rs create mode 100644 lightproc/src/proc_handle.rs create mode 100644 lightproc/src/proc_vtable.rs create mode 100644 lightproc/src/state.rs diff --git a/lightproc/src/lib.rs b/lightproc/src/lib.rs index e69de29b..799e5a0f 100644 --- a/lightproc/src/lib.rs +++ b/lightproc/src/lib.rs @@ -0,0 +1,5 @@ +mod lightproc; +mod proc_handle; +mod proc_data; +mod proc_vtable; +mod state; diff --git a/lightproc/src/lightproc.rs b/lightproc/src/lightproc.rs index e69de29b..7f586cd9 100644 --- a/lightproc/src/lightproc.rs +++ b/lightproc/src/lightproc.rs @@ -0,0 +1,4 @@ + +pub struct LightProc { + +} diff --git a/lightproc/src/proc_data.rs b/lightproc/src/proc_data.rs new file mode 100644 index 00000000..e7568e79 --- /dev/null +++ b/lightproc/src/proc_data.rs @@ -0,0 +1,12 @@ +use std::task::Waker; +use std::cell::UnsafeCell; +use proc_vtable::ProcVTable; +use std::sync::atomic::{AtomicUsize, Ordering}; + +pub(crate) struct ProcData { + pub(crate) state: AtomicUsize, + + pub(crate) awaiter: UnsafeCell>, + + pub(crate) vtable: &'static ProcVTable, +} diff --git a/lightproc/src/proc_handle.rs b/lightproc/src/proc_handle.rs new file mode 100644 index 00000000..41c9b42d --- /dev/null +++ b/lightproc/src/proc_handle.rs @@ -0,0 +1,24 @@ +use std::ptr::NonNull; +use std::marker::PhantomData as marker; + +pub struct ProcHandle { + raw_proc: NonNull<()>, + _private: marker<(R, T)> +} + +unsafe impl Send for ProcHandle {} +unsafe impl Sync for ProcHandle {} + +impl Unpin for ProcHandle {} + +impl ProcHandle { + /// Cancels the task. + /// + /// If the task has already completed, calling this method will have no effect. + /// + /// When a task is cancelled, its future cannot be polled again and will be dropped instead. + pub fn cancel(&self) { + let ptr = self.raw_proc.as_ptr(); + unimplemented!() + } +} diff --git a/lightproc/src/proc_vtable.rs b/lightproc/src/proc_vtable.rs new file mode 100644 index 00000000..942d1db7 --- /dev/null +++ b/lightproc/src/proc_vtable.rs @@ -0,0 +1,8 @@ +use std::task::RawWakerVTable; + +pub(crate) struct ProcVTable { + /// The raw waker vtable. + pub(crate) raw_waker: RawWakerVTable, + + pub(crate) schedule: unsafe fn(*const ()), +} diff --git a/lightproc/src/state.rs b/lightproc/src/state.rs new file mode 100644 index 00000000..e69de29b