Skip to content

Commit 376b966

Browse files
authored
Merge pull request #1941 from zyuiop/cleanup/poll_on
cleanup: poll_on no longer required in new_idle
2 parents 9a6f950 + b933294 commit 376b966

File tree

2 files changed

+40
-64
lines changed

2 files changed

+40
-64
lines changed

src/executor/mod.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,6 @@ pub fn init() {
125125
crate::executor::vsock::init();
126126
}
127127

128-
/// Blocks the current thread on `f`, running the executor when idling.
129-
pub(crate) fn poll_on<F, T>(future: F) -> io::Result<T>
130-
where
131-
F: Future<Output = io::Result<T>>,
132-
{
133-
let mut cx = Context::from_waker(Waker::noop());
134-
let mut future = pin!(future);
135-
136-
loop {
137-
// run background tasks
138-
run();
139-
140-
if let Poll::Ready(t) = future.as_mut().poll(&mut cx) {
141-
return t;
142-
}
143-
}
144-
}
145-
146128
/// Blocks the current thread on `f`, running the executor when idling.
147129
pub(crate) fn block_on<F, T>(future: F, timeout: Option<Duration>) -> io::Result<T>
148130
where

src/scheduler/task.rs

Lines changed: 40 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ use crate::arch::core_local::*;
1919
use crate::arch::scheduler::TaskStacks;
2020
#[cfg(not(feature = "common-os"))]
2121
use crate::arch::scheduler::TaskTLS;
22-
use crate::errno::Errno;
23-
use crate::executor::poll_on;
2422
use crate::fd::stdio::*;
2523
use crate::fd::{FileDescriptor, ObjectInterface, STDERR_FILENO, STDIN_FILENO, STDOUT_FILENO};
2624
use crate::scheduler::CoreId;
@@ -467,50 +465,46 @@ impl Task {
467465
))))
468466
.unwrap();
469467
let objmap = OBJECT_MAP.get().unwrap().clone();
470-
let _ = poll_on(async {
471-
let mut guard = objmap.write();
472-
if env::is_uhyve() {
473-
guard
474-
.try_insert(
475-
STDIN_FILENO,
476-
Arc::new(async_lock::RwLock::new(UhyveStdin::new())),
477-
)
478-
.map_err(|_| Errno::Io)?;
479-
guard
480-
.try_insert(
481-
STDOUT_FILENO,
482-
Arc::new(async_lock::RwLock::new(UhyveStdout::new())),
483-
)
484-
.map_err(|_| Errno::Io)?;
485-
guard
486-
.try_insert(
487-
STDERR_FILENO,
488-
Arc::new(async_lock::RwLock::new(UhyveStderr::new())),
489-
)
490-
.map_err(|_| Errno::Io)?;
491-
} else {
492-
guard
493-
.try_insert(
494-
STDIN_FILENO,
495-
Arc::new(async_lock::RwLock::new(GenericStdin::new())),
496-
)
497-
.map_err(|_| Errno::Io)?;
498-
guard
499-
.try_insert(
500-
STDOUT_FILENO,
501-
Arc::new(async_lock::RwLock::new(GenericStdout::new())),
502-
)
503-
.map_err(|_| Errno::Io)?;
504-
guard
505-
.try_insert(
506-
STDERR_FILENO,
507-
Arc::new(async_lock::RwLock::new(GenericStderr::new())),
508-
)
509-
.map_err(|_| Errno::Io)?;
510-
}
511-
512-
Ok(())
513-
});
468+
let mut guard = objmap.write();
469+
if env::is_uhyve() {
470+
guard
471+
.try_insert(
472+
STDIN_FILENO,
473+
Arc::new(async_lock::RwLock::new(UhyveStdin::new())),
474+
)
475+
.expect("cannot insert stdin");
476+
guard
477+
.try_insert(
478+
STDOUT_FILENO,
479+
Arc::new(async_lock::RwLock::new(UhyveStdout::new())),
480+
)
481+
.expect("cannot insert stdout");
482+
guard
483+
.try_insert(
484+
STDERR_FILENO,
485+
Arc::new(async_lock::RwLock::new(UhyveStderr::new())),
486+
)
487+
.expect("cannot insert stderr");
488+
} else {
489+
guard
490+
.try_insert(
491+
STDIN_FILENO,
492+
Arc::new(async_lock::RwLock::new(GenericStdin::new())),
493+
)
494+
.expect("cannot insert stdin");
495+
guard
496+
.try_insert(
497+
STDOUT_FILENO,
498+
Arc::new(async_lock::RwLock::new(GenericStdout::new())),
499+
)
500+
.expect("cannot insert stdout");
501+
guard
502+
.try_insert(
503+
STDERR_FILENO,
504+
Arc::new(async_lock::RwLock::new(GenericStderr::new())),
505+
)
506+
.expect("cannot insert stderr");
507+
}
514508
}
515509

516510
Task {

0 commit comments

Comments
 (0)