21#include "rigtorp/SPSCQueue.h"
33 WorkerThread(rigtorp::SPSCQueue<std::unique_ptr<Command>>& commandQueue,
50 void runLoop(std::stop_token stopToken);
58 void processBatch(std::unique_ptr<Command>* commands,
size_t count);
Repository interface for persisting and loading orders.
Risk management hooks for pre-checks and post-trade updates.
Executes database tasks asynchronously.
Definition DatabaseWorker.h:22
Persists and retrieves common::Order objects.
Definition OrderRepository.h:20
A command to cancel an existing order in the trading engine.
Definition CancelOrder.h:18
The matching engine that pairs buy and sell orders.
Definition Matcher.h:23
A command to modify an existing order in the trading engine.
Definition ModifyOrder.h:20
A command to submit a new order to the trading engine.
Definition NewOrder.h:19
Represents the order book for a single financial instrument.
Definition OrderBook.h:22
Manages all the orders in the system.
Definition OrderManager.h:19
Performs risk validation and updates after trade execution.
Definition RiskManager.h:21
A thread-safe, database-aware generator for unique trade IDs.
Definition TradeIDGenerator.h:15
Background worker which processes batched commands.
Definition WorkerThread.h:31
void runLoop(std::stop_token stopToken)
Definition WorkerThread.cpp:41
void processNewOrder(NewOrder &cmd) const
Definition WorkerThread.cpp:93
OrderManager & mOrderManager
Definition WorkerThread.h:63
void start()
Definition WorkerThread.cpp:27
void processModifyOrder(const ModifyOrder &cmd) const
Definition WorkerThread.cpp:148
TradeIDGenerator * mTradeIDGenerator
Definition WorkerThread.h:69
void processNextCommand()
Definition WorkerThread.cpp:50
std::jthread mThread
Definition WorkerThread.h:60
void stop()
Definition WorkerThread.cpp:34
rigtorp::SPSCQueue< std::unique_ptr< Command > > & mCommandQueue
Definition WorkerThread.h:61
void processBatch(std::unique_ptr< Command > *commands, size_t count)
Definition WorkerThread.cpp:70
std::unique_ptr< Command > mCommandBatch[BATCH_SIZE]
Definition WorkerThread.h:73
RiskManager & mRiskManager
Definition WorkerThread.h:66
void processCancelOrder(const CancelOrder &cmd) const
Definition WorkerThread.cpp:126
OrderBook & mOrderBook
Definition WorkerThread.h:64
static constexpr size_t BATCH_SIZE
Definition WorkerThread.h:72
data::OrderRepository & mOrderRepository
Definition WorkerThread.h:67
~WorkerThread()
Definition WorkerThread.cpp:22
Matcher & mMatcher
Definition WorkerThread.h:65
data::DatabaseWorker * mDatabaseWorker
Definition WorkerThread.h:70
Definition CancelOrder.h:10