MCPcopy Create free account
hub / github.com/crossuo/crossuo / THREADCALL CThreadLoopSynchronizedDelay

Function THREADCALL CThreadLoopSynchronizedDelay

src/Wisp/WispThread.cpp:53–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51};
52
53thread_int THREADCALL CThreadLoopSynchronizedDelay(void *arg)
54{
55 CThread *parent = (CThread *)arg;
56
57 while (parent->IsActive())
58 {
59 while (parent->Paused())
60 {
61 SDL_Delay(1);
62 }
63
64#if THREAD_USE_CLOCK == 1
65 uint32_t nowTime = clock();
66#else
67 uint32_t nowTime = SDL_GetTicks();
68#endif
69
70 parent->OnExecute(nowTime);
71 if (!parent->Cycled())
72 {
73 break;
74 }
75
76#if THREAD_USE_CLOCK == 1
77 int delay = (int)((nowTime + parent->Delay()) - clock());
78#else
79 int delay = (int)((nowTime + parent->Delay()) - SDL_GetTicks());
80#endif
81
82 SDL_Delay(delay > 0 ? delay : 1);
83 }
84
85 parent->OnDestroy();
86 delete parent;
87
88 return 0;
89};
90
91CThread::CThread()
92{

Callers

nothing calls this directly

Calls 8

PausedMethod · 0.80
CycledMethod · 0.80
DelayMethod · 0.80
SDL_DelayFunction · 0.50
SDL_GetTicksFunction · 0.50
IsActiveMethod · 0.45
OnExecuteMethod · 0.45
OnDestroyMethod · 0.45

Tested by

no test coverage detected