Struct wayland_server::EventLoop
[−]
[src]
pub struct EventLoop { /* fields omitted */ }
Methods
impl EventLoop
[src]
fn new() -> EventLoop
Create a new EventLoop
It is not associated to a wayland socket, and can be used for other event sources.
fn dispatch(&mut self, timeout: Option<u32>) -> IoResult<u32>
Dispatch pending requests to their respective handlers
If no request is pending, will block at most timeout
ms if specified,
or indefinitely if timeout
is None
.
Returns the number of requests dispatched or an error.
fn run(&mut self) -> IoResult<()>
Runs the event loop
This method will call repetitively the dispatch method,
until one of the handlers call the stop_loop
method
on the EventLoopHandle
.
If this event loop is attached to a display, it will also
flush the events to the clients between two calls to
dispatch()
.
fn register_global<R: Resource, H: GlobalHandler<R> + Any + 'static>(&mut self,
handler_id: usize,
version: i32)
-> Global
handler_id: usize,
version: i32)
-> Global
Register a global object to the display.
Specify the version of the interface to advertize, as well as the handler that will receive requests to create an object.
The handler must implement the appropriate GlobalHandler<R>
trait.
Panics:
- if the event loop is not associated to a display
- if the provided
H
type does not match the actual type of the handler
fn state(&mut self) -> StateGuard
Get an handle to the internal state
The returned guard object allows you to get references to the handler objects you previously inserted in this event loop.
fn add_fd_event_source<H>(&mut self,
fd: RawFd,
handler_id: usize,
interest: FdInterest)
-> IoResult<FdEventSource> where H: FdEventSourceHandler + 'static
fd: RawFd,
handler_id: usize,
interest: FdInterest)
-> IoResult<FdEventSource> where H: FdEventSourceHandler + 'static
Add a File Descriptor event source to this event loop
The interest in read/write capability for this FD must be provided (and can be changed afterwards using the returned object), and the associated handler will be called whenever these capabilities are satisfied, during the dispatching of this event loop.
fn add_timer_event_source<H>(&mut self,
handler_id: usize)
-> IoResult<TimerEventSource> where H: TimerEventSourceHandler + 'static
handler_id: usize)
-> IoResult<TimerEventSource> where H: TimerEventSourceHandler + 'static
Add a timer event source to this event loop
It is a countdown, which can be reset using the struct returned by this function. When the countdown reaches 0, the registered handler is called in the dispatching of this event loop.
fn add_signal_event_source<H>(&mut self,
signal: Signal,
handler_id: usize)
-> IoResult<SignalEventSource> where H: SignalEventSourceHandler + 'static
signal: Signal,
handler_id: usize)
-> IoResult<SignalEventSource> where H: SignalEventSourceHandler + 'static
Add a signal event source to this event loop
This will listen for a given unix signal (by setting up a signalfd for it) and call the registered handler whenever the program receives this signal. Calls are made during the dispatching of this event loop.
Methods from Deref<Target=EventLoopHandle>
fn register<R: Resource, H: Handler<R> + Any + Send + 'static>(&mut self,
resource: &R,
handler_id: usize)
resource: &R,
handler_id: usize)
Register a resource to a handler of this event loop.
The H type must be provided and match the type of the targetted Handler, or it will panic.
This overwrites any precedently set Handler for this resource and removes its destructor if any.
fn register_with_destructor<R, H, D>(&mut self, resource: &R, handler_id: usize) where R: Resource,
H: Handler<R> + Any + Send + 'static,
D: Destroy<R> + 'static
H: Handler<R> + Any + Send + 'static,
D: Destroy<R> + 'static
Register a resource to a handler of this event loop with a destructor
The H type must be provided and match the type of the targetted Handler, or it will panic.
The D type is the one whose Destroy<R>
impl will be used as destructor.
This overwrites any precedently set Handler and destructor for this resource.
fn add_handler<H: Any + Send + 'static>(&mut self, handler: H) -> usize
Insert a new handler to this EventLoop
Returns the index of this handler in the internal array, needed register proxies to it.
fn add_handler_with_init<H: Init + Any + Send + 'static>(&mut self,
handler: H)
-> usize
handler: H)
-> usize
Insert a new handler with init
Allows you to insert handlers that require some interaction with the event loop in their initialization, like registering some objects to it.
The handler must implement the Init
trait, and its init method will
be called after its insertion.
fn stop_loop(&mut self)
Stop looping
If the event loop this handle belongs to is currently running its run()
method, it'll stop and return as soon as the current dispatching session ends.
Trait Implementations
impl Send for EventLoop
[src]
impl Deref for EventLoop
[src]
type Target = EventLoopHandle
The resulting type after dereferencing
fn deref(&self) -> &EventLoopHandle
The method called to dereference a value
impl DerefMut for EventLoop
[src]
fn deref_mut(&mut self) -> &mut EventLoopHandle
The method called to mutably dereference a value