Skip to content

Commit de461fe

Browse files
committed
---
yaml --- r: 96940 b: refs/heads/dist-snap c: 7f48345 h: refs/heads/master v: v3
1 parent 4af9714 commit de461fe

File tree

8 files changed

+20
-44
lines changed

8 files changed

+20
-44
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 1c4af5e3d93fe2953c31f8a76ee2aed15069204a
9+
refs/heads/dist-snap: 7f483459045789d6bb44671269fd9aec73dbeb63
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libextra/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl WaitQueue {
7979

8080
fn wait_end(&self) -> WaitEnd {
8181
let (wait_end, signal_end) = Chan::new();
82-
self.tail.send_deferred(signal_end);
82+
assert!(self.tail.try_send_deferred(signal_end));
8383
wait_end
8484
}
8585
}

branches/dist-snap/src/libgreen/simple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl Runtime for SimpleTask {
5454
}
5555
Local::put(cur_task);
5656
}
57-
fn reawaken(mut ~self, mut to_wake: ~Task) {
57+
fn reawaken(mut ~self, mut to_wake: ~Task, _can_resched: bool) {
5858
let me = &mut *self as *mut SimpleTask;
5959
to_wake.put_runtime(self as ~Runtime);
6060
unsafe {

branches/dist-snap/src/libgreen/task.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl Runtime for GreenTask {
346346
}
347347
}
348348

349-
fn reawaken(mut ~self, to_wake: ~Task) {
349+
fn reawaken(mut ~self, to_wake: ~Task, can_resched: bool) {
350350
self.put_task(to_wake);
351351
assert!(self.sched.is_none());
352352

@@ -372,10 +372,15 @@ impl Runtime for GreenTask {
372372
match running_task.maybe_take_runtime::<GreenTask>() {
373373
Some(mut running_green_task) => {
374374
running_green_task.put_task(running_task);
375-
let sched = running_green_task.sched.take_unwrap();
375+
let mut sched = running_green_task.sched.take_unwrap();
376376

377377
if sched.pool_id == self.pool_id {
378-
sched.run_task(running_green_task, self);
378+
if can_resched {
379+
sched.run_task(running_green_task, self);
380+
} else {
381+
sched.enqueue_task(self);
382+
running_green_task.put_with_sched(sched);
383+
}
379384
} else {
380385
self.reawaken_remotely();
381386

branches/dist-snap/src/librustuv/pipe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ extern fn listen_cb(server: *uvll::uv_stream_t, status: libc::c_int) {
210210
}
211211
n => Err(uv_error_to_io_error(UvError(n)))
212212
};
213-
pipe.outgoing.send_deferred(msg);
213+
pipe.outgoing.send(msg);
214214
}
215215

216216
impl Drop for PipeListener {

branches/dist-snap/src/librustuv/signal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl SignalWatcher {
5252
extern fn signal_cb(handle: *uvll::uv_signal_t, signum: c_int) {
5353
let s: &mut SignalWatcher = unsafe { UvHandle::from_uv_handle(&handle) };
5454
assert_eq!(signum as int, s.signal as int);
55-
s.channel.try_send_deferred(s.signal);
55+
s.channel.try_send(s.signal);
5656
}
5757

5858
impl HomingIO for SignalWatcher {

branches/dist-snap/src/librustuv/timer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ extern fn timer_cb(handle: *uvll::uv_timer_t, status: c_int) {
140140
WakeTask(task) => {
141141
task.wake().map(|t| t.reawaken(true));
142142
}
143-
SendOnce(chan) => { chan.try_send_deferred(()); }
143+
SendOnce(chan) => { chan.try_send(()); }
144144
SendMany(chan, id) => {
145-
chan.try_send_deferred(());
145+
chan.try_send(());
146146

147147
// Note that the above operation could have performed some form of
148148
// scheduling. This means that the timer may have decided to insert

branches/dist-snap/src/libstd/comm/mod.rs

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ impl Packet {
496496
match self.channels.fetch_sub(1, SeqCst) {
497497
1 => {
498498
match self.cnt.swap(DISCONNECTED, SeqCst) {
499-
-1 => { self.wakeup(false); }
499+
-1 => { self.wakeup(true); }
500500
DISCONNECTED => {}
501501
n => { assert!(n >= 0); }
502502
}
@@ -537,9 +537,6 @@ impl<T: Send> Chan<T> {
537537
/// port.
538538
///
539539
/// Rust channels are infinitely buffered so this method will never block.
540-
/// This method may trigger a rescheduling, however, in order to wake up a
541-
/// blocked receiver (if one is present). If no scheduling is desired, then
542-
/// the `send_deferred` guarantees that there will be no reschedulings.
543540
///
544541
/// # Failure
545542
///
@@ -561,15 +558,6 @@ impl<T: Send> Chan<T> {
561558
}
562559
}
563560

564-
/// This function is equivalent in the semantics of `send`, but it
565-
/// guarantees that a rescheduling will never occur when this method is
566-
/// called.
567-
pub fn send_deferred(&self, t: T) {
568-
if !self.try_send_deferred(t) {
569-
fail!("sending on a closed channel");
570-
}
571-
}
572-
573561
/// Attempts to send a value on this channel, returning whether it was
574562
/// successfully sent.
575563
///
@@ -585,9 +573,8 @@ impl<T: Send> Chan<T> {
585573
/// be tolerated, then this method should be used instead.
586574
pub fn try_send(&self, t: T) -> bool { self.try(t, true) }
587575

588-
/// This function is equivalent in the semantics of `try_send`, but it
589-
/// guarantees that a rescheduling will never occur when this method is
590-
/// called.
576+
/// This function will not stick around for very long. The purpose of this
577+
/// function is to guarantee that no rescheduling is performed.
591578
pub fn try_send_deferred(&self, t: T) -> bool { self.try(t, false) }
592579

593580
fn try(&self, t: T, can_resched: bool) -> bool {
@@ -649,25 +636,9 @@ impl<T: Send> SharedChan<T> {
649636
}
650637
}
651638

652-
/// This function is equivalent in the semantics of `send`, but it
653-
/// guarantees that a rescheduling will never occur when this method is
654-
/// called.
655-
pub fn send_deferred(&self, t: T) {
656-
if !self.try_send_deferred(t) {
657-
fail!("sending on a closed channel");
658-
}
659-
}
660-
661639
/// Equivalent method to `try_send` on the `Chan` type (using the same
662640
/// semantics)
663-
pub fn try_send(&self, t: T) -> bool { self.try(t, true) }
664-
665-
/// This function is equivalent in the semantics of `try_send`, but it
666-
/// guarantees that a rescheduling will never occur when this method is
667-
/// called.
668-
pub fn try_send_deferred(&self, t: T) -> bool { self.try(t, false) }
669-
670-
fn try(&self, t: T, can_resched: bool) -> bool {
641+
pub fn try_send(&self, t: T) -> bool {
671642
unsafe {
672643
// Note that the multiple sender case is a little tricker
673644
// semantically than the single sender case. The logic for
@@ -704,7 +675,7 @@ impl<T: Send> SharedChan<T> {
704675

705676
match (*packet).increment() {
706677
DISCONNECTED => {} // oh well, we tried
707-
-1 => { (*packet).wakeup(can_resched); }
678+
-1 => { (*packet).wakeup(true); }
708679
n => {
709680
if n > 0 && n % RESCHED_FREQ == 0 {
710681
let task: ~Task = Local::take();

0 commit comments

Comments
 (0)