Example #1
0
int
cli_cmd_await_response (unsigned time)
{
        struct  timespec        ts = {0,};
        int                     ret = 0;

        cli_op_ret = -1;

        seconds_from_now (time, &ts);
        while (!cmd_done && !ret) {
                ret = pthread_cond_timedwait (&cond, &cond_mutex,
                                        &ts);
        }

        if (!cmd_done) {
                if (ret == ETIMEDOUT)
                        cli_out ("Error : Request timed out");
                else
                        cli_out ("Error : Command returned with error code:%d",
                                 ret);
        }
        cmd_done = 0;

        return cli_op_ret;
}
Example #2
0
int
cli_cmd_await_response (unsigned time)
{
        struct  timespec        ts = {0,};
        int                     ret = 0;

        cli_op_ret = -1;

        seconds_from_now (time, &ts);
        while (!cmd_done && !ret) {
                ret = pthread_cond_timedwait (&cond, &cond_mutex,
                                        &ts);
        }

        cmd_done = 0;

        if (ret)
                return ret;

        return cli_op_ret;
}
Example #3
0
int32_t
cli_cmd_await_connected (unsigned conn_timo)
{
        int32_t                 ret = 0;
        struct  timespec        ts = {0,};

        if (!conn_timo)
                return 0;

        pthread_mutex_lock (&conn_mutex);
        {
                seconds_from_now (conn_timo, &ts);
                while (!connected && !ret) {
                        ret = pthread_cond_timedwait (&conn, &conn_mutex,
                                                      &ts);
                }
        }
        pthread_mutex_unlock (&conn_mutex);


        return ret;
}
Example #4
0
int main()
{
	log_info("%s %d \n", "test", 3);

	reload_context_t t;
	memset(t.reloader_name, 0, MAX_RELOADER_NAME_SIZE);
	snprintf(t.reloader_name, MAX_RELOADER_NAME_SIZE, "%s", "myreloader");
	t.reload_timestamp = seconds_from_now(60);

	namespace TW = crafet::timer_worker;
	//crafet::timer_worker::TimerWorker* tw = new crafet::timer_worker::TimerWorker();
	TW::TimerWorker* tw = new TW::TimerWorker();


	// define my process as a loop task
	tw->schedule_repeated(microsecond_from_now(), 60, reload, &t);
	if (!tw->start()) {
		log_error("failed to start reload task");		
	}


	return 0;
}