Esempio n. 1
0
void t3_notify(struct curl_client_t* cc, void* args)
{
    struct task_step_t* ts = (struct task_step_t*)(args);
	struct task_step_result_t* rt = NULL;
	struct task_step_t* t1 = NULL;
	t1_data_t* td = NULL;

    if (curl_client_err_code(cc) != CURLE_OK) {
        printf("task step[%x] asynchronous notify, fail\n", task_step_id(ts));
        rt = task_step_result_init(TASK_RET_FAIL);
        task_step_finish(ts, rt);
        task_step_result_release(rt);
    }
    printf("task step[%x] asynchronous notify, complete\n", task_step_id(ts));

    t1 = task_get_step(task_step_task(ts), id);
    assert(t1);
    td = (t1_data_t*)task_step_data(t1);
    td->result --;
    if (td->result > 0) {
        printf("need to loop %d times\n", td->result);
        rt = task_step_result_init(TASK_RET_NEXT);
        task_step_result_set_backward(rt);
        task_step_finish(ts, rt);
        task_step_result_release(rt);
    } else {
        rt = task_step_result_init(TASK_RET_SUCCESS);
        task_step_finish(ts, rt);
        task_step_result_release(rt);
    }
}
Esempio n. 2
0
int32_t t1_run(struct task_step_t* ts)
{
	struct t1_data_t* td;
	void* arg;

    td = (t1_data_t*)MALLOC(sizeof(*td));
    task_step_set_data(ts, td, t1_data_release);
	arg = task_data(task_step_task(ts));
    assert(arg);
    td->result = *(int32_t*)arg;
    printf("task step[%x] run complete\n", task_step_id(ts));
    return TASK_RET_NEXT;
}
Esempio n. 3
0
static void
t3_notify(curlc_t* cc, void* args) {
    task_step_t* ts = (struct task_step_t*)(args);
    if (curlc_ret(cc) != CURLE_OK) {
        printf("task step[%x] asynchronous notify, fail\n", task_step_id(ts));
        task_step_resume(ts, TASK_RET_FAIL, 0);
    }
    printf("task step[%x] asynchronous notify, complete\n", task_step_id(ts));

    task_step_t* t1 = task_get_step(task_step_task(ts), _task_step_id);
    if (!t1) {
        fprintf(stderr, "task get step fail");
        return;
    }

    t1_param_t* tsp = (t1_param_t*)task_step_param(t1);
    if (tsp->loop -- > 0) {
        printf("need to loop %d times\n", tsp->loop);
        task_step_resume(ts, TASK_RET_NEXT, -1);
    } else {
        task_step_resume(ts, TASK_RET_SUCCESS, 0);
    }
}