fn internal_notifiers(balloon_io: Arc<Mutex<Self>>) -> Vec<EventNotifier> {
        let mut notifiers = Vec::new();
        let locked_balloon_io = balloon_io.lock().unwrap();

        // register event notifier for inflate event.
        let cloned_balloon_io = balloon_io.clone();
        let handler: Box<NotifierCallback> = Box::new(move |_, fd: RawFd| {
            read_fd(fd);
            if let Err(e) = cloned_balloon_io
                .lock()
                .unwrap()
                .process_balloon_queue(BALLOON_INFLATE_EVENT)
            {
                error!("Failed to inflate balloon: {}", e.display_chain());
            };
            None
        });
        notifiers.push(build_event_notifier(
            locked_balloon_io.inf_evt.as_raw_fd(),
            handler,
        ));

        // register event notifier for deflate event.
        let cloned_balloon_io = balloon_io.clone();
        let handler: Box<NotifierCallback> = Box::new(move |_, fd: RawFd| {
            read_fd(fd);
            if let Err(e) = cloned_balloon_io
                .lock()
                .unwrap()
                .process_balloon_queue(BALLOON_DEFLATE_EVENT)
            {
                error!("Failed to deflate balloon: {}", e.display_chain());
            };
            None
        });
        notifiers.push(build_event_notifier(
            locked_balloon_io.def_evt.as_raw_fd(),
            handler,
        ));

        // register event notifier for reset event.
        let cloned_balloon_io = balloon_io.clone();
        let handler: Box<NotifierCallback> = Box::new(move |_, fd: RawFd| {
            read_fd(fd);
            Some(cloned_balloon_io.lock().unwrap().reset_evt_handler())
        });
        notifiers.push(build_event_notifier(locked_balloon_io.reset_evt, handler));

        // register event notifier for timer event.
        let cloned_balloon_io = balloon_io.clone();
        let handler: Box<NotifierCallback> = Box::new(move |_, fd: RawFd| {
            read_fd(fd);
            cloned_balloon_io
                .lock()
                .unwrap()
                .send_balloon_changed_event();
            None
        });
        notifiers.push(build_event_notifier(
            locked_balloon_io
                .event_timer
                .clone()
                .lock()
                .unwrap()
                .as_raw_fd(),
            handler,
        ));

        notifiers
    }
/// Register event notifiers for different queue event.
Register event notifiers for different queue event.
Register event notifiers for different queue event .
fn internal_notifiers(balloon_io: Arc<Mutex<Self>>) -> Vec<EventNotifier> {
        let mut notifiers = Vec::new();
        let locked_balloon_io = balloon_io.lock().unwrap();
        // register event notifier for inflate event.
        let cloned_balloon_io = balloon_io.clone();
        let handler: Box<NotifierCallback> = Box::new(move |_, fd: RawFd| {
            read_fd(fd);
            if let Err(e) = cloned_balloon_io
                .lock()
                .unwrap()
                .process_balloon_queue(BALLOON_INFLATE_EVENT)
            {
                error!("Failed to inflate balloon: {}", e.display_chain());
            };
            None
        });
        notifiers.push(build_event_notifier(
            locked_balloon_io.inf_evt.as_raw_fd(),
            handler,
        ));
        // register event notifier for deflate event.
        let cloned_balloon_io = balloon_io.clone();
        let handler: Box<NotifierCallback> = Box::new(move |_, fd: RawFd| {
            read_fd(fd);
            if let Err(e) = cloned_balloon_io
                .lock()
                .unwrap()
                .process_balloon_queue(BALLOON_DEFLATE_EVENT)
            {
                error!("Failed to deflate balloon: {}", e.display_chain());
            };
            None
        });
        notifiers.push(build_event_notifier(
            locked_balloon_io.def_evt.as_raw_fd(),
            handler,
        ));
        // register event notifier for reset event.
        let cloned_balloon_io = balloon_io.clone();
        let handler: Box<NotifierCallback> = Box::new(move |_, fd: RawFd| {
            read_fd(fd);
            Some(cloned_balloon_io.lock().unwrap().reset_evt_handler())
        });
        notifiers.push(build_event_notifier(locked_balloon_io.reset_evt, handler));
        // register event notifier for timer event.
        let cloned_balloon_io = balloon_io.clone();
        let handler: Box<NotifierCallback> = Box::new(move |_, fd: RawFd| {
            read_fd(fd);
            cloned_balloon_io
                .lock()
                .unwrap()
                .send_balloon_changed_event();
            None
        });
        notifiers.push(build_event_notifier(
            locked_balloon_io
                .event_timer
                .clone()
                .lock()
                .unwrap()
                .as_raw_fd(),
            handler,
        ));
        notifiers
    }
fn internal_notifiers ( balloon_io : Arc < Mutex < Self > > ) -> Vec < EventNotifier > { let mut notifiers = Vec :: new ( ) ; let locked_balloon_io = balloon_io . lock ( ) . unwrap ( ) ; // register event notifier for inflate event. let cloned_balloon_io = balloon_io . clone ( ) ; let handler : Box < NotifierCallback > = Box :: new ( move | _ , fd : RawFd | { read_fd ( fd ) ; if let Err ( e ) = cloned_balloon_io . lock ( ) . unwrap ( ) . process_balloon_queue ( BALLOON_INFLATE_EVENT ) { error ! ( " " e display_chain ( ) ) ; } ; None } ) ; notifiers . push ( build_event_notifier ( locked_balloon_io . inf_evt . as_raw_fd ( ) , handler , ) ) ; // register event notifier for deflate event. let cloned_balloon_io = balloon_io . clone ( ) ; let handler : Box < NotifierCallback > = Box :: new ( move | _ , fd : RawFd | { read_fd ( fd ) ; if let Err ( e ) = cloned_balloon_io . lock ( ) . unwrap ( ) . process_balloon_queue ( BALLOON_DEFLATE_EVENT ) { error ! ( " " e display_chain ( ) ) ; } ; None } ) ; notifiers . push ( build_event_notifier ( locked_balloon_io . def_evt . as_raw_fd ( ) , handler , ) ) ; // register event notifier for reset event. let cloned_balloon_io = balloon_io . clone ( ) ; let handler : Box < NotifierCallback > = Box :: new ( move | _ , fd : RawFd | { read_fd ( fd ) ; Some ( cloned_balloon_io . lock ( ) . unwrap ( ) . reset_evt_handler ( ) ) } ) ; notifiers . push ( build_event_notifier ( locked_balloon_io . reset_evt , handler ) ) ; // register event notifier for timer event. let cloned_balloon_io = balloon_io . clone ( ) ; let handler : Box < NotifierCallback > = Box :: new ( move | _ , fd : RawFd | { read_fd ( fd ) ; cloned_balloon_io . lock ( ) . unwrap ( ) . send_balloon_changed_event ( ) ; None } ) ; notifiers . push ( build_event_notifier ( locked_balloon_io . event_timer . clone ( ) . lock ( ) . unwrap ( ) . as_raw_fd ( ) , handler , ) ) ; notifiers }
Register event notifiers for different queue event.
Register event notifiers for different queue event .
balloon_io
Arc<Mutex<Self>>
balloon_io
Arc<Mutex<Self>>