コード例 #1
0
ファイル: metis_Dispatcher.c プロジェクト: PARC/Metis
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));
}
コード例 #2
0
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);
}
コード例 #3
0
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);
}