@@ -23,7 +23,7 @@ ControllerWithScheduler::ControllerWithScheduler(Logger& logger)
2323 make_resource_list ()
2424 )
2525 , m_logger(logger)
26- , m_logging_suppress(0 )
26+ // , m_logging_suppress(0)
2727{}
2828
2929
@@ -32,7 +32,7 @@ void ControllerWithScheduler::issue_barrier(const Cancellable* cancellable){
3232 std::lock_guard<std::mutex> lg0 (m_issue_lock);
3333 std::lock_guard<std::mutex> lg1 (m_state_lock);
3434 this ->issue_wait_for_all (cancellable);
35- if (m_logging_suppress. load (std::memory_order_relaxed) == 0 ){
35+ if (m_logging_throttler ){
3636 m_logger.log (" issue_barrier()" , COLOR_DARKGREEN);
3737 }
3838}
@@ -43,7 +43,7 @@ void ControllerWithScheduler::issue_nop(const Cancellable* cancellable, Millisec
4343 cancellable->throw_if_cancelled ();
4444 }
4545 this ->SuperscalarScheduler ::issue_nop (cancellable, WallDuration (duration));
46- if (m_logging_suppress. load (std::memory_order_relaxed) == 0 ){
46+ if (m_logging_throttler ){
4747 m_logger.log (
4848 " issue_nop(): duration = " + std::to_string (duration.count ()) + " ms" ,
4949 COLOR_DARKGREEN
@@ -78,7 +78,7 @@ void ControllerWithScheduler::issue_buttons(
7878 }
7979 this ->SuperscalarScheduler ::issue_nop (cancellable, delay);
8080
81- if (m_logging_suppress. load (std::memory_order_relaxed) == 0 ){
81+ if (m_logging_throttler ){
8282 m_logger.log (
8383 " issue_buttons(): " + button_to_string (button) +
8484 " , delay = " + std::to_string (delay.count ()) + " ms" +
@@ -103,7 +103,7 @@ void ControllerWithScheduler::issue_dpad(
103103 m_dpad.position = position;
104104 this ->issue_to_resource (cancellable, m_dpad, delay, hold, cooldown);
105105
106- if (m_logging_suppress. load (std::memory_order_relaxed) == 0 ){
106+ if (m_logging_throttler ){
107107 m_logger.log (
108108 " issue_dpad(): " + dpad_to_string (position) +
109109 " , delay = " + std::to_string (delay.count ()) + " ms" +
@@ -130,7 +130,7 @@ void ControllerWithScheduler::issue_left_joystick(
130130 m_left_joystick.y = y;
131131 this ->issue_to_resource (cancellable, m_left_joystick, delay, hold, cooldown);
132132
133- if (m_logging_suppress. load (std::memory_order_relaxed) == 0 ){
133+ if (m_logging_throttler ){
134134 m_logger.log (
135135 " issue_left_joystick(): (" + std::to_string (x) + " ," + std::to_string (y) + " )" +
136136 " , delay = " + std::to_string (delay.count ()) + " ms" +
@@ -156,7 +156,7 @@ void ControllerWithScheduler::issue_right_joystick(
156156 m_right_joystick.y = y;
157157 this ->issue_to_resource (cancellable, m_right_joystick, delay, hold, cooldown);
158158
159- if (m_logging_suppress. load (std::memory_order_relaxed) == 0 ){
159+ if (m_logging_throttler ){
160160 m_logger.log (
161161 " issue_right_joystick(): (" + std::to_string (x) + " ," + std::to_string (y) + " )" +
162162 " , delay = " + std::to_string (delay.count ()) + " ms" +
@@ -218,7 +218,7 @@ void ControllerWithScheduler::issue_full_controller_state(
218218 hold, hold, WallDuration::zero ()
219219 );
220220
221- if (m_logging_suppress. load (std::memory_order_relaxed) == 0 ){
221+ if (m_logging_throttler ){
222222 m_logger.log (
223223 " issue_controller_state(): (" + button_to_string (button) +
224224 " ), dpad(" + dpad_to_string (position) +
@@ -238,15 +238,15 @@ void ControllerWithScheduler::issue_mash_button(
238238 if (cancellable){
239239 cancellable->throw_if_cancelled ();
240240 }
241- LoggingSuppressScope scope (m_logging_suppress );
241+ ThrottleScope scope (m_logging_throttler );
242242 bool log = true ;
243243 while (duration > Milliseconds::zero ()){
244244 issue_buttons (cancellable, button, 8 *8ms, 5 *8ms, 3 *8ms);
245245
246246 // We never log before the first issue to avoid delaying the critical path.
247247 // But we do want to log before the mash spam. So we log after the first
248248 // issue, but before the second.
249- if (log && m_logging_suppress. load (std::memory_order_relaxed) == 1 ){
249+ if (log && scope ){
250250 m_logger.log (
251251 " issue_mash_button(): " + button_to_string (button) +
252252 " , duration = " + std::to_string (duration.count ()) + " ms" ,
@@ -267,7 +267,7 @@ void ControllerWithScheduler::issue_mash_button(
267267 if (cancellable){
268268 cancellable->throw_if_cancelled ();
269269 }
270- LoggingSuppressScope scope (m_logging_suppress );
270+ ThrottleScope scope (m_logging_throttler );
271271 bool log = true ;
272272 while (duration > Milliseconds::zero ()){
273273 issue_buttons (cancellable, button0, Milliseconds (4 *8 ), 5 *8ms, 3 *8ms);
@@ -276,7 +276,7 @@ void ControllerWithScheduler::issue_mash_button(
276276 // We never log before the first issue to avoid delaying the critical path.
277277 // But we do want to log before the mash spam. So we log after the first
278278 // issue, but before the second.
279- if (log && m_logging_suppress. load (std::memory_order_relaxed) == 1 ){
279+ if (log && scope ){
280280 m_logger.log (
281281 " issue_mash_button(): (" + button_to_string (button0) +
282282 " ), (" + button_to_string (button1) +
@@ -296,7 +296,7 @@ void ControllerWithScheduler::issue_mash_AZs(
296296 if (cancellable){
297297 cancellable->throw_if_cancelled ();
298298 }
299- LoggingSuppressScope scope (m_logging_suppress );
299+ ThrottleScope scope (m_logging_throttler );
300300 bool log = true ;
301301 while (true ){
302302 if (duration <= Milliseconds::zero ()){
@@ -307,7 +307,7 @@ void ControllerWithScheduler::issue_mash_AZs(
307307 // We never log before the first issue to avoid delaying the critical path.
308308 // But we do want to log before the mash spam. So we log after the first
309309 // issue, but before the second.
310- if (log && m_logging_suppress. load (std::memory_order_relaxed) == 1 ){
310+ if (log && scope ){
311311 m_logger.log (
312312 " issue_mash_AZs(): duration = " + std::to_string (duration.count ()) + " ms" ,
313313 COLOR_DARKGREEN
@@ -338,7 +338,7 @@ void ControllerWithScheduler::issue_system_scroll(
338338 cancellable->throw_if_cancelled ();
339339 }
340340
341- LoggingSuppressScope scope (m_logging_suppress );
341+ ThrottleScope scope (m_logging_throttler );
342342
343343 WallClock dpad = m_dpad.free_time ();
344344 WallClock left_joystick = m_left_joystick.free_time ();
@@ -403,7 +403,7 @@ void ControllerWithScheduler::issue_system_scroll(
403403 }
404404 }while (false );
405405
406- if (m_logging_suppress. load (std::memory_order_relaxed) == 1 ){
406+ if (scope ){
407407 m_logger.log (
408408 " issue_system_scroll(): " + dpad_to_string (direction) +
409409 " , delay = " + std::to_string (delay.count ()) + " ms" +
0 commit comments