diff options
author | Barnabás Pőcze <pobrn@protonmail.com> | 2025-01-14 16:38:56 +0100 |
---|---|---|
committer | Barnabás Pőcze <pobrn@protonmail.com> | 2025-02-27 17:29:28 +0100 |
commit | 54055dd0c21caac78fae4d983857cd67a587fa73 (patch) | |
tree | ccc9fda9b87a38f3c6c38f1840f6d38b7b4346cd /src/apps | |
parent | a0f4092c6c7103db2d0a14adda49959378d48c1b (diff) |
apps: common: event_loop: Use `std::deque` instead of `std::list`
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@protonmail.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Diffstat (limited to 'src/apps')
-rw-r--r-- | src/apps/common/event_loop.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/apps/common/event_loop.h b/src/apps/common/event_loop.h index 4e8dd0a4..76007588 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_; |