BVB Source Codes

CRYENGINE Show NetworkStallTicker.cpp Source code

Return Download CRYENGINE: download NetworkStallTicker.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #include "StdAfx.h"
  4. #include "GameContext.h"
  5. #include "NetworkStallTicker.h"
  6.  
  7. //--------------------------------------------------------------------------
  8. // special ticker thread to run during load and unload of levels
  9. #ifdef USE_NETWORK_STALL_TICKER_THREAD
  10.  
  11.         #define WARN_ABOUT_LONG_STALLS_IN_TICKER (0)  // Log warnings about long stalls in the loading ticker (which would likely cause disconnects)
  12.  
  13. void CNetworkStallTickerThread::ThreadEntry()
  14. {
  15.         bool gotLockLastTime = true;
  16.  
  17.         #if WARN_ABOUT_LONG_STALLS_IN_TICKER
  18.         CTimeValue started = gEnv->pTimer->GetAsyncTime();
  19.         CTimeValue ended;
  20.         #endif
  21.  
  22.         while (m_threadRunning)
  23.         {
  24.                 if (gEnv->pNetwork)
  25.                 {
  26.                         gEnv->pNetwork->SyncWithGame(eNGS_SleepNetwork);
  27.                 }
  28.  
  29.                 if (gotLockLastTime)
  30.                 {
  31.                         CrySleep(33);
  32.                 }
  33.                 else
  34.                 {
  35.                         CrySleep(1);
  36.                 }
  37.  
  38.                 {
  39.                         if (gEnv->pNetwork)
  40.                         {
  41.                                 SCOPED_TICKER_TRY_LOCK;
  42.                                 if (SCOPED_TICKER_HAS_LOCK)
  43.                                 {
  44.                                         gEnv->pNetwork->SyncWithGame(eNGS_MinimalUpdateForLoading);
  45.                                         gotLockLastTime = true;
  46.                                 }
  47.                                 else
  48.                                 {
  49.                                         gotLockLastTime = false;
  50.                                 }
  51.                                 gEnv->pNetwork->SyncWithGame(eNGS_WakeNetwork);
  52.                         }
  53.  
  54.         #if WARN_ABOUT_LONG_STALLS_IN_TICKER
  55.                         ended = gEnv->pTimer->GetAsyncTime();
  56.                         if (ended.GetDifferenceInSeconds(started) > 1.f)
  57.                         {
  58.                                 CryLogAlways("THREADEDLOADING:: No update for %f", ended.GetDifferenceInSeconds(started));
  59.                         }
  60.                         started = ended;
  61.         #endif
  62.                 }
  63.         }
  64. }
  65.  
  66. #endif // #ifdef USE_NETWORK_STALL_TICKER_THREAD
  67. //--------------------------------------------------------------------------
  68.  
downloadNetworkStallTicker.cpp Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top