Skip to content

Commit bedf4cb

Browse files
committed
---
yaml --- r: 97182 b: refs/heads/dist-snap c: 1a9c8cc h: refs/heads/master v: v3
1 parent 47f827f commit bedf4cb

File tree

3 files changed

+17
-35
lines changed

3 files changed

+17
-35
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: 981c6b12fad24ef28998668e515e62976f72b3bf
9+
refs/heads/dist-snap: 1a9c8cc1283675dfc1b85dbf80a9ea07a2b8b335
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,7 @@ impl SchedPool {
214214
pool.handles.push(sched.make_handle());
215215
let sched = sched;
216216
pool.threads.push(do Thread::start {
217-
let mut sched = sched;
218-
let task = do GreenTask::new(&mut sched.stack_pool, None) {
219-
rtdebug!("boostraping a non-primary scheduler");
220-
};
221-
sched.bootstrap(task);
217+
sched.bootstrap();
222218
});
223219
}
224220

@@ -270,13 +266,7 @@ impl SchedPool {
270266
let ret = sched.make_handle();
271267
self.handles.push(sched.make_handle());
272268
let sched = sched;
273-
self.threads.push(do Thread::start {
274-
let mut sched = sched;
275-
let task = do GreenTask::new(&mut sched.stack_pool, None) {
276-
rtdebug!("boostraping a non-primary scheduler");
277-
};
278-
sched.bootstrap(task);
279-
});
269+
self.threads.push(do Thread::start { sched.bootstrap() });
280270

281271
return ret;
282272
}

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

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl Scheduler {
171171

172172
// Take a main task to run, and a scheduler to run it in. Create a
173173
// scheduler task and bootstrap into it.
174-
pub fn bootstrap(mut ~self, task: ~GreenTask) {
174+
pub fn bootstrap(mut ~self) {
175175

176176
// Build an Idle callback.
177177
let cb = ~SchedRunner as ~Callback;
@@ -187,18 +187,11 @@ impl Scheduler {
187187
self.idle_callback.get_mut_ref().resume();
188188

189189
// Now, as far as all the scheduler state is concerned, we are inside
190-
// the "scheduler" context. So we can act like the scheduler and resume
191-
// the provided task. Let it think that the currently running task is
192-
// actually the sched_task so it knows where to squirrel it away.
193-
let mut sched_task = self.resume_task_immediately(sched_task, task);
194-
195-
// Now we are back in the scheduler context, having
196-
// successfully run the input task. Start by running the
197-
// scheduler. Grab it out of TLS - performing the scheduler
198-
// action will have given it away.
199-
let sched = sched_task.sched.take_unwrap();
200-
rtdebug!("starting scheduler {}", sched.sched_id());
201-
let mut sched_task = sched.run(sched_task);
190+
// the "scheduler" context. The scheduler immediately hands over control
191+
// to the event loop, and this will only exit once the event loop no
192+
// longer has any references (handles or I/O objects).
193+
rtdebug!("starting scheduler {}", self.sched_id());
194+
let mut sched_task = self.run(sched_task);
202195

203196
// Close the idle callback.
204197
let mut sched = sched_task.sched.take_unwrap();
@@ -548,7 +541,10 @@ impl Scheduler {
548541
// We push the task onto our local queue clone.
549542
assert!(!task.is_sched());
550543
self.work_queue.push(task);
551-
self.idle_callback.get_mut_ref().resume();
544+
match self.idle_callback {
545+
Some(ref mut idle) => idle.resume(),
546+
None => {} // allow enqueuing before the scheduler starts
547+
}
552548

553549
// We've made work available. Notify a
554550
// sleeping scheduler.
@@ -1176,25 +1172,21 @@ mod test {
11761172
let mut sh = special_handle;
11771173
sh.send(Shutdown);
11781174
};
1179-
1175+
normal_sched.enqueue_task(normal_task);
11801176

11811177
let special_task = do GreenTask::new(&mut special_sched.stack_pool,
11821178
None) {
11831179
run(task1);
11841180
run(task3);
11851181
chan.send(());
11861182
};
1187-
1183+
special_sched.enqueue_task(special_task);
11881184

11891185
let normal_sched = normal_sched;
1190-
let normal_thread = do Thread::start {
1191-
normal_sched.bootstrap(normal_task);
1192-
};
1186+
let normal_thread = do Thread::start { normal_sched.bootstrap() };
11931187

11941188
let special_sched = special_sched;
1195-
let special_thread = do Thread::start {
1196-
special_sched.bootstrap(special_task);
1197-
};
1189+
let special_thread = do Thread::start { special_sched.bootstrap() };
11981190

11991191
normal_thread.join();
12001192
special_thread.join();

0 commit comments

Comments
 (0)