@@ -62,8 +62,8 @@ ftxui::Element orderbookToTable(OrderBook &ob) {
6262 // ─────────── Data Rows ───────────
6363 const std::vector<BidAsk> x = ob.toVector ();
6464 constexpr size_t max_rows = 15 ;
65- const int rowCount = std::min (x.size (), max_rows);
66- for (int i = 0 ; i < rowCount; ++i) {
65+ const size_t rowCount = std::min (x.size (), max_rows);
66+ for (size_t i = 0 ; i < rowCount; ++i) {
6767 ftxui::Elements cells;
6868 cells.push_back (ftxui::text (Pad (x[i].bid_sz , column_width)));
6969 cells.push_back (ftxui::text (Pad (x[i].bid_px , column_width)));
@@ -122,15 +122,18 @@ void TableApp::pollQueue(const std::stop_token &stoken) {
122122 // / Performs an adaptive backoff by spinning then sleeping, increasing sleep
123123 // / time exponentially. Yield 10x times, followed by a 2x sleep capped at
124124 // / 1ms
125+ constexpr int INITIAL_SLEEP_US = 10 ;
125126 int spinCount = 0 ;
126- int sleepTimeUs = 10 ;
127+ int sleepTimeUs = INITIAL_SLEEP_US ;
127128 auto adaptiveBackoff = [&spinCount, &sleepTimeUs]() {
128- if (spinCount < 10 ) {
129+ constexpr int MIN_SPINS = 10 ;
130+ constexpr int MAX_SLEEP_US = 1000 ;
131+ if (spinCount < MIN_SPINS) {
129132 ++spinCount;
130133 std::this_thread::yield ();
131134 } else {
132135 std::this_thread::sleep_for (std::chrono::microseconds (sleepTimeUs));
133- sleepTimeUs = std::min (sleepTimeUs * 2 , 1000 );
136+ sleepTimeUs = std::min (sleepTimeUs * 2 , MAX_SLEEP_US );
134137 }
135138 };
136139
@@ -161,7 +164,7 @@ void TableApp::pollQueue(const std::stop_token &stoken) {
161164
162165 // Reset backoff state
163166 spinCount = 0 ;
164- sleepTimeUs = 10 ;
167+ sleepTimeUs = INITIAL_SLEEP_US ;
165168 }
166169 spdlog::info (" closing worker thread..." );
167170 }
0 commit comments