engine(masterserver): Add sequence for requesting server info, implement StopRefresh and use it on timeout

This commit is contained in:
nillerusr
2023-02-10 22:45:36 +03:00
parent a08b6ae7bf
commit 12716fd07f
6 changed files with 171 additions and 67 deletions
+1
View File
@@ -89,6 +89,7 @@ class IServersInfo
public:
virtual void RequestInternetServerList( const char *gamedir, IServerListResponse *response ) = 0;
virtual void RequestLANServerList( const char *gamedir, IServerListResponse *response ) = 0;
virtual void StopRefresh() = 0;
//virtual HServerQuery PingServer( uint32 unIP, uint16 usPort, ISteamMatchmakingPingResponse *pRequestServersResponse ) = 0;
//virtual HServerQuery PlayerDetails( uint32 unIP, uint16 usPort, ISteamMatchmakingPlayersResponse *pRequestServersResponse ) = 0;
+5 -39
View File
@@ -52,12 +52,6 @@
#pragma once
#pragma warning(push)
#pragma warning(disable:4251)
extern "C"
{
void __declspec(dllimport) __stdcall Sleep( unsigned long );
}
#endif
#ifdef COMPILER_MSVC64
@@ -200,6 +194,8 @@ PLATFORM_INTERFACE bool ReleaseThreadHandle( ThreadHandle_t );
//-----------------------------------------------------------------------------
PLATFORM_INTERFACE void ThreadSleep(unsigned duration = 0);
PLATFORM_INTERFACE void ThreadNanoSleep(unsigned ns);
PLATFORM_INTERFACE ThreadId_t ThreadGetCurrentId();
PLATFORM_INTERFACE ThreadHandle_t ThreadGetCurrentHandle();
PLATFORM_INTERFACE int ThreadGetPriority( ThreadHandle_t hThread = NULL );
@@ -233,10 +229,10 @@ inline void ThreadPause()
{
#if defined( COMPILER_PS3 )
__db16cyc();
#elif defined( COMPILER_GCC ) && (defined( __i386__ ) || defined( __x86_64__ ))
__asm __volatile( "pause" );
#elif defined( POSIX )
#elif defined(__arm__) || defined(__aarch64__)
sched_yield();
#elif defined( COMPILER_GCC )
__asm __volatile( "pause" );
#elif defined ( COMPILER_MSVC64 )
_mm_pause();
#elif defined( COMPILER_MSVC32 )
@@ -251,36 +247,6 @@ inline void ThreadPause()
#endif
}
inline void ThreadSleep(unsigned nMilliseconds = 0)
{
if( nMilliseconds == 0 )
{
ThreadPause();
return;
}
#ifdef _WIN32
#ifdef _WIN32_PC
static bool bInitialized = false;
if ( !bInitialized )
{
bInitialized = true;
// Set the timer resolution to 1 ms (default is 10.0, 15.6, 2.5, 1.0 or
// some other value depending on hardware and software) so that we can
// use Sleep( 1 ) to avoid wasting CPU time without missing our frame
// rate.
timeBeginPeriod( 1 );
}
#endif
Sleep( nMilliseconds );
#elif PS3
sys_timer_usleep( nMilliseconds * 1000 );
#elif defined(POSIX)
usleep( nMilliseconds * 1000 );
#endif
}
PLATFORM_INTERFACE bool ThreadJoin( ThreadHandle_t, unsigned timeout = TT_INFINITE );
PLATFORM_INTERFACE void ThreadSetDebugName( ThreadHandle_t hThread, const char *pszName );
+11 -5
View File
@@ -11,15 +11,21 @@ namespace memutils
template<typename T>
inline void copy( T *dest, const T *src, size_t n )
{
for(; n; n--)
*(dest++) = *(src++);
do
{
--n;
*(dest+n) = *(src+n);
} while( n );
}
template<typename T>
inline void set( T *dest, const T& value, size_t n )
inline void set( T *dest, T value, size_t n )
{
for(; n; n--)
*(dest++) = value;
do
{
--n;
*(dest+n) = value;
} while( n );
}
}