mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-21 16:33:24 +00:00
Rename Poller
to PollHandle
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
44b55f2ccf
commit
f12e502ab0
@ -7,7 +7,7 @@ use crate::{
|
|||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
fs::inode_handle::FileIo,
|
fs::inode_handle::FileIo,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollable, Poller},
|
process::signal::{PollHandle, Pollable},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Null;
|
pub struct Null;
|
||||||
@ -28,7 +28,7 @@ impl Device for Null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for Null {
|
impl Pollable for Null {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
let events = IoEvents::IN | IoEvents::OUT;
|
let events = IoEvents::IN | IoEvents::OUT;
|
||||||
events & mask
|
events & mask
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ use crate::{
|
|||||||
get_current_userspace,
|
get_current_userspace,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::{
|
process::{
|
||||||
signal::{Pollable, Pollee, Poller},
|
signal::{PollHandle, Pollable, Pollee},
|
||||||
JobControl, Terminal,
|
JobControl, Terminal,
|
||||||
},
|
},
|
||||||
util::ring_buffer::RingBuffer,
|
util::ring_buffer::RingBuffer,
|
||||||
@ -67,7 +67,11 @@ impl PtyMaster {
|
|||||||
self.update_state(&input);
|
self.update_state(&input);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn slave_poll(&self, mask: IoEvents, mut poller: Option<&mut Poller>) -> IoEvents {
|
pub(super) fn slave_poll(
|
||||||
|
&self,
|
||||||
|
mask: IoEvents,
|
||||||
|
mut poller: Option<&mut PollHandle>,
|
||||||
|
) -> IoEvents {
|
||||||
let mut poll_status = IoEvents::empty();
|
let mut poll_status = IoEvents::empty();
|
||||||
|
|
||||||
let poll_in_mask = mask & IoEvents::IN;
|
let poll_in_mask = mask & IoEvents::IN;
|
||||||
@ -112,7 +116,7 @@ impl PtyMaster {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for PtyMaster {
|
impl Pollable for PtyMaster {
|
||||||
fn poll(&self, mask: IoEvents, mut poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, mut poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
let mut poll_status = IoEvents::empty();
|
let mut poll_status = IoEvents::empty();
|
||||||
|
|
||||||
let poll_in_mask = mask & IoEvents::IN;
|
let poll_in_mask = mask & IoEvents::IN;
|
||||||
@ -322,7 +326,7 @@ impl Terminal for PtySlave {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for PtySlave {
|
impl Pollable for PtySlave {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
self.master().slave_poll(mask, poller)
|
self.master().slave_poll(mask, poller)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ use crate::{
|
|||||||
inode_handle::FileIo,
|
inode_handle::FileIo,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollable, Poller},
|
process::signal::{PollHandle, Pollable},
|
||||||
util::random::getrandom,
|
util::random::getrandom,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ impl Device for Random {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for Random {
|
impl Pollable for Random {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
let events = IoEvents::IN | IoEvents::OUT;
|
let events = IoEvents::IN | IoEvents::OUT;
|
||||||
events & mask
|
events & mask
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use crate::{
|
|||||||
error::Error,
|
error::Error,
|
||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
fs::{inode_handle::FileIo, utils::IoctlCmd},
|
fs::{inode_handle::FileIo, utils::IoctlCmd},
|
||||||
process::signal::{Pollable, Poller},
|
process::signal::{PollHandle, Pollable},
|
||||||
};
|
};
|
||||||
|
|
||||||
const TDX_REPORTDATA_LEN: usize = 64;
|
const TDX_REPORTDATA_LEN: usize = 64;
|
||||||
@ -58,7 +58,7 @@ impl From<TdCallError> for Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for TdxGuest {
|
impl Pollable for TdxGuest {
|
||||||
fn poll(&self, mask: IoEvents, _poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, _poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
let events = IoEvents::IN | IoEvents::OUT;
|
let events = IoEvents::IN | IoEvents::OUT;
|
||||||
events & mask
|
events & mask
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ use crate::{
|
|||||||
inode_handle::FileIo,
|
inode_handle::FileIo,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollable, Poller},
|
process::signal::{PollHandle, Pollable},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Corresponds to `/dev/tty` in the file system. This device represents the controlling terminal
|
/// Corresponds to `/dev/tty` in the file system. This device represents the controlling terminal
|
||||||
@ -41,7 +41,7 @@ impl Device for TtyDevice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for TtyDevice {
|
impl Pollable for TtyDevice {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
IoEvents::empty()
|
IoEvents::empty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ use crate::{
|
|||||||
process::signal::{
|
process::signal::{
|
||||||
constants::{SIGINT, SIGQUIT},
|
constants::{SIGINT, SIGQUIT},
|
||||||
signals::kernel::KernelSignal,
|
signals::kernel::KernelSignal,
|
||||||
Pollable, Pollee, Poller,
|
PollHandle, Pollable, Pollee,
|
||||||
},
|
},
|
||||||
thread::work_queue::{submit_work_item, work_item::WorkItem, WorkPriority},
|
thread::work_queue::{submit_work_item, work_item::WorkItem, WorkPriority},
|
||||||
util::ring_buffer::RingBuffer,
|
util::ring_buffer::RingBuffer,
|
||||||
@ -88,7 +88,7 @@ impl CurrentLine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for LineDiscipline {
|
impl Pollable for LineDiscipline {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
self.pollee.poll(mask, poller)
|
self.pollee.poll(mask, poller)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ use crate::{
|
|||||||
get_current_userspace,
|
get_current_userspace,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::{
|
process::{
|
||||||
signal::{signals::kernel::KernelSignal, Pollable, Poller},
|
signal::{signals::kernel::KernelSignal, PollHandle, Pollable},
|
||||||
JobControl, Process, Terminal,
|
JobControl, Process, Terminal,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -73,7 +73,7 @@ impl Tty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for Tty {
|
impl Pollable for Tty {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
self.ldisc.poll(mask, poller)
|
self.ldisc.poll(mask, poller)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ use crate::{
|
|||||||
inode_handle::FileIo,
|
inode_handle::FileIo,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollable, Poller},
|
process::signal::{PollHandle, Pollable},
|
||||||
util::random::getrandom,
|
util::random::getrandom,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ impl Device for Urandom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for Urandom {
|
impl Pollable for Urandom {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
let events = IoEvents::IN | IoEvents::OUT;
|
let events = IoEvents::IN | IoEvents::OUT;
|
||||||
events & mask
|
events & mask
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ use crate::{
|
|||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
fs::inode_handle::FileIo,
|
fs::inode_handle::FileIo,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollable, Poller},
|
process::signal::{PollHandle, Pollable},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Zero;
|
pub struct Zero;
|
||||||
@ -28,7 +28,7 @@ impl Device for Zero {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for Zero {
|
impl Pollable for Zero {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
let events = IoEvents::IN | IoEvents::OUT;
|
let events = IoEvents::IN | IoEvents::OUT;
|
||||||
events & mask
|
events & mask
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ use super::*;
|
|||||||
use crate::{
|
use crate::{
|
||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
fs::inode_handle::FileIo,
|
fs::inode_handle::FileIo,
|
||||||
process::signal::{Pollable, Poller},
|
process::signal::{PollHandle, Pollable},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Same major number with Linux.
|
/// Same major number with Linux.
|
||||||
@ -182,7 +182,7 @@ impl Device for Inner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for Inner {
|
impl Pollable for Inner {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
IoEvents::empty()
|
IoEvents::empty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use crate::{
|
|||||||
device::PtySlave,
|
device::PtySlave,
|
||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
fs::inode_handle::FileIo,
|
fs::inode_handle::FileIo,
|
||||||
process::signal::{Pollable, Poller},
|
process::signal::{PollHandle, Pollable},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Same major number with Linux, the minor number is the index of slave.
|
/// Same major number with Linux, the minor number is the index of slave.
|
||||||
@ -136,7 +136,7 @@ impl Inode for PtySlaveInode {
|
|||||||
self.device.ioctl(cmd, arg)
|
self.device.ioctl(cmd, arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
self.device.poll(mask, poller)
|
self.device.poll(mask, poller)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ use crate::{
|
|||||||
file_handle::FileLike,
|
file_handle::FileLike,
|
||||||
utils::{InodeMode, IoctlCmd, Metadata},
|
utils::{InodeMode, IoctlCmd, Metadata},
|
||||||
},
|
},
|
||||||
process::signal::{Pollable, Pollee, Poller},
|
process::signal::{PollHandle, Pollable, Pollee},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A file-like object that provides epoll API.
|
/// A file-like object that provides epoll API.
|
||||||
@ -326,7 +326,7 @@ impl EpollFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for EpollFile {
|
impl Pollable for EpollFile {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
self.pollee.poll(mask, poller)
|
self.pollee.poll(mask, poller)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::{signal::Poller, Gid, Uid},
|
process::{signal::PollHandle, Gid, Uid},
|
||||||
vm::vmo::Vmo,
|
vm::vmo::Vmo,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1695,7 +1695,7 @@ impl Inode for ExfatInode {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll(&self, mask: IoEvents, _poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, _poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
let events = IoEvents::IN | IoEvents::OUT;
|
let events = IoEvents::IN | IoEvents::OUT;
|
||||||
events & mask
|
events & mask
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ impl Clone for InodeHandle<Rights> {
|
|||||||
|
|
||||||
#[inherit_methods(from = "self.0")]
|
#[inherit_methods(from = "self.0")]
|
||||||
impl Pollable for InodeHandle<Rights> {
|
impl Pollable for InodeHandle<Rights> {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents;
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inherit_methods(from = "self.0")]
|
#[inherit_methods(from = "self.0")]
|
||||||
|
@ -26,7 +26,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::{
|
process::{
|
||||||
signal::{Pollable, Poller},
|
signal::{PollHandle, Pollable},
|
||||||
Gid, Uid,
|
Gid, Uid,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -189,7 +189,7 @@ impl InodeHandle_ {
|
|||||||
Ok(read_cnt)
|
Ok(read_cnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
if let Some(ref file_io) = self.file_io {
|
if let Some(ref file_io) = self.file_io {
|
||||||
return file_io.poll(mask, poller);
|
return file_io.poll(mask, poller);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use super::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollable, Poller},
|
process::signal::{PollHandle, Pollable},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct NamedPipe {
|
pub struct NamedPipe {
|
||||||
@ -31,7 +31,7 @@ impl NamedPipe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for NamedPipe {
|
impl Pollable for NamedPipe {
|
||||||
fn poll(&self, _mask: IoEvents, _poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, _mask: IoEvents, _poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
warn!("Named pipe doesn't support poll now, return IoEvents::empty for now.");
|
warn!("Named pipe doesn't support poll now, return IoEvents::empty for now.");
|
||||||
IoEvents::empty()
|
IoEvents::empty()
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ use crate::{
|
|||||||
events::{IoEvents, Observer},
|
events::{IoEvents, Observer},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::{
|
process::{
|
||||||
signal::{Pollable, Poller},
|
signal::{PollHandle, Pollable},
|
||||||
Gid, Uid,
|
Gid, Uid,
|
||||||
},
|
},
|
||||||
time::clocks::RealTimeCoarseClock,
|
time::clocks::RealTimeCoarseClock,
|
||||||
@ -53,7 +53,7 @@ impl PipeReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for PipeReader {
|
impl Pollable for PipeReader {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
self.consumer.poll(mask, poller)
|
self.consumer.poll(mask, poller)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ impl PipeWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for PipeWriter {
|
impl Pollable for PipeWriter {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
self.producer.poll(mask, poller)
|
self.producer.poll(mask, poller)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::{signal::Poller, Gid, Uid},
|
process::{signal::PollHandle, Gid, Uid},
|
||||||
time::clocks::RealTimeCoarseClock,
|
time::clocks::RealTimeCoarseClock,
|
||||||
vm::vmo::Vmo,
|
vm::vmo::Vmo,
|
||||||
};
|
};
|
||||||
@ -1120,7 +1120,7 @@ impl Inode for RamInode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
if !self.typ.is_device() {
|
if !self.typ.is_device() {
|
||||||
return (IoEvents::IN | IoEvents::OUT) & mask;
|
return (IoEvents::IN | IoEvents::OUT) & mask;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use aster_rights_proc::require;
|
|||||||
use crate::{
|
use crate::{
|
||||||
events::{IoEvents, Observer},
|
events::{IoEvents, Observer},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollee, Poller},
|
process::signal::{PollHandle, Pollee},
|
||||||
util::{
|
util::{
|
||||||
ring_buffer::{RbConsumer, RbProducer, RingBuffer},
|
ring_buffer::{RbConsumer, RbProducer, RingBuffer},
|
||||||
MultiRead, MultiWrite,
|
MultiRead, MultiWrite,
|
||||||
@ -82,7 +82,7 @@ macro_rules! impl_common_methods_for_channel {
|
|||||||
self.0.common.is_shutdown()
|
self.0.common.is_shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
pub fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
self.this_end().pollee.poll(mask, poller)
|
self.this_end().pollee.poll(mask, poller)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ use crate::{
|
|||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
fs::device::{Device, DeviceType},
|
fs::device::{Device, DeviceType},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::{signal::Poller, Gid, Uid},
|
process::{signal::PollHandle, Gid, Uid},
|
||||||
time::clocks::RealTimeCoarseClock,
|
time::clocks::RealTimeCoarseClock,
|
||||||
vm::vmo::Vmo,
|
vm::vmo::Vmo,
|
||||||
};
|
};
|
||||||
@ -398,7 +398,7 @@ pub trait Inode: Any + Sync + Send {
|
|||||||
return_errno!(Errno::EOPNOTSUPP);
|
return_errno!(Errno::EOPNOTSUPP);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll(&self, mask: IoEvents, _poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, _poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
let events = IoEvents::IN | IoEvents::OUT;
|
let events = IoEvents::IN | IoEvents::OUT;
|
||||||
events & mask
|
events & mask
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollable, Pollee, Poller},
|
process::signal::{PollHandle, Pollable, Pollee},
|
||||||
util::{MultiRead, MultiWrite},
|
util::{MultiRead, MultiWrite},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ impl DatagramSocket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for DatagramSocket {
|
impl Pollable for DatagramSocket {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
self.pollee.poll(mask, poller)
|
self.pollee.poll(mask, poller)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollable, Pollee, Poller},
|
process::signal::{PollHandle, Pollable, Pollee},
|
||||||
util::{MultiRead, MultiWrite},
|
util::{MultiRead, MultiWrite},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -376,7 +376,7 @@ impl StreamSocket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for StreamSocket {
|
impl Pollable for StreamSocket {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
self.pollee.poll(mask, poller)
|
self.pollee.poll(mask, poller)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ use crate::{
|
|||||||
SockShutdownCmd,
|
SockShutdownCmd,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollee, Poller},
|
process::signal::{PollHandle, Pollee},
|
||||||
util::{MultiRead, MultiWrite},
|
util::{MultiRead, MultiWrite},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ impl Connected {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn poll(&self, mask: IoEvents, mut poller: Option<&mut Poller>) -> IoEvents {
|
pub(super) fn poll(&self, mask: IoEvents, mut poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
// Note that `mask | IoEvents::ALWAYS_POLL` contains all the events we care about.
|
// Note that `mask | IoEvents::ALWAYS_POLL` contains all the events we care about.
|
||||||
let reader_events = self.reader.poll(mask, poller.as_deref_mut());
|
let reader_events = self.reader.poll(mask, poller.as_deref_mut());
|
||||||
let writer_events = self.writer.poll(mask, poller);
|
let writer_events = self.writer.poll(mask, poller);
|
||||||
|
@ -13,7 +13,7 @@ use crate::{
|
|||||||
SockShutdownCmd,
|
SockShutdownCmd,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollee, Poller},
|
process::signal::{PollHandle, Pollee},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(super) struct Init {
|
pub(super) struct Init {
|
||||||
@ -112,7 +112,7 @@ impl Init {
|
|||||||
self.addr.as_ref()
|
self.addr.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn poll(&self, mask: IoEvents, mut poller: Option<&mut Poller>) -> IoEvents {
|
pub(super) fn poll(&self, mask: IoEvents, mut poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
// To avoid loss of events, this must be compatible with
|
// To avoid loss of events, this must be compatible with
|
||||||
// `Connected::poll`/`Listener::poll`.
|
// `Connected::poll`/`Listener::poll`.
|
||||||
let reader_events = self.reader_pollee.poll(mask, poller.as_deref_mut());
|
let reader_events = self.reader_pollee.poll(mask, poller.as_deref_mut());
|
||||||
|
@ -17,7 +17,7 @@ use crate::{
|
|||||||
SockShutdownCmd, SocketAddr,
|
SockShutdownCmd, SocketAddr,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollee, Poller},
|
process::signal::{PollHandle, Pollee},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(super) struct Listener {
|
pub(super) struct Listener {
|
||||||
@ -78,7 +78,7 @@ impl Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn poll(&self, mask: IoEvents, mut poller: Option<&mut Poller>) -> IoEvents {
|
pub(super) fn poll(&self, mask: IoEvents, mut poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
let reader_events = self.backlog.poll(mask, poller.as_deref_mut());
|
let reader_events = self.backlog.poll(mask, poller.as_deref_mut());
|
||||||
let writer_events = self.writer_pollee.poll(mask, poller);
|
let writer_events = self.writer_pollee.poll(mask, poller);
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ impl Backlog {
|
|||||||
self.wait_queue.wake_all();
|
self.wait_queue.wake_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
self.pollee.poll(mask, poller)
|
self.pollee.poll(mask, poller)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ use crate::{
|
|||||||
SockShutdownCmd, Socket,
|
SockShutdownCmd, Socket,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollable, Poller},
|
process::signal::{PollHandle, Pollable},
|
||||||
util::{MultiRead, MultiWrite},
|
util::{MultiRead, MultiWrite},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ impl UnixStreamSocket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for UnixStreamSocket {
|
impl Pollable for UnixStreamSocket {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
let inner = self.state.read();
|
let inner = self.state.read();
|
||||||
match inner.as_ref() {
|
match inner.as_ref() {
|
||||||
State::Init(init) => init.poll(mask, poller),
|
State::Init(init) => init.poll(mask, poller),
|
||||||
|
@ -10,7 +10,7 @@ use crate::{
|
|||||||
SendRecvFlags, SockShutdownCmd,
|
SendRecvFlags, SockShutdownCmd,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollee, Poller},
|
process::signal::{PollHandle, Pollee},
|
||||||
util::{ring_buffer::RingBuffer, MultiRead, MultiWrite},
|
util::{ring_buffer::RingBuffer, MultiRead, MultiWrite},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ impl Connected {
|
|||||||
.set_peer_requested_shutdown()
|
.set_peer_requested_shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
pub fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
self.pollee.poll(mask, poller)
|
self.pollee.poll(mask, poller)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ use crate::{
|
|||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
net::socket::vsock::{addr::VsockSocketAddr, VSOCK_GLOBAL},
|
net::socket::vsock::{addr::VsockSocketAddr, VSOCK_GLOBAL},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollee, Poller},
|
process::signal::{PollHandle, Pollee},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Connecting {
|
pub struct Connecting {
|
||||||
@ -45,7 +45,7 @@ impl Connecting {
|
|||||||
self.info.disable_irq().lock().update_for_event(event)
|
self.info.disable_irq().lock().update_for_event(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
pub fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
self.pollee.poll(mask, poller)
|
self.pollee.poll(mask, poller)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ use crate::{
|
|||||||
VSOCK_GLOBAL,
|
VSOCK_GLOBAL,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollee, Poller},
|
process::signal::{PollHandle, Pollee},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Init {
|
pub struct Init {
|
||||||
@ -61,7 +61,7 @@ impl Init {
|
|||||||
*self.bound_addr.lock()
|
*self.bound_addr.lock()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
pub fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
self.pollee.poll(mask, poller)
|
self.pollee.poll(mask, poller)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ use crate::{
|
|||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
net::socket::vsock::addr::VsockSocketAddr,
|
net::socket::vsock::addr::VsockSocketAddr,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollee, Poller},
|
process::signal::{PollHandle, Pollee},
|
||||||
};
|
};
|
||||||
pub struct Listen {
|
pub struct Listen {
|
||||||
addr: VsockSocketAddr,
|
addr: VsockSocketAddr,
|
||||||
@ -51,7 +51,7 @@ impl Listen {
|
|||||||
Ok(connection)
|
Ok(connection)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
pub fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
self.pollee.poll(mask, poller)
|
self.pollee.poll(mask, poller)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ use crate::{
|
|||||||
MessageHeader, SendRecvFlags, SockShutdownCmd, Socket, SocketAddr,
|
MessageHeader, SendRecvFlags, SockShutdownCmd, Socket, SocketAddr,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollable, Poller},
|
process::signal::{PollHandle, Pollable},
|
||||||
util::{MultiRead, MultiWrite},
|
util::{MultiRead, MultiWrite},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ impl VsockStreamSocket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for VsockStreamSocket {
|
impl Pollable for VsockStreamSocket {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
match &*self.status.read() {
|
match &*self.status.read() {
|
||||||
Status::Init(init) => init.poll(mask, poller),
|
Status::Init(init) => init.poll(mask, poller),
|
||||||
Status::Listen(listen) => listen.poll(mask, poller),
|
Status::Listen(listen) => listen.poll(mask, poller),
|
||||||
@ -231,7 +231,7 @@ impl Socket for VsockStreamSocket {
|
|||||||
vsockspace.request(&connecting.info()).unwrap();
|
vsockspace.request(&connecting.info()).unwrap();
|
||||||
// wait for response from driver
|
// wait for response from driver
|
||||||
// TODO: Add timeout
|
// TODO: Add timeout
|
||||||
let mut poller = Poller::new();
|
let mut poller = PollHandle::new();
|
||||||
if !connecting
|
if !connecting
|
||||||
.poll(IoEvents::IN, Some(&mut poller))
|
.poll(IoEvents::IN, Some(&mut poller))
|
||||||
.contains(IoEvents::IN)
|
.contains(IoEvents::IN)
|
||||||
|
@ -20,7 +20,7 @@ use c_types::{siginfo_t, ucontext_t};
|
|||||||
pub use events::{SigEvents, SigEventsFilter};
|
pub use events::{SigEvents, SigEventsFilter};
|
||||||
use ostd::{cpu::UserContext, user::UserContextApi};
|
use ostd::{cpu::UserContext, user::UserContextApi};
|
||||||
pub use pause::{with_signal_blocked, Pause};
|
pub use pause::{with_signal_blocked, Pause};
|
||||||
pub use poll::{Pollable, Pollee, Poller};
|
pub use poll::{PollHandle, Pollable, Pollee};
|
||||||
use sig_action::{SigAction, SigActionFlags, SigDefaultAction};
|
use sig_action::{SigAction, SigActionFlags, SigDefaultAction};
|
||||||
use sig_mask::SigMask;
|
use sig_mask::SigMask;
|
||||||
use sig_num::SigNum;
|
use sig_num::SigNum;
|
||||||
|
@ -44,7 +44,7 @@ impl Pollee {
|
|||||||
///
|
///
|
||||||
/// This operation is _atomic_ in the sense that if there are interesting events, either the
|
/// This operation is _atomic_ in the sense that if there are interesting events, either the
|
||||||
/// events are returned or the poller is notified.
|
/// events are returned or the poller is notified.
|
||||||
pub fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
pub fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
let mask = mask | IoEvents::ALWAYS_POLL;
|
let mask = mask | IoEvents::ALWAYS_POLL;
|
||||||
|
|
||||||
// Register the provided poller.
|
// Register the provided poller.
|
||||||
@ -56,7 +56,7 @@ impl Pollee {
|
|||||||
self.events() & mask
|
self.events() & mask
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_poller(&self, poller: &mut Poller, mask: IoEvents) {
|
fn register_poller(&self, poller: &mut PollHandle, mask: IoEvents) {
|
||||||
self.inner
|
self.inner
|
||||||
.subject
|
.subject
|
||||||
.register_observer(poller.observer(), mask);
|
.register_observer(poller.observer(), mask);
|
||||||
@ -127,7 +127,7 @@ impl Pollee {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A poller gets notified when its associated pollees have interesting events.
|
/// A poller gets notified when its associated pollees have interesting events.
|
||||||
pub struct Poller {
|
pub struct PollHandle {
|
||||||
// Use event counter to wait or wake up a poller
|
// Use event counter to wait or wake up a poller
|
||||||
event_counter: Arc<EventCounter>,
|
event_counter: Arc<EventCounter>,
|
||||||
// All pollees that are interesting to this poller
|
// All pollees that are interesting to this poller
|
||||||
@ -136,14 +136,14 @@ pub struct Poller {
|
|||||||
waiter: Waiter,
|
waiter: Waiter,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Poller {
|
impl Default for PollHandle {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new()
|
Self::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Poller {
|
impl PollHandle {
|
||||||
/// Constructs a new `Poller`.
|
/// Constructs a new `PollHandle`.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let (waiter, waker) = Waiter::new_pair();
|
let (waiter, waker) = Waiter::new_pair();
|
||||||
Self {
|
Self {
|
||||||
@ -167,7 +167,7 @@ impl Poller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Poller {
|
impl Drop for PollHandle {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let observer = self.observer();
|
let observer = self.observer();
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ pub trait Pollable {
|
|||||||
/// poller is provided.
|
/// poller is provided.
|
||||||
///
|
///
|
||||||
/// This method has the same semantics as [`Pollee::poll`].
|
/// This method has the same semantics as [`Pollee::poll`].
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents;
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents;
|
||||||
|
|
||||||
/// Waits for events and performs event-based operations.
|
/// Waits for events and performs event-based operations.
|
||||||
///
|
///
|
||||||
@ -270,7 +270,7 @@ pub trait Pollable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait until the event happens.
|
// Wait until the event happens.
|
||||||
let mut poller = Poller::new();
|
let mut poller = PollHandle::new();
|
||||||
if self.poll(mask, Some(&mut poller)).is_empty() {
|
if self.poll(mask, Some(&mut poller)).is_empty() {
|
||||||
poller.wait(timeout)?;
|
poller.wait(timeout)?;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::{
|
process::{
|
||||||
signal::{Pollable, Pollee, Poller},
|
signal::{PollHandle, Pollable, Pollee},
|
||||||
Gid, Uid,
|
Gid, Uid,
|
||||||
},
|
},
|
||||||
time::clocks::RealTimeClock,
|
time::clocks::RealTimeClock,
|
||||||
@ -174,7 +174,7 @@ impl EventFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pollable for EventFile {
|
impl Pollable for EventFile {
|
||||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents {
|
||||||
self.pollee.poll(mask, poller)
|
self.pollee.poll(mask, poller)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ use crate::{
|
|||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
fs::{file_handle::FileLike, file_table::FileDesc},
|
fs::{file_handle::FileLike, file_table::FileDesc},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::Poller,
|
process::signal::PollHandle,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn sys_poll(fds: Vaddr, nfds: u64, timeout: i32, ctx: &Context) -> Result<SyscallReturn> {
|
pub fn sys_poll(fds: Vaddr, nfds: u64, timeout: i32, ctx: &Context) -> Result<SyscallReturn> {
|
||||||
@ -126,13 +126,13 @@ fn hold_files(poll_fds: &[PollFd], ctx: &Context) -> (FileResult, Vec<Option<Arc
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum PollerResult {
|
enum PollerResult {
|
||||||
AllRegistered(Poller),
|
AllRegistered(PollHandle),
|
||||||
EventFoundAt(usize),
|
EventFoundAt(usize),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Registers the files with a poller, or exits early if some events are detected.
|
/// Registers the files with a poller, or exits early if some events are detected.
|
||||||
fn register_poller(poll_fds: &[PollFd], files: &[Option<Arc<dyn FileLike>>]) -> PollerResult {
|
fn register_poller(poll_fds: &[PollFd], files: &[Option<Arc<dyn FileLike>>]) -> PollerResult {
|
||||||
let mut poller = Poller::new();
|
let mut poller = PollHandle::new();
|
||||||
|
|
||||||
for (i, (poll_fd, file)) in poll_fds.iter().zip(files.iter()).enumerate() {
|
for (i, (poll_fd, file)) in poll_fds.iter().zip(files.iter()).enumerate() {
|
||||||
let Some(file) = file else {
|
let Some(file) = file else {
|
||||||
|
Reference in New Issue
Block a user