pub struct EpollManager {
pub mgr: Arc<Mutex<EventManager<EpollSubscriber>>>,
/* private fields */
}
Expand description
A wrapper struct over EventManager to solve possible deadlock.
It’s a rather tough topic to deal with the epoll event manager in rust way. The event_manager::EventManager is designed for single-threaded environment and it leaves the task for concurrent access to the clients. There are two types of threads involved, epoll worker thread and vCPU threads. To reduce overhead, the epoll worker thread calls epoll::wait() without timeout, so the worker thread will hold the EpollManagerImpl::Mutex for undetermined periods. When the vCPU threads tries to activate virtio devices, they need to acquire the same EpollManagerImpl::Mutex. Thus the vCPU threads may block for an undetermined time. To solve this issue, we perform an kick()/try_lock() loop to wake up the epoll worker thread from sleeping.
Fields§
§mgr: Arc<Mutex<EventManager<EpollSubscriber>>>
Implementations§
Source§impl EpollManager
impl EpollManager
Sourcepub fn add_subscriber(&self, handler: EpollSubscriber) -> SubscriberId
pub fn add_subscriber(&self, handler: EpollSubscriber) -> SubscriberId
Add a new epoll event subscriber.
Sourcepub fn remove_subscriber(
&mut self,
subscriber_id: SubscriberId,
) -> Result<EpollSubscriber>
pub fn remove_subscriber( &mut self, subscriber_id: SubscriberId, ) -> Result<EpollSubscriber>
Remove a given epoll event subscriber.
Trait Implementations§
Source§impl Clone for EpollManager
impl Clone for EpollManager
Source§fn clone(&self) -> EpollManager
fn clone(&self) -> EpollManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more