Class MultiplexingDispatchable¶
Defined in File multiplexing_dispatchable.h
Inheritance Relationships¶
Base Type¶
public mir::dispatch::Dispatchable
(Class Dispatchable)
Class Documentation¶
-
class MultiplexingDispatchable : public mir::dispatch::Dispatchable¶
An adaptor that combines multiple Dispatchables into a single Dispatchable.
Note
Instances are fully thread-safe.
Public Functions
-
MultiplexingDispatchable()¶
-
virtual ~MultiplexingDispatchable() noexcept¶
-
MultiplexingDispatchable &operator=(MultiplexingDispatchable const&) = delete¶
-
MultiplexingDispatchable(MultiplexingDispatchable const&) = delete¶
-
virtual Fd watch_fd() const override¶
Get a poll()able file descriptor.
- Returns:
A file descriptor usable with poll() or equivalent function calls. relevant_events() contains the set of event types to watch for.
-
virtual bool dispatch(FdEvents events) override¶
Dispatch one pending event.
- Parameters:
events – [in] The set of events current on the file-descriptor
- Returns:
False iff no more events will be produced by this Dispatchable. Dispatch should no longer be called.
Note
This will dispatch at most one event. If there are multiple events specified in
events
(eg: readable | remote_closed) then dispatch will process only one.Note
It is harmless to call dispatch() with an event that does not contain any of the events from relevant_events(). The function will do nothing in such a case.
Note
An implementation of dispatch() MUST handle FdEvent::error, if only to return false and terminate further event dispatch.
-
virtual FdEvents relevant_events() const override¶
The set of file-descriptor events this Dispatchable handles.
Add a dispatchable to the adaptor.
- Parameters:
dispatchee – [in] Dispatchable to add. The Dispatchable’s dispatch() function will not be called reentrantly.
Add a dispatchable to the adaptor, specifying the reentrancy of dispatch()
-
void add_watch(Fd const &fd, std::function<void()> const &callback)¶
Add a simple callback to the adaptor.
- Parameters:
fd – [in] File descriptor to monitor for readability
callback – [in] Callback to fire when
fd
becomes readable. This callback is not called reentrantly.
Remove a watch from the dispatchable.
- Parameters:
dispatchee – [in] Dispatchable to remove
-
MultiplexingDispatchable()¶