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>
This commit is contained in:
parent
a0f4092c6c
commit
54055dd0c2
1 changed files with 3 additions and 1 deletions
|
@ -8,6 +8,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <deque>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -63,7 +64,8 @@ private:
|
||||||
struct event_base *base_;
|
struct event_base *base_;
|
||||||
int exitCode_;
|
int exitCode_;
|
||||||
|
|
||||||
std::list<std::function<void()>> calls_;
|
std::deque<std::function<void()>> calls_;
|
||||||
|
|
||||||
std::list<std::unique_ptr<Event>> events_;
|
std::list<std::unique_ptr<Event>> events_;
|
||||||
std::mutex lock_;
|
std::mutex lock_;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue