From 45c98cc535508611e2fdcf7fb0b46a82c338df60 Mon Sep 17 00:00:00 2001 From: Fletcher Dunn Date: Wed, 6 May 2026 19:58:29 -0700 Subject: [PATCH] Move IThinker::EnsureMinThinkTime out of line Having it inline was a small speedup, but really not worth the ugly macros needed to deal with tsan. (In tsan we need to make sure it isn't expanded inline in order for the supression to work properly.) --- .../steamnetworkingsockets_thinker.cpp | 7 +++++++ .../steamnetworkingsockets_thinker.h | 7 +------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/steamnetworkingsockets/steamnetworkingsockets_thinker.cpp b/src/steamnetworkingsockets/steamnetworkingsockets_thinker.cpp index 2874f41..671979f 100644 --- a/src/steamnetworkingsockets/steamnetworkingsockets_thinker.cpp +++ b/src/steamnetworkingsockets/steamnetworkingsockets_thinker.cpp @@ -95,6 +95,13 @@ ATTR_NO_SANITIZE_THREAD void IThinker::SetNextThinkTime( SteamNetworkingMicrosec s_mutexThinkerTable.unlock(); } +ATTR_NO_SANITIZE_THREAD void IThinker::EnsureMinThinkTime( SteamNetworkingMicroseconds usecTargetThinkTime ) +{ + // Lockless fast-path read -- see SetNextThinkTime for explanation of the intentional race. + if ( usecTargetThinkTime < m_usecNextThinkTime ) + InternalEnsureMinThinkTime( usecTargetThinkTime ); +} + void IThinker::InternalSetNextThinkTime( SteamNetworkingMicroseconds usecTargetThinkTime ) { diff --git a/src/steamnetworkingsockets/steamnetworkingsockets_thinker.h b/src/steamnetworkingsockets/steamnetworkingsockets_thinker.h index affc749..4cc628e 100644 --- a/src/steamnetworkingsockets/steamnetworkingsockets_thinker.h +++ b/src/steamnetworkingsockets/steamnetworkingsockets_thinker.h @@ -31,12 +31,7 @@ public: /// Adjust schedule time to the earlier of the current schedule time, /// or the given time. - ATTR_NO_SANITIZE_THREAD inline void EnsureMinThinkTime( SteamNetworkingMicroseconds usecTargetThinkTime ) - { - // Lockless fast-path read -- see SetNextThinkTime for explanation of the intentional race. - if ( usecTargetThinkTime < m_usecNextThinkTime ) - InternalEnsureMinThinkTime( usecTargetThinkTime ); - } + void EnsureMinThinkTime( SteamNetworkingMicroseconds usecTargetThinkTime ); /// Clear the next think time. You won't get a callback. void ClearNextThinkTime() { SetNextThinkTime( k_nThinkTime_Never ); }