uv_work_t *baton;
void work(uv_work_t* task) {}
void after(uv_work_t* task, int status) {
printf("after\n");
delete task;
}
int process()
{
baton = new uv_work_t();
uv_queue_work(uv_default_loop(), baton, work, after);
printf("before\n");
return 0;
}
static uv_sem_t sem;
uv_work_t *baton;
void work(uv_work_t* task) {}
void after(uv_work_t* task, int status) {
printf("after\n");
delete task;
uv_sem_post(&sem);
}
int process()
{
baton = new uv_work_t();
if (uv_sem_init(&sem, 0) < 0) {
perror("uv_sem_init");
return -1;
}
uv_queue_work(uv_default_loop(), baton, work, after);
printf("before\n");
uv_sem_wait(&sem);
uv_sem_destroy(&sem);
return 0;
}