MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / ServiceThreadPerform

Function ServiceThreadPerform

modules/piu/PC/piuService.c:374–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372
373#if mxAndroid
374int ServiceThreadPerform(int fd, int events, void* it)
375#elif mxLinux
376gboolean ServiceThreadPerform(void* it)
377#else
378void ServiceThreadPerform(void* it)
379#endif
380{
381 ServiceThread thread = it;
382 ServiceEvent event;
383 //fprintf(stderr, "ServiceThreadPerform thread %p\n", thread);
384#if mxAndroid
385 txByte msg;
386 read(fd, &msg, sizeof(msg));
387 pthread_mutex_lock(&(thread->mutex));
388#elif mxLinux
389 g_mutex_lock(&(thread->mutex));
390#elif mxWindows
391 EnterCriticalSection(&(thread->lock));
392#else
393 pthread_mutex_lock(&(thread->mutex));
394#endif
395 event = thread->firstEvent;
396 thread->firstEvent = NULL;
397 thread->lastEvent = NULL;
398#if mxLinux
399 g_mutex_unlock(&(thread->mutex));
400#elif mxWindows
401 LeaveCriticalSection(&(thread->lock));
402#else
403 pthread_mutex_unlock(&(thread->mutex));
404#endif
405 while (event) {
406 ServiceEvent nextEvent = event->nextEvent;
407 ServiceCallback callback = event->callback;
408 event->nextEvent = NULL;
409 event->callback = NULL;
410 (*callback)(event);
411 event = nextEvent;
412 }
413#if mxInstrument
414 fxSampleInstrumentation(thread->the, 0, NULL);
415#endif
416#if mxAndroid
417 return 1;
418#elif mxLinux
419 return G_SOURCE_REMOVE;
420#endif
421}
422
423void ServiceThreadSignal(ServiceThread client, ServiceThread server, ServiceEvent event)
424{

Callers

nothing calls this directly

Calls 2

fxSampleInstrumentationFunction · 0.85
readFunction · 0.50

Tested by

no test coverage detected