Skip to content

Commit 088aa56

Browse files
committed
refactor: Remove wrapping cell
1 parent 11ee2a8 commit 088aa56

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Diff for: src/rt/runtime.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl Machine {
219219
runs = 0;
220220
rt.quick_poll().unwrap();
221221

222-
let p = self.processor.lock();
222+
let mut p = self.processor.lock();
223223
if let Steal::Success(task) = p.steal_from_global(rt) {
224224
p.schedule(rt, task);
225225
}
@@ -284,21 +284,21 @@ struct Processor {
284284
worker: Worker<Runnable>,
285285

286286
/// Contains the next task to run as an optimization that skips the queue.
287-
slot: Cell<Option<Runnable>>,
287+
slot: Option<Runnable>,
288288
}
289289

290290
impl Processor {
291291
/// Creates a new processor.
292292
fn new() -> Processor {
293293
Processor {
294294
worker: Worker::new_fifo(),
295-
slot: Cell::new(None),
295+
slot: None,
296296
}
297297
}
298298

299299
/// Schedules a task to run on this processor.
300-
fn schedule(&self, rt: &Runtime, task: Runnable) {
301-
match self.slot.replace(Some(task)) {
300+
fn schedule(&mut self, rt: &Runtime, task: Runnable) {
301+
match self.slot.replace(task) {
302302
None => {}
303303
Some(task) => {
304304
self.worker.push(task);
@@ -308,15 +308,15 @@ impl Processor {
308308
}
309309

310310
/// Flushes a task from the slot into the local queue.
311-
fn flush_slot(&self, rt: &Runtime) {
311+
fn flush_slot(&mut self, rt: &Runtime) {
312312
if let Some(task) = self.slot.take() {
313313
self.worker.push(task);
314314
rt.notify();
315315
}
316316
}
317317

318318
/// Pops a task from this processor.
319-
fn pop_task(&self) -> Option<Runnable> {
319+
fn pop_task(&mut self) -> Option<Runnable> {
320320
self.slot.take().or_else(|| self.worker.pop())
321321
}
322322

0 commit comments

Comments
 (0)