# My Project: include/Algo.hh Source File

Loading...
Searching...
No Matches
Algo.hh
Go to the documentation of this file.
#pragma once
// C++ Includes
#include <memory>
#include <queue>
#include <atomic>
#include <thread>
#include <future>
// FastInAHurry includes
#include "Publisher.hh"
#include "utils/ThreadSafeQueue.hh"
#include "utils/ThreadPool.hh"
class Algo {
public:
Algo();
void initialize();
void generate_orders();
void process();
void send(trading::Order&);
bool initialized();
void stop();
private:
std::queue<trading::Order> _orders;
std::atomic<bool> _initialized{false};
std::atomic<bool> _running{false};
std::shared_ptr<Publisher> _pub;
utils::ThreadSafeQueue<trading::Order> _order_queue;
utils::ThreadPool _thread_pool;
std::mutex _send_mutex;
std::jthread _reader_thread;
std::vector<std::jthread> _worker_threads;
std::vector<std::future<bool>> _futures;
};
Publisher.hh
ThreadPool.hh
ThreadSafeQueue.hh
Algo::stop
void stop()
Definition Algo.cc:23
Algo::_running
std::atomic< bool > _running
Definition Algo.hh:30
Algo::_send_mutex
std::mutex _send_mutex
Definition Algo.hh:36
Algo::_futures
std::vector< std::future< bool > > _futures
Definition Algo.hh:39
Algo::_initialized
std::atomic< bool > _initialized
Definition Algo.hh:29
Algo::initialized
bool initialized()
Definition Algo.cc:43
Algo::_reader_thread
std::jthread _reader_thread
Definition Algo.hh:37
Algo::_orders
std::queue< trading::Order > _orders
Definition Algo.hh:28
Algo::process
void process()
Definition Algo.cc:47
Algo::Algo
Algo()
Definition Algo.cc:11
Algo::generate_orders
void generate_orders()
Definition Algo.cc:39
Algo::_order_queue
utils::ThreadSafeQueue< trading::Order > _order_queue
Definition Algo.hh:33
Algo::send
void send(trading::Order &)
Definition Algo.cc:106
Algo::_worker_threads
std::vector< std::jthread > _worker_threads
Definition Algo.hh:38
Algo::initialize
void initialize()
Definition Algo.cc:15
Algo::_thread_pool
utils::ThreadPool _thread_pool
Definition Algo.hh:34
Algo::_pub
std::shared_ptr< Publisher > _pub
Definition Algo.hh:31
utils::ThreadPool
Definition ThreadPool.hh:12
utils::ThreadSafeQueue
Definition ThreadSafeQueue.hh:11