MCPcopy Create free account
hub / github.com/diasurgical/devilution / dthread_handler

Function dthread_handler

Source/dthread.cpp:76–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76unsigned int dthread_handler(void *)
77{
78 const char *error_buf;
79 TMegaPkt *pkt;
80 DWORD dwMilliseconds;
81
82 while (dthread_running) {
83 if (!sgpInfoHead && WaitForEvent(sghWorkToDoEvent) == -1) {
84 error_buf = TraceLastError();
85 app_fatal("dthread4:\n%s", error_buf);
86 }
87
88 sgMemCrit.Enter();
89 pkt = sgpInfoHead;
90 if (sgpInfoHead)
91 sgpInfoHead = sgpInfoHead->pNext;
92 else
93 ResetEvent(sghWorkToDoEvent);
94 sgMemCrit.Leave();
95
96 if (pkt) {
97 if (pkt->dwSpaceLeft != MAX_PLRS)
98 multi_send_zero_packet(pkt->dwSpaceLeft, pkt->data[0], &pkt->data[8], *(DWORD *)&pkt->data[4]);
99
100 dwMilliseconds = 1000 * *(DWORD *)&pkt->data[4] / gdwDeltaBytesSec;
101 if (dwMilliseconds >= 1)
102 dwMilliseconds = 1;
103
104 mem_free_dbg(pkt);
105
106 if (dwMilliseconds)
107 SDL_Delay(dwMilliseconds);
108 }
109 }
110
111 return 0;
112}
113
114void dthread_cleanup()
115{

Callers

nothing calls this directly

Calls 7

WaitForEventFunction · 0.85
app_fatalFunction · 0.85
ResetEventFunction · 0.85
multi_send_zero_packetFunction · 0.85
mem_free_dbgFunction · 0.85
EnterMethod · 0.80
LeaveMethod · 0.80

Tested by

no test coverage detected