summaryrefslogtreecommitdiff
path: root/monoio/src/driver/legacy/mod.rs
diff options
context:
space:
mode:
authorzy <[email protected]>2023-09-01 10:43:54 +0000
committerzy <[email protected]>2023-09-01 10:43:54 +0000
commita038a38a1f52d14a2af6f99c98c9a6cbc367d39e (patch)
tree38ddb48644310e12a3f918e5966ca73d7d257168 /monoio/src/driver/legacy/mod.rs
parent4ecbf24689b0a0f214a972983a33b41064c5ea81 (diff)
6/51
Diffstat (limited to 'monoio/src/driver/legacy/mod.rs')
-rw-r--r--monoio/src/driver/legacy/mod.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/monoio/src/driver/legacy/mod.rs b/monoio/src/driver/legacy/mod.rs
index a92a702..483cd70 100644
--- a/monoio/src/driver/legacy/mod.rs
+++ b/monoio/src/driver/legacy/mod.rs
@@ -26,7 +26,7 @@ mod waker;
pub(crate) use waker::UnparkHandle;
pub(crate) struct LegacyInner {
- pub(crate) io_dispatch: Slab<ScheduledIo>,
+ pub(crate) io_dispatch: Slab<ScheduledIo>, //
#[cfg(unix)]
events: Option<mio::Events>,
#[cfg(unix)]
@@ -260,7 +260,7 @@ impl LegacyInner {
pub(crate) fn poll_op<T: OpAble>(
this: &Rc<UnsafeCell<Self>>,
- data: &mut T,
+ data: &mut T, // 实际上是个 OpAble
cx: &mut Context<'_>,
) -> Poll<CompletionMeta> {
let inner = unsafe { &mut *this.get() };
@@ -269,6 +269,7 @@ impl LegacyInner {
None => {
// if there is no index provided, it means the action does not rely on fd
// readiness. do syscall right now.
+ // 如果没有提供索引,则表示该操作不依赖于 fd 的准备就绪.立即执行系统调用.
return Poll::Ready(CompletionMeta {
result: OpAble::legacy_call(data),
flags: 0,
@@ -277,14 +278,17 @@ impl LegacyInner {
};
// wait io ready and do syscall
+ // 等待 io 准备就绪并执行系统调用
let mut scheduled_io = inner.io_dispatch.get(index).expect("scheduled_io lost");
let ref_mut = scheduled_io.as_mut();
loop {
let readiness = ready!(ref_mut.poll_readiness(cx, direction));
// check if canceled
+ // 检查是否已取消
if readiness.is_canceled() {
// clear CANCELED part only
+ // 只清除 CANCELED 部分
ref_mut.clear_readiness(readiness & Ready::CANCELED);
return Poll::Ready(CompletionMeta {
result: Err(io::Error::from_raw_os_error(125)),