libcamera: libcamera::EventDispatcher Class Reference

libcamera v0.5.1 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
libcamera::EventDispatcher Class Referenceabstract

Interface to manage the libcamera events and timers. More...

Inheritance diagram for libcamera::EventDispatcher:
[legend]

## Public Member Functions
virtual void | registerEventNotifier (EventNotifier *notifier)=0
| Register an event notifier.
virtual void | unregisterEventNotifier (EventNotifier *notifier)=0
| Unregister an event notifier.
virtual void | registerTimer (Timer *timer)=0
| Register a timer.
virtual void | unregisterTimer (Timer *timer)=0
| Unregister a timer.
virtual void | processEvents ()=0
| Wait for and process pending events.
virtual void | interrupt ()=0
| Interrupt any running processEvents() call as soon as possible.

## Detailed Description

Interface to manage the libcamera events and timers.

The EventDispatcher class allows the integration of the application event loop with libcamera by abstracting how events and timers are managed and processed.

To listen to events, libcamera creates EventNotifier instances and registers them with the dispatcher with registerEventNotifier(). The event notifier EventNotifier::activated signal is then emitted by the dispatcher whenever the event is detected.

To set timers, libcamera creates Timer instances and registers them with the dispatcher with registerTimer(). The timer Timer::timeout signal is then emitted by the dispatcher when the timer times out.

## Member Function Documentation

## ◆ interrupt()

virtual void libcamera::EventDispatcher::interrupt | ( |  | ) |
| pure virtual

Interrupt any running processEvents() call as soon as possible.

Calling this function interrupts any blocking processEvents() call in progress. The processEvents() function will return as soon as possible, after processing pending timers and events. If processEvents() isn't in progress, it will be interrupted immediately the next time it gets called.

Implemented in libcamera::EventDispatcherPoll.

## ◆ processEvents()

virtual void libcamera::EventDispatcher::processEvents | ( |  | ) |
| pure virtual

Wait for and process pending events.

This function processes all pending events associated with registered event notifiers and timers and signals the corresponding EventNotifier and Timer objects. If no events are pending, it waits for the first event and processes it before returning.

Implemented in libcamera::EventDispatcherPoll.

## ◆ registerEventNotifier()

virtual void libcamera::EventDispatcher::registerEventNotifier | ( | EventNotifier * | notifier | ) |
| pure virtual

Register an event notifier.

Parameters

  [in] | notifier | The event notifier to register

Once the notifier is registered with the dispatcher, the dispatcher will emit the notifier EventNotifier::activated signal whenever a corresponding event is detected on the notifier's file descriptor. The event is monitored until the notifier is unregistered with unregisterEventNotifier().

Registering multiple notifiers for the same file descriptor and event type is not allowed and results in undefined behaviour.

Implemented in libcamera::EventDispatcherPoll.

## ◆ registerTimer()

virtual void libcamera::EventDispatcher::registerTimer | ( | Timer * | timer | ) |
| pure virtual

Register a timer.

Parameters

  [in] | timer | The timer to register

Once the timer is registered with the dispatcher, the dispatcher will emit the timer Timer::timeout signal when the timer times out. The timer can be unregistered with unregisterTimer() before it times out, in which case the signal will not be emitted.

When the timer times out, it is automatically unregistered by the dispatcher and can be registered back as early as from the Timer::timeout signal handlers.

Registering the same timer multiple times is not allowed and results in undefined behaviour.

Implemented in libcamera::EventDispatcherPoll.

## ◆ unregisterEventNotifier()

virtual void libcamera::EventDispatcher::unregisterEventNotifier | ( | EventNotifier * | notifier | ) |
| pure virtual

Unregister an event notifier.

Parameters

  [in] | notifier | The event notifier to unregister

After this function returns the notifier is guaranteed not to emit the EventNotifier::activated signal.

If the notifier isn't registered, this function performs no operation.

Implemented in libcamera::EventDispatcherPoll.

## ◆ unregisterTimer()

virtual void libcamera::EventDispatcher::unregisterTimer | ( | Timer * | timer | ) |
| pure virtual

Unregister a timer.

Parameters

  [in] | timer | The timer to unregister

After this function returns the timer is guaranteed not to emit the Timer::timeout signal.

If the timer isn't registered, this function performs no operation.

Implemented in libcamera::EventDispatcherPoll.

The documentation for this class was generated from the following files:

- include/libcamera/base/event_dispatcher.h
- src/libcamera/base/event_dispatcher.cpp