void metisDispatcher_StartSignalEvent(MetisDispatcher *dispatcher, PARCEventSignal *event) { assertNotNull(dispatcher, "Parameter dispatcher must be non-null"); assertNotNull(event, "Parameter event must be non-null"); int failure = parcEventSignal_Start(event); assertFalse(failure < 0, "Error starting signal event %p: (%d) %s", (void *) event, errno, strerror(errno)); }
LONGBOW_TEST_CASE(Global, parc_EventSignal_Stop) { _test_event_called = 0; PARCEventScheduler *parcEventScheduler = parcEventScheduler_Create(); assertNotNull(parcEventScheduler, "parcEventScheduler_Create returned a null reference"); PARCEventSignal *parcEventSignal = parcEventSignal_Create(parcEventScheduler, SIGUSR1, PARCEventType_Signal | PARCEventType_Persist, _test_stop_event, &parcEventSignal); assertNotNull(parcEventSignal, "parcEventSignal_Create returned a null reference"); parcEventSignal_Start(parcEventSignal); kill(getpid(), SIGUSR1); parcEventScheduler_Start(parcEventScheduler, PARCEventSchedulerDispatchType_Blocking); assertTrue(_test_event_called == 1, "Event never called."); parcEventSignal_Destroy(&parcEventSignal); parcEventScheduler_Destroy(&parcEventScheduler); }
LONGBOW_TEST_CASE(Global, parc_EventSignal_Start_Stop) { PARCEventScheduler *parcEventScheduler = parcEventScheduler_Create(); assertNotNull(parcEventScheduler, "parcEventScheduler_Create returned a null reference"); PARCEventSignal *parcEventSignal = parcEventSignal_Create(parcEventScheduler, SIGUSR1, PARCEventType_Signal | PARCEventType_Persist, _signal_event, &parcEventSignal); assertNotNull(parcEventSignal, "parcEventSignal_Create returned a null reference"); parcEventSignal_Start(parcEventSignal); pthread_t thread; pthread_create(&thread, NULL, _run_scheduler, parcEventScheduler); kill(getpid(), SIGUSR1); pthread_join(thread, NULL); assertTrue(_test_event_called == 1, "Event never called."); parcEventSignal_Destroy(&parcEventSignal); parcEventScheduler_Destroy(&parcEventScheduler); }