[RFC PATCH v2 03/16] apps: common: event_loop: Use `std::deque` instead of `std::list`
Jacopo Mondi
jacopo.mondi at ideasonboard.com
Wed Jan 22 10:05:37 CET 2025
Hi Barnabás
On Tue, Jan 14, 2025 at 06:22:01PM +0000, Barnabás Pőcze wrote:
> Deque has fast pop_front and push_back operations while making
> fewer allocations for the same number of elements as an `std::list`.
> So use an `std::deque` for storing the deferred calls of the loop.
>
> Signed-off-by: Barnabás Pőcze <pobrn at protonmail.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi at ideasonboard.com>
Thanks
j
> ---
> src/apps/common/event_loop.h | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/apps/common/event_loop.h b/src/apps/common/event_loop.h
> index 4e8dd0a46..760075885 100644
> --- a/src/apps/common/event_loop.h
> +++ b/src/apps/common/event_loop.h
> @@ -8,6 +8,7 @@
> #pragma once
>
> #include <chrono>
> +#include <deque>
> #include <functional>
> #include <list>
> #include <memory>
> @@ -63,7 +64,8 @@ private:
> struct event_base *base_;
> int exitCode_;
>
> - std::list<std::function<void()>> calls_;
> + std::deque<std::function<void()>> calls_;
> +
> std::list<std::unique_ptr<Event>> events_;
> std::mutex lock_;
>
> --
> 2.48.0
>
>
More information about the libcamera-devel
mailing list