Skip to content

Rename ThreadUnpark -> ThreadNotify #596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/task_impl/std/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl<F: Future> Spawn<F> {
/// to complete. When a future cannot make progress it will use
/// `thread::park` to block the current thread.
pub fn wait_future(&mut self) -> Result<F::Item, F::Error> {
let unpark = Arc::new(ThreadUnpark::new(thread::current()));
let unpark = Arc::new(ThreadNotify::new(thread::current()));

loop {
match self.poll_future_notify(&unpark, 0)? {
Expand Down Expand Up @@ -296,7 +296,7 @@ impl<S: Stream> Spawn<S> {
/// Like `wait_future`, except only waits for the next element to arrive on
/// the underlying stream.
pub fn wait_stream(&mut self) -> Option<Result<S::Item, S::Error>> {
let unpark = Arc::new(ThreadUnpark::new(thread::current()));
let unpark = Arc::new(ThreadNotify::new(thread::current()));
loop {
match self.poll_stream_notify(&unpark, 0) {
Ok(Async::NotReady) => unpark.park(),
Expand Down Expand Up @@ -340,7 +340,7 @@ impl<S: Sink> Spawn<S> {
/// be blocked until it's able to send the value.
pub fn wait_send(&mut self, mut value: S::SinkItem)
-> Result<(), S::SinkError> {
let notify = Arc::new(ThreadUnpark::new(thread::current()));
let notify = Arc::new(ThreadNotify::new(thread::current()));
loop {
value = match self.start_send_notify(value, &notify, 0)? {
AsyncSink::NotReady(v) => v,
Expand All @@ -359,7 +359,7 @@ impl<S: Sink> Spawn<S> {
/// The thread will be blocked until `poll_complete` returns that it's
/// ready.
pub fn wait_flush(&mut self) -> Result<(), S::SinkError> {
let notify = Arc::new(ThreadUnpark::new(thread::current()));
let notify = Arc::new(ThreadNotify::new(thread::current()));
loop {
if self.poll_flush_notify(&notify, 0)?.is_ready() {
return Ok(())
Expand All @@ -374,7 +374,7 @@ impl<S: Sink> Spawn<S> {
/// is not ready to be close yet, then the current thread will be blocked
/// until it's closed.
pub fn wait_close(&mut self) -> Result<(), S::SinkError> {
let notify = Arc::new(ThreadUnpark::new(thread::current()));
let notify = Arc::new(ThreadNotify::new(thread::current()));
loop {
if self.close_notify(&notify, 0)?.is_ready() {
return Ok(())
Expand Down Expand Up @@ -474,16 +474,16 @@ impl Unpark for RunInner {
}
}

// ===== ThreadUnpark =====
// ===== ThreadNotify =====

struct ThreadUnpark {
struct ThreadNotify {
thread: thread::Thread,
ready: AtomicBool,
}

impl ThreadUnpark {
fn new(thread: thread::Thread) -> ThreadUnpark {
ThreadUnpark {
impl ThreadNotify {
fn new(thread: thread::Thread) -> ThreadNotify {
ThreadNotify {
thread: thread,
ready: AtomicBool::new(false),
}
Expand All @@ -496,7 +496,7 @@ impl ThreadUnpark {
}
}

impl Notify for ThreadUnpark {
impl Notify for ThreadNotify {
fn notify(&self, _unpark_id: usize) {
self.ready.store(true, Ordering::SeqCst);
self.thread.unpark()
Expand Down