Exemple #1
0
int orte_wait_event(opal_event_t **event, orte_trigger_event_t *trig,
                    char *trigger_name,
                    void (*cbfunc)(int, short, void*))
{
    int p[2];
    
    if (create_socketpair(AF_UNIX, SOCK_STREAM, 0, p) == -1) {
        return ORTE_ERROR;
    }

    /* save the trigger name */
    trig->name = strdup(trigger_name);
    
    /* create the event */
    *event =  (opal_event_t *) malloc(sizeof(opal_event_t));
    
    /* setup the trigger and its associated lock */
    OBJ_CONSTRUCT(trig, orte_trigger_event_t);
    
    /* pass back the write end of the pipe */
    trig->channel = p[1];
    
    /* define the event to fire when someone writes to the pipe */
    opal_event_set(opal_event_base, *event, p[0], OPAL_EV_READ, cbfunc, NULL);
    
	/* Add it to the active events, without a timeout */
	opal_event_add(*event, NULL);

    /* all done */
    return ORTE_SUCCESS;
}
static int create_system_server (void)
{
    pid_t pid;
    char c;

    create_socketpair ();

    if ((pid = fork ()) < 0)
        return (-1);

    if (pid == 0) {
        system_server ();
        exit (0);
    }

    close (server_fd);

    /*
     *  Wait for system_server setup to complete
     */
    read (client_fd, &c, 1);

    return (0);
}
Exemple #3
0
static void
setup(OutputTestFixture *fixture,
      const void        *data,
      TaskScenario       task_scenario,
      gboolean           with_chain)
{
    if (with_chain) {
        fixture->stream_descs = &various_stream_descs[0];
        fixture->n_stream_descs = G_N_ELEMENTS(various_stream_descs);
    } else {
        fixture->stream_descs = data;
        fixture->n_stream_descs = 1;
    }

    fixture->loop =
        g_main_loop_new(NULL, FALSE);

    fixture->runner =
        g_object_new(HRT_TYPE_TASK_RUNNER,
                     "event-loop-type", HRT_EVENT_LOOP_EV,
                     NULL);

    g_signal_connect(G_OBJECT(fixture->runner),
                     "tasks-completed",
                     G_CALLBACK(on_tasks_completed),
                     fixture);

    switch (task_scenario) {
    case TASK_SCENARIO_ALL_ONE: {
        HrtTask *task;
        int i;

        fixture->tasks_started_count = 1;

        task = hrt_task_runner_create_task(fixture->runner);

        for (i = 0; i < N_STREAMS_IN_CHAIN; ++i) {
            fixture->write_tasks[i] = g_object_ref(task);
            fixture->stream_tasks[i] = g_object_ref(task);
        }

        if (with_chain) {
            fixture->chain_task = task;
        } else {
            g_object_unref(task);
        }
    }
        break;
    case TASK_SCENARIO_THREE: {
        HrtTask *task;
        int i;

        /* with no chain there's no chain task so really two ;-) */
        if (with_chain) {
            task = hrt_task_runner_create_task(fixture->runner);

            fixture->chain_task = task;

            fixture->tasks_started_count = 3;
        } else {
            fixture->tasks_started_count = 2;
        }

        task = hrt_task_runner_create_task(fixture->runner);

        for (i = 0; i < N_STREAMS_IN_CHAIN; ++i) {
            fixture->write_tasks[i] = g_object_ref(task);
        }

        g_object_unref(task);

        task = hrt_task_runner_create_task(fixture->runner);

        for (i = 0; i < N_STREAMS_IN_CHAIN; ++i) {
            fixture->stream_tasks[i] = g_object_ref(task);
        }

        g_object_unref(task);
    }
        break;
    case TASK_SCENARIO_ALL_DISTINCT: {
        int i;

        if (with_chain) {
            HrtTask *task;

            task = hrt_task_runner_create_task(fixture->runner);

            fixture->chain_task = task;

            fixture->tasks_started_count = 1 + N_STREAMS_IN_CHAIN * 2;
        } else {
            fixture->tasks_started_count = N_STREAMS_IN_CHAIN * 2;
        }

        for (i = 0; i < N_STREAMS_IN_CHAIN; ++i) {
            fixture->write_tasks[i] = hrt_task_runner_create_task(fixture->runner);
            fixture->stream_tasks[i] = hrt_task_runner_create_task(fixture->runner);
        }
    }
        break;
    }

    if (with_chain) {
        fixture->chain = hio_output_chain_new(fixture->chain_task);
    }

    create_socketpair(&fixture->read_fd,
                      &fixture->write_fd);
}