diff options
author | Stjepan Glavina <stjepang@gmail.com> | 2020-09-18 14:31:53 +0200 |
---|---|---|
committer | Stjepan Glavina <stjepang@gmail.com> | 2020-09-18 14:31:53 +0200 |
commit | deb709f4198c4c6d1c691a69f5cd713d040e0fed (patch) | |
tree | b00b7b94df7f0e4ca8b1ab41e7eea81020765c21 /src | |
parent | c533cc6a78f12099143f2230a851abb77d0e67c2 (diff) | |
download | async-task-deb709f4198c4c6d1c691a69f5cd713d040e0fed.tar.gz |
Replace crossbeam with flume
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 6 | ||||
-rw-r--r-- | src/task.rs | 26 |
2 files changed, 5 insertions, 27 deletions
@@ -9,7 +9,7 @@ //! All executors have some kind of queue that holds runnable tasks: //! //! ``` -//! let (sender, receiver) = crossbeam::channel::unbounded(); +//! let (sender, receiver) = flume::unbounded(); //! # //! # // A future that will get spawned. //! # let future = async { 1 + 2 }; @@ -24,7 +24,7 @@ //! A task is constructed using either [`spawn`] or [`spawn_local`]: //! //! ``` -//! # let (sender, receiver) = crossbeam::channel::unbounded(); +//! # let (sender, receiver) = flume::unbounded(); //! # //! // A future that will be spawned. //! let future = async { 1 + 2 }; @@ -47,7 +47,7 @@ //! runnable tasks out of the queue and running each one in order: //! //! ```no_run -//! # let (sender, receiver) = crossbeam::channel::unbounded(); +//! # let (sender, receiver) = flume::unbounded(); //! # //! # // A future that will get spawned. //! # let future = async { 1 + 2 }; diff --git a/src/task.rs b/src/task.rs index 7374cf4..4850e00 100644 --- a/src/task.rs +++ b/src/task.rs @@ -33,15 +33,13 @@ use crate::JoinHandle; /// # Examples /// /// ``` -/// use crossbeam::channel; -/// /// // The future inside the task. /// let future = async { /// println!("Hello, world!"); /// }; /// /// // If the task gets woken up, it will be sent into this channel. -/// let (s, r) = channel::unbounded(); +/// let (s, r) = flume::unbounded(); /// let schedule = move |task| s.send(task).unwrap(); /// /// // Create a task with the future and the schedule function. @@ -94,15 +92,13 @@ where /// # Examples /// /// ``` -/// use crossbeam::channel; -/// /// // The future inside the task. /// let future = async { /// println!("Hello, world!"); /// }; /// /// // If the task gets woken up, it will be sent into this channel. -/// let (s, r) = channel::unbounded(); +/// let (s, r) = flume::unbounded(); /// let schedule = move |task| s.send(task).unwrap(); /// /// // Create a task with the future and the schedule function. @@ -266,24 +262,6 @@ impl Task { Waker::from_raw(raw_waker) } } - - /// Converts this task into a raw pointer. - pub fn into_raw(self) -> *mut () { - let ptr = self.raw_task.as_ptr(); - mem::forget(self); - ptr - } - - /// Converts a raw pointer into a task. - /// - /// This method should only be used with raw pointers returned from [`into_raw`]. - /// - /// [`into_raw`]: #method.into_raw - pub unsafe fn from_raw(raw: *mut ()) -> Task { - Task { - raw_task: NonNull::new_unchecked(raw as *mut ()), - } - } } impl Drop for Task { |