BetaTrader
A HFT Eco-System
Loading...
Searching...
No Matches
trading_core::WorkerThread Class Reference

Background worker which processes batched commands. More...

#include <WorkerThread.h>

Collaboration diagram for trading_core::WorkerThread:
Collaboration graph

Public Member Functions

 WorkerThread (rigtorp::SPSCQueue< std::unique_ptr< Command > > &commandQueue, OrderManager &orderManager, OrderBook &orderBook, Matcher &matcher, RiskManager &riskManager, data::OrderRepository &orderRepository, TradeIDGenerator *tradeIDGenerator, data::DatabaseWorker *databaseWorker)
 
 ~WorkerThread ()
 
void processNextCommand ()
 
void start ()
 
void stop ()
 

Private Member Functions

void processBatch (std::unique_ptr< Command > *commands, size_t count)
 
void processCancelOrder (const CancelOrder &cmd) const
 
void processModifyOrder (const ModifyOrder &cmd) const
 
void processNewOrder (NewOrder &cmd) const
 
void runLoop (std::stop_token stopToken)
 

Private Attributes

std::unique_ptr< CommandmCommandBatch [BATCH_SIZE]
 
rigtorp::SPSCQueue< std::unique_ptr< Command > > & mCommandQueue
 
data::DatabaseWorkermDatabaseWorker
 
MatchermMatcher
 
OrderBookmOrderBook
 
OrderManagermOrderManager
 
data::OrderRepositorymOrderRepository
 
RiskManagermRiskManager
 
std::jthread mThread
 
TradeIDGeneratormTradeIDGenerator
 

Static Private Attributes

static constexpr size_t BATCH_SIZE = 64
 

Detailed Description

Background worker which processes batched commands.

Constructor & Destructor Documentation

◆ WorkerThread()

trading_core::WorkerThread::WorkerThread ( rigtorp::SPSCQueue< std::unique_ptr< Command > > &  commandQueue,
OrderManager orderManager,
OrderBook orderBook,
Matcher matcher,
RiskManager riskManager,
data::OrderRepository orderRepository,
TradeIDGenerator tradeIDGenerator,
data::DatabaseWorker databaseWorker 
)

◆ ~WorkerThread()

trading_core::WorkerThread::~WorkerThread ( )
Here is the call graph for this function:

Member Function Documentation

◆ processBatch()

void trading_core::WorkerThread::processBatch ( std::unique_ptr< Command > *  commands,
size_t  count 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ processCancelOrder()

void trading_core::WorkerThread::processCancelOrder ( const CancelOrder cmd) const
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ processModifyOrder()

void trading_core::WorkerThread::processModifyOrder ( const ModifyOrder cmd) const
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ processNewOrder()

void trading_core::WorkerThread::processNewOrder ( NewOrder cmd) const
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ processNextCommand()

void trading_core::WorkerThread::processNextCommand ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ runLoop()

void trading_core::WorkerThread::runLoop ( std::stop_token  stopToken)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start()

void trading_core::WorkerThread::start ( )
Here is the call graph for this function:

◆ stop()

void trading_core::WorkerThread::stop ( )
Here is the caller graph for this function:

Member Data Documentation

◆ BATCH_SIZE

constexpr size_t trading_core::WorkerThread::BATCH_SIZE = 64
staticconstexprprivate

◆ mCommandBatch

std::unique_ptr<Command> trading_core::WorkerThread::mCommandBatch[BATCH_SIZE]
private

◆ mCommandQueue

rigtorp::SPSCQueue<std::unique_ptr<Command> >& trading_core::WorkerThread::mCommandQueue
private

◆ mDatabaseWorker

data::DatabaseWorker* trading_core::WorkerThread::mDatabaseWorker
private

◆ mMatcher

Matcher& trading_core::WorkerThread::mMatcher
private

◆ mOrderBook

OrderBook& trading_core::WorkerThread::mOrderBook
private

◆ mOrderManager

OrderManager& trading_core::WorkerThread::mOrderManager
private

◆ mOrderRepository

data::OrderRepository& trading_core::WorkerThread::mOrderRepository
private

◆ mRiskManager

RiskManager& trading_core::WorkerThread::mRiskManager
private

◆ mThread

std::jthread trading_core::WorkerThread::mThread
private

◆ mTradeIDGenerator

TradeIDGenerator* trading_core::WorkerThread::mTradeIDGenerator
private

The documentation for this class was generated from the following files: