1313#include < mutex>
1414#include < string>
1515#include < thread>
16+ #include < utility>
1617#include < vector>
1718
1819#include " ./../utils/Threading.h"
@@ -25,7 +26,9 @@ namespace UI {
2526
2627// Helper to pad or truncate a string to a fixed width
2728std::string Pad (const std::string &input, const size_t width) {
28- if (input.size () >= width) return input.substr (0 , width);
29+ if (input.size () >= width) {
30+ return input.substr (0 , width);
31+ }
2932
3033 std::string result = input;
3134 result.resize (width, ' ' );
@@ -91,7 +94,7 @@ TableApp::TableApp(
9194 workerTask_(std::move(task)) {
9295 // default behaviour
9396 if (!workerTask_) {
94- workerTask_ = ([this ](std::stop_token stoken) {
97+ workerTask_ = ([this ](const std::stop_token & stoken) {
9598 Utils::Threading::set_thread_name (" tradercppUI" );
9699 pollQueue (stoken);
97100 spdlog::info (" started polling queue on background thread" );
@@ -101,7 +104,7 @@ TableApp::TableApp(
101104
102105// main thread
103106void TableApp::start () {
104- // TODO: why does the order of these two items affect the rendered result?
107+ // TODO(mils) : why does the order of these two items affect the rendered result?
105108
106109 // start worker thread
107110 worker_ = std::jthread (workerTask_);
@@ -112,7 +115,7 @@ void TableApp::start() {
112115}
113116
114117// worker thread
115- void TableApp::pollQueue (std::stop_token stoken) {
118+ void TableApp::pollQueue (const std::stop_token & stoken) {
116119 try {
117120 // / Adaptive backoff strategy for spin+sleep polling
118121 // / Performs an adaptive backoff by spinning then sleeping, increasing sleep
@@ -135,7 +138,9 @@ void TableApp::pollQueue(std::stop_token stoken) {
135138 while (!stoken.stop_requested ()) {
136139 std::shared_ptr<const FIX44::Message> msg;
137140 while (!queue_.try_dequeue (msg)) {
138- if (stoken.stop_requested ()) return ;
141+ if (stoken.stop_requested ()) {
142+ return ;
143+ }
139144 adaptiveBackoff ();
140145 }
141146
@@ -159,7 +164,7 @@ void TableApp::pollQueue(std::stop_token stoken) {
159164 }
160165 spdlog::info (" closing worker thread..." );
161166 }
162- // TODO: log error
167+ // TODO(mils) : log error
163168 catch (const std::exception &e) {
164169 spdlog::error (" error in ui worker thread, error [{}]" , e.what ());
165170 thread_exception = std::current_exception ();
0 commit comments