StaticThreadPipeline

This commit is contained in:
2025-08-26 15:13:16 -04:00
parent 0b63e24b98
commit 6dbf29d1e1
4 changed files with 244 additions and 321 deletions

View File

@@ -18,10 +18,12 @@ struct Message {
struct EchoHandler : public ConnectionHandler {
private:
ThreadPipeline<Message> &pipeline;
StaticThreadPipeline<Message, WaitStrategy::WaitIfStageEmpty, 1> &pipeline;
public:
explicit EchoHandler(ThreadPipeline<Message> &pipeline)
explicit EchoHandler(
StaticThreadPipeline<Message, WaitStrategy::WaitIfStageEmpty, 1>
&pipeline)
: pipeline(pipeline) {}
void on_data_arrived(std::string_view data,
@@ -42,11 +44,11 @@ TEST_CASE(
config.server.io_threads = 1;
config.server.epoll_instances = 1;
ThreadPipeline<Message> pipeline{10, {1}};
StaticThreadPipeline<Message, WaitStrategy::WaitIfStageEmpty, 1> pipeline{10};
EchoHandler handler{pipeline};
auto echoThread = std::thread{[&]() {
for (;;) {
auto guard = pipeline.acquire(0, 0);
auto guard = pipeline.acquire<0, 0>();
for (auto &message : guard.batch) {
bool done = message.done;
if (done) {