MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / UDPThreadFunc

Function UDPThreadFunc

examples/SharedMemory/PhysicsClientUDP.cpp:304–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302};
303
304void UDPThreadFunc(void* userPtr, void* lsMemory)
305{
306 printf("UDPThreadFunc thread started\n");
307 // UDPThreadLocalStorage* localStorage = (UDPThreadLocalStorage*)lsMemory;
308
309 UdpNetworkedInternalData* args = (UdpNetworkedInternalData*)userPtr;
310 // int workLeft = true;
311 b3Clock clock;
312 clock.reset();
313 bool init = true;
314 if (init)
315 {
316 args->m_cs->lock();
317 args->m_cs->setSharedParam(0, eUDPIsInitialized);
318 args->m_cs->unlock();
319
320 double deltaTimeInSeconds = 0;
321
322 do
323 {
324 b3Clock::usleep(0);
325
326 deltaTimeInSeconds += double(clock.getTimeMicroseconds()) / 1000000.;
327
328 {
329 clock.reset();
330 deltaTimeInSeconds = 0.f;
331 switch (args->m_cs->getSharedParam(1))
332 {
333 case eUDP_ConnectRequest:
334 {
335 bool connected = args->connectUDP();
336 if (connected)
337 {
338 args->m_cs->setSharedParam(1, eUDP_Connected);
339 }
340 else
341 {
342 args->m_cs->setSharedParam(1, eUDP_ConnectionFailed);
343 }
344 break;
345 }
346 default:
347 {
348 }
349 };
350
351 if (args->m_isConnected)
352 {
353 args->m_cs->lock();
354 bool hasCommand = args->m_hasCommand;
355 args->m_cs->unlock();
356
357 if (hasCommand)
358 {
359 int sz = 0;
360 ENetPacket* packet = 0;
361

Callers

nothing calls this directly

Calls 10

enet_packet_createFunction · 0.85
enet_peer_sendFunction · 0.85
connectUDPMethod · 0.80
resetMethod · 0.45
lockMethod · 0.45
setSharedParamMethod · 0.45
unlockMethod · 0.45
getTimeMicrosecondsMethod · 0.45
getSharedParamMethod · 0.45
checkDataMethod · 0.45

Tested by

no test coverage detected