The libcamera internal headers are located in src/libcamera/include/. The directory is added to the compiler headers search path with a meson include_directories() directive, and internal headers are included with (e.g. for the internal semaphore.h header) #include "semaphore.h" All was well, until libcxx decided to implement the C++20 synchronization library. The __threading_support header gained a #include <semaphore.h> to include the pthread's semaphore support. As include_directories() adds src/libcamera/include/ to the compiler search path with -I, the internal semaphore.h is included instead of the pthread version. Needless to say, the compiler isn't happy. Three options have been considered to fix this issue: - Use -iquote instead of -I. The -iquote option instructs gcc to only consider the header search path for headers included with the "" version. Meson unfortunately doesn't support this option. - Rename the internal semaphore.h header. This was deemed to be the beginning of a long whack-a-mole game, where namespace clashes with system libraries would appear over time (possibly dependent on particular system configurations) and would need to be constantly fixed. - Move the internal headers to another directory to create a unique namespace through path components. This causes lots of churn in all the existing source files through the all project. The first option would be best, but isn't available to us due to missing support in meson. Even if -iquote support was added, we would need to fix the problem before a new version of meson containing the required support would be released. The third option is thus the only practical solution available. Bite the bullet, and do it, moving headers to include/libcamera/internal/. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org>
118 lines
3.8 KiB
C++
118 lines
3.8 KiB
C++
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Copyright (C) 2019, Google Inc.
|
|
*
|
|
* event_dispatcher.cpp - Event dispatcher
|
|
*/
|
|
|
|
#include <libcamera/event_dispatcher.h>
|
|
|
|
#include "libcamera/internal/log.h"
|
|
|
|
/**
|
|
* \file event_dispatcher.h
|
|
*/
|
|
|
|
namespace libcamera {
|
|
|
|
LOG_DEFINE_CATEGORY(Event)
|
|
|
|
/**
|
|
* \class EventDispatcher
|
|
* \brief 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
|
|
* \ref 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 \ref Timer::timeout signal is then
|
|
* emitted by the dispatcher when the timer times out.
|
|
*/
|
|
|
|
EventDispatcher::~EventDispatcher()
|
|
{
|
|
}
|
|
|
|
/**
|
|
* \fn EventDispatcher::registerEventNotifier()
|
|
* \brief Register an event notifier
|
|
* \param[in] notifier The event notifier to register
|
|
*
|
|
* Once the \a notifier is registered with the dispatcher, the dispatcher will
|
|
* emit the notifier \ref 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.
|
|
*/
|
|
|
|
/**
|
|
* \fn EventDispatcher::unregisterEventNotifier()
|
|
* \brief Unregister an event notifier
|
|
* \param[in] notifier The event notifier to unregister
|
|
*
|
|
* After this function returns the \a notifier is guaranteed not to emit the
|
|
* \ref EventNotifier::activated signal.
|
|
*
|
|
* If the notifier isn't registered, this function performs no operation.
|
|
*/
|
|
|
|
/**
|
|
* \fn EventDispatcher::registerTimer()
|
|
* \brief Register a timer
|
|
* \param[in] timer The timer to register
|
|
*
|
|
* Once the \a timer is registered with the dispatcher, the dispatcher will emit
|
|
* the timer \ref 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 \a timer times out, it is automatically unregistered by the
|
|
* dispatcher and can be registered back as early as from the \ref Timer::timeout
|
|
* signal handlers.
|
|
*
|
|
* Registering the same timer multiple times is not allowed and results in
|
|
* undefined behaviour.
|
|
*/
|
|
|
|
/**
|
|
* \fn EventDispatcher::unregisterTimer()
|
|
* \brief Unregister a timer
|
|
* \param[in] timer The timer to unregister
|
|
*
|
|
* After this function returns the \a timer is guaranteed not to emit the
|
|
* \ref Timer::timeout signal.
|
|
*
|
|
* If the timer isn't registered, this function performs no operation.
|
|
*/
|
|
|
|
/**
|
|
* \fn EventDispatcher::processEvents()
|
|
* \brief 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.
|
|
*/
|
|
|
|
/**
|
|
* \fn EventDispatcher::interrupt()
|
|
* \brief 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.
|
|
*/
|
|
|
|
} /* namespace libcamera */
|