Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions core/src/net/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::common::constants::{CoroutineState, PoolState, Syscall, SyscallState,
use crate::net::selector::{Event, Events, Poller, Selector};
use crate::scheduler::SchedulableCoroutine;
use crate::{error, impl_current_for, impl_display_by_debug, info};
use crossbeam_utils::atomic::AtomicCell;
use dashmap::DashSet;
use once_cell::sync::Lazy;
use rand::Rng;
Expand All @@ -28,8 +27,6 @@ cfg_if::cfg_if! {
#[repr(C)]
#[derive(Debug)]
pub(crate) struct EventLoop<'e> {
//状态
state: AtomicCell<PoolState>,
stop: Arc<(Mutex<bool>, Condvar)>,
shared_stop: Arc<(Mutex<AtomicUsize>, Condvar)>,
cpu: usize,
Expand Down Expand Up @@ -87,7 +84,6 @@ impl<'e> EventLoop<'e> {
shared_stop: Arc<(Mutex<AtomicUsize>, Condvar)>,
) -> std::io::Result<Self> {
Ok(EventLoop {
state: AtomicCell::new(PoolState::Running),
stop: Arc::new((Mutex::new(false), Condvar::new())),
shared_stop,
cpu,
Expand Down
34 changes: 18 additions & 16 deletions core/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,26 +322,28 @@ impl<'s> Scheduler<'s> {

fn check_ready(&mut self) -> std::io::Result<()> {
// Check if the elements in the suspend queue are ready
if let Some(item) = self.suspend.peek() {
if now() >= item.timestamp {
if let Some(item) = self.suspend.pop() {
item.coroutine.ready()?;
self.ready.push(item.coroutine);
}
while let Some(item) = self.suspend.peek() {
if now() < item.timestamp {
break;
}
if let Some(item) = self.suspend.pop() {
item.coroutine.ready()?;
self.ready.push(item.coroutine);
}
}
// Check if the elements in the syscall suspend queue are ready
if let Some(item) = self.syscall_suspend.peek() {
if now() >= item.timestamp {
if let Some(item) = self.syscall_suspend.pop() {
if let Some((_, co)) = self.syscall.remove(item.co_name) {
match co.state() {
CoroutineState::SystemCall(val, syscall, SyscallState::Suspend(_)) => {
co.syscall(val, syscall, SyscallState::Timeout)?;
self.ready.push(co);
}
_ => unreachable!("check_ready should never execute to here"),
while let Some(item) = self.syscall_suspend.peek() {
if now() < item.timestamp {
break;
}
if let Some(item) = self.syscall_suspend.pop() {
if let Some((_, co)) = self.syscall.remove(item.co_name) {
match co.state() {
CoroutineState::SystemCall(val, syscall, SyscallState::Suspend(_)) => {
co.syscall(val, syscall, SyscallState::Timeout)?;
self.ready.push(co);
}
_ => unreachable!("check_ready should never execute to here"),
}
}
}
Expand Down
Loading