Wayland++
0.2.6
C++ Bindings for Wayland
|
Represents an intention to read from the display file descriptor. More...
#include <wayland-client.hpp>
Public Member Functions | |
bool | is_finalized () const |
Check whether this intent was already finalized with cancel or read. More... | |
void | cancel () |
Cancel read intent. More... | |
void | read () |
Read events from display file descriptor. More... | |
Represents an intention to read from the display file descriptor.
When not using the convenience method display_t::dispatch that takes care of this automatically, threads that want to read events from a Wayland display file descriptor must announce their intention to do so beforehand - in the C API, this is done using wl_display_prepare_read. This intention must then be resolved either by actually invoking a read from the file descriptor or cancelling.
This RAII class makes sure that when it goes out of scope, the intent is cancelled automatically if it was not finalized by manually cancelling or reading before. Otherwise, it would be easy to forget resolving the intent e.g. when handling errors, potentially leading to a deadlock.
Read intents can only be created by a display_t with display_t::obtain_read_intent and display_t::obtain_queue_read_intent.
Undefined behavior occurs when the associated display_t or event_queue_t is destroyed when a read_intent has not been finalized yet.
Definition at line 357 of file wayland-client.hpp.
void wayland::read_intent::cancel | ( | ) |
Cancel read intent.
An exception is thrown when the read intent was already finalized.
bool wayland::read_intent::is_finalized | ( | ) | const |
void wayland::read_intent::read | ( | ) |
Read events from display file descriptor.
This will read events from the file descriptor for the display. This function does not dispatch events, it only reads and queues events into their corresponding event queues. If no data is avilable on the file descriptor, read() returns immediately. To dispatch events that may have been queued, call display_t::dispatch_pending or display_t::dispatch_queue_pending.
An exception is thrown when the read intent was already finalized. Each read intent can only be used for reading once. A new one must be obtained for any further read requests.