[][src]Struct xidlehook_core::Xidlehook

pub struct Xidlehook<T: Timer, M: Module> where
    T: Timer,
    M: Module
{ /* fields omitted */ }

The main xidlehook instance that allows you to schedule things

Implementations

impl<T: Timer> Xidlehook<T, ()>[src]

pub fn new(timers: Vec<T>) -> Self[src]

An empty instance without any modules

impl<T, M> Xidlehook<T, M> where
    T: Timer,
    M: Module
[src]

pub fn with_module<N: Module>(self, other: N) -> Xidlehook<T, N>[src]

Return this xidlehook instance but with this module replaced.

pub fn register<N: Module>(self, other: N) -> Xidlehook<T, (M, N)>[src]

Return this xidlehook instance but with an additional module activated. This works using the timer impl for (A, B) to get a fixed-size list of modules at compile time.

pub fn timers(&self) -> &Vec<T>[src]

Returns an immutable list of all timers

pub fn timers_mut(&mut self) -> Result<&mut Vec<T>>[src]

Returns a mutable list of all timers. Use this to add or remove timers as you wish. This will abort the idle chain as that may otherwise panic.

pub fn trigger(
    &mut self,
    index: usize,
    absolute_time: Duration,
    force: bool
) -> Result<Progress>
[src]

Skip ahead to the selected timer. Timers leading up to this point will not be ran. If you pass force, modules will not even be able to prevent this from happening (all requests pre-timer would be ignored). Post-timer requests are fully complied with.

Whatever the return value is, it's already been handled. If the return value is Err(...), that means this function invoked the module's warning function and that still wanted to propagate the error. If the return value is Ok(Progress::Abort), never mind it. The self.abort() function has already been invoked - it's all cool.

Panics

  • If the index is out of bounds

pub fn poll(&mut self, absolute_time: Duration) -> Result<Option<Duration>>[src]

Polls the scheduler for any activated timers. On success, returns the max amount of time a program can sleep for. Only fatal errors cause this function to return, and at that point, the state of xidlehook is undefined so it should not be used.

pub fn main_sync<F>(self, xcb: &Xcb, callback: F) -> Result<()> where
    F: FnMut() -> bool
[src]

Runs a standard poll-sleep-repeat loop.

static EXITED: AtomicBool = AtomicBool::new(false);

extern "C" fn exit_handler(_signo: libc::c_int) {
    EXITED.store(true, Ordering::SeqCst);
}

unsafe {
    signal::sigaction(
        signal::Signal::SIGINT,
        &signal::SigAction::new(
            signal::SigHandler::Handler(exit_handler),
            signal::SaFlags::empty(),
            signal::SigSet::empty(),
        ),
    )?;
}
xidlehook.main_sync(&xcb, || EXITED.load(Ordering::SeqCst));

Trait Implementations

impl<T, M> Debug for Xidlehook<T, M> where
    T: Timer,
    M: Module + Debug
[src]

Auto Trait Implementations

impl<T, M> RefUnwindSafe for Xidlehook<T, M> where
    M: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, M> Send for Xidlehook<T, M> where
    M: Send,
    T: Send

impl<T, M> Sync for Xidlehook<T, M> where
    M: Sync,
    T: Sync

impl<T, M> Unpin for Xidlehook<T, M> where
    M: Unpin,
    T: Unpin

impl<T, M> UnwindSafe for Xidlehook<T, M> where
    M: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.