diff --git a/core/src/coroutine/korosensei.rs b/core/src/coroutine/korosensei.rs
index fa83623b..adcfa51a 100644
--- a/core/src/coroutine/korosensei.rs
+++ b/core/src/coroutine/korosensei.rs
@@ -419,8 +419,14 @@ where
local: CoroutineLocal::default(),
priority,
};
- #[cfg(all(unix, feature = "preemptive"))]
- co.add_listener(crate::monitor::MonitorListener::::new());
+ cfg_if::cfg_if! {
+ if #[cfg(all(unix, feature = "preemptive"))] {
+ let type_id = std::any::TypeId::of::<()>();
+ if std::any::TypeId::of::() == type_id && std::any::TypeId::of::() == type_id {
+ co.add_listener(crate::monitor::MonitorListener);
+ }
+ }
+ }
Ok(co)
}
diff --git a/core/src/monitor.rs b/core/src/monitor.rs
index fb1e3a97..b57623b5 100644
--- a/core/src/monitor.rs
+++ b/core/src/monitor.rs
@@ -7,12 +7,10 @@ use crate::scheduler::SchedulableSuspender;
use crate::{catch, error, impl_current_for, impl_display_by_debug, info};
use nix::sys::pthread::{pthread_kill, pthread_self, Pthread};
use nix::sys::signal::{sigaction, SaFlags, SigAction, SigHandler, SigSet, Signal};
-use std::any::TypeId;
use std::cell::{Cell, UnsafeCell};
use std::collections::HashSet;
use std::fmt::Debug;
use std::io::{Error, ErrorKind};
-use std::marker::PhantomData;
use std::mem::MaybeUninit;
use std::sync::Arc;
use std::thread::JoinHandle;
@@ -176,35 +174,19 @@ impl Monitor {
impl_current_for!(MONITOR, Monitor);
#[repr(C)]
-#[derive(educe::Educe)]
-#[educe(Debug(named_field = false))]
-pub(crate) struct MonitorListener(
- PhantomData,
- PhantomData,
- PhantomData,
-);
-
-impl MonitorListener {
- pub(crate) fn new() -> Self {
- Self(PhantomData, PhantomData, PhantomData)
- }
-}
+#[derive(Debug)]
+pub(crate) struct MonitorListener;
const NOTIFY_NODE: &str = "MONITOR_NODE";
-impl Listener
- for MonitorListener
-{
+impl Listener for MonitorListener {
fn on_state_changed(
&self,
local: &CoroutineLocal,
_: CoroutineState,
new_state: CoroutineState,
) {
- if TypeId::of::() != TypeId::of::<()>()
- || TypeId::of::() != TypeId::of::<()>()
- || Monitor::current().is_some()
- {
+ if Monitor::current().is_some() {
return;
}
match new_state {