Skip to content

Commit

Permalink
feat: add task manager and queue message tasks in agent
Browse files Browse the repository at this point in the history
  • Loading branch information
jr0me committed Jul 17, 2024
1 parent 6e30bf7 commit 960cbb8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/agent/include/agent.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
#pragma once

#include <task_manager.hpp>

#include <queue>
#include <string>

class Agent
{
public:
Agent();
~Agent();

private:
std::queue<std::string> m_messageQueue;

TaskManager m_taskManager;
};
19 changes: 17 additions & 2 deletions src/agent/src/agent.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
#include "agent.hpp"

Agent::Agent() {}
#include <message_task.hpp>

Agent::~Agent() {}
#include <chrono>
#include <thread>

Agent::Agent()
{
m_taskManager.start(std::thread::hardware_concurrency());
m_taskManager.enqueueTask(StatefulMessageProcessingTask(m_messageQueue));
m_taskManager.enqueueTask(StatelessMessageProcessingTask(m_messageQueue));
}

Agent::~Agent()
{
// Sleep for 2 seconds
std::this_thread::sleep_for(std::chrono::seconds(2));
m_taskManager.stop();
}

0 comments on commit 960cbb8

Please sign in to comment.