Add a Producer/Consumer system.

It allow you to create the two end of a pipe: A producer and consumer.
The producer can be moved into another thread.
Several producer can be created if necessary.

This will ease merging:
https://github.com/ArthurSonzogni/FTXUI/pull/11
This commit is contained in:
ArthurSonzogni
2020-03-24 23:26:55 +01:00
parent 6de8c63907
commit 09a1b16613
7 changed files with 244 additions and 66 deletions

View File

@@ -10,6 +10,7 @@
#include "ftxui/component/event.hpp"
#include "ftxui/screen/screen.hpp"
#include <ftxui/component/producer_consumer.hpp>
namespace ftxui {
class Component;
@@ -40,13 +41,13 @@ class ScreenInteractive : public Screen {
Dimension dimension_ = Dimension::Fixed;
ScreenInteractive(int dimx, int dimy, Dimension dimension);
std::condition_variable events_queue_cv;
std::mutex events_queue_mutex;
std::queue<Event> events_queue;
std::atomic<bool> quit_ = false;
Producer<Event> event_producer_;
Consumer<Event> event_consumer_;
std::string set_cursor_position;
std::string reset_cursor_position;
std::atomic<bool>quit_ = false;
};
} // namespace ftxui