Struct dbs_utils::epoll_manager::EpollManager
source · [−]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
sourceimpl 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
sourceimpl Clone for EpollManager
impl Clone for EpollManager
sourcefn clone(&self) -> EpollManager
fn clone(&self) -> EpollManager
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Default for EpollManager
impl Default for EpollManager
Auto Trait Implementations
impl RefUnwindSafe for EpollManager
impl Send for EpollManager
impl Sync for EpollManager
impl Unpin for EpollManager
impl UnwindSafe for EpollManager
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more