Ejemplo n.º 1
0
static void
log_threaded_dest_driver_init_watches(LogThrDestDriver* self)
{
  IV_EVENT_INIT(&self->wake_up_event);
  self->wake_up_event.cookie = self;
  self->wake_up_event.handler = log_threaded_dest_driver_wake_up;
  iv_event_register(&self->wake_up_event);

  IV_EVENT_INIT(&self->shutdown_event);
  self->shutdown_event.cookie = self;
  self->shutdown_event.handler = log_threaded_dest_driver_shutdown;
  iv_event_register(&self->shutdown_event);

  IV_TIMER_INIT(&self->timer_reopen);
  self->timer_reopen.cookie = self;
  self->timer_reopen.handler = log_threaded_dest_driver_do_work;

  IV_TIMER_INIT(&self->timer_throttle);
  self->timer_throttle.cookie = self;
  self->timer_throttle.handler = log_threaded_dest_driver_do_work;

  IV_TASK_INIT(&self->do_work);
  self->do_work.cookie = self;
  self->do_work.handler = log_threaded_dest_driver_do_work;
}
Ejemplo n.º 2
0
static void iv_work_thread(void *_thr)
{
	struct work_pool_thread *thr = _thr;
	struct work_pool_priv *pool = thr->pool;

	iv_init();

	INIT_IV_LIST_HEAD(&thr->list);

	thr->kicked = 0;

	IV_EVENT_INIT(&thr->kick);
	thr->kick.cookie = thr;
	thr->kick.handler = iv_work_thread_got_event;
	iv_event_register(&thr->kick);

	IV_TIMER_INIT(&thr->idle_timer);
	thr->idle_timer.cookie = thr;
	thr->idle_timer.handler = iv_work_thread_idle_timeout;

	if (pool->thread_start != NULL)
		pool->thread_start(pool->cookie);

	iv_event_post(&thr->kick);

	iv_main();

	iv_deinit();
}
Ejemplo n.º 3
0
static void
log_reader_init_watches(LogReader *self)
{
  gint fd;
  GIOCondition cond;

  log_proto_prepare(self->proto, &fd, &cond);

  IV_FD_INIT(&self->fd_watch);
  self->fd_watch.cookie = self;

  IV_TIMER_INIT(&self->follow_timer);
  self->follow_timer.cookie = self;
  self->follow_timer.handler = log_reader_io_follow_file;

  IV_TASK_INIT(&self->restart_task);
  self->restart_task.cookie = self;
  self->restart_task.handler = log_reader_io_process_input;

  IV_EVENT_INIT(&self->schedule_wakeup);
  self->schedule_wakeup.cookie = self;
  self->schedule_wakeup.handler = log_reader_wakeup_triggered;

  main_loop_io_worker_job_init(&self->io_job);
  self->io_job.user_data = self;
  self->io_job.work = (void (*)(void *)) log_reader_work_perform;
  self->io_job.completion = (void (*)(void *)) log_reader_work_finished;
}
Ejemplo n.º 4
0
static void
afinter_source_init_watches(AFInterSource *self)
{
  IV_EVENT_INIT(&self->post);
  self->post.cookie = self;
  self->post.handler = afinter_source_post;
  IV_TIMER_INIT(&self->mark_timer);
  self->mark_timer.cookie = self;
  self->mark_timer.handler = afinter_source_mark;
  IV_EVENT_INIT(&self->schedule_wakeup);
  self->schedule_wakeup.cookie = self;
  self->schedule_wakeup.handler = (void (*)(void *)) afinter_source_update_watches;
  IV_TASK_INIT(&self->restart_task);
  self->restart_task.cookie = self;
  self->restart_task.handler = afinter_source_post;
}
Ejemplo n.º 5
0
static void
_register_event(struct iv_event *event, void (*handler)(void *))
{
  IV_EVENT_INIT(event);
  event->handler = handler;
  event->cookie = NULL;
  iv_event_register(event);
}
Ejemplo n.º 6
0
static void
log_reader_init_watches(LogReader *self)
{
  IV_TASK_INIT(&self->restart_task);
  self->restart_task.cookie = self;
  self->restart_task.handler = log_reader_io_process_input;

  IV_EVENT_INIT(&self->schedule_wakeup);
  self->schedule_wakeup.cookie = self;
  self->schedule_wakeup.handler = log_reader_wakeup_triggered;

  IV_EVENT_INIT(&self->last_msg_sent_event);
  self->last_msg_sent_event.cookie = self;
  self->last_msg_sent_event.handler = _last_msg_sent;

  IV_TIMER_INIT(&self->idle_timer);
  self->idle_timer.cookie = self;
  self->idle_timer.handler = log_reader_idle_timeout;

  main_loop_io_worker_job_init(&self->io_job);
  self->io_job.user_data = self;
  self->io_job.work = (void (*)(void *)) log_reader_work_perform;
  self->io_job.completion = (void (*)(void *)) log_reader_work_finished;
}
Ejemplo n.º 7
0
static void
_init_watches(JournalReader *self)
{
    IV_EVENT_INIT(&self->schedule_wakeup);
    self->schedule_wakeup.cookie = self;
    self->schedule_wakeup.handler = _wakeup_triggered;
    iv_event_register(&self->schedule_wakeup);

    IV_TASK_INIT(&self->restart_task);
    self->restart_task.cookie = self;
    self->restart_task.handler = _io_process_input;

    main_loop_io_worker_job_init(&self->io_job);
    self->io_job.user_data = self;
    self->io_job.work = (void (*)(void *)) _work_perform;
    self->io_job.completion = (void (*)(void *)) _work_finished;
}
Ejemplo n.º 8
0
static void thr_child(void *_dummy)
{
	iv_init();

	IV_EVENT_INIT(&ev_child);
	ev_child.handler = got_ev_child;
	iv_event_register(&ev_child);

	iv_validate_now();
	tim_start = iv_now;

	iv_event_post(&ev_parent);

	iv_main();

	iv_deinit();
}
Ejemplo n.º 9
0
int main()
{
	long long nsec;

	iv_init();

#ifdef USE_SIGNAL
	signal(SIGALRM, got_signal_timeout);
	alarm(5);
#else
	IV_TIMER_INIT(&timeout);
	iv_validate_now();
	timeout.expires = iv_now;
	timeout.expires.tv_sec += 5;
	timeout.handler = got_timer_timeout;
	iv_timer_register(&timeout);
#endif

	IV_EVENT_INIT(&ev_parent);
	ev_parent.handler = got_ev_parent;
	iv_event_register(&ev_parent);

	iv_thread_create("child", thr_child, NULL);

	iv_main();

	iv_deinit();

	nsec = 1000000000ULL * (tim_end.tv_sec - tim_start.tv_sec) +
		(tim_end.tv_nsec - tim_start.tv_nsec);

	printf("%s: %d in %lld nsec => %d/sec\n",
	       iv_poll_method_name(), ev_received, (long long)nsec,
	       (int)(1000000000ULL * ev_received / nsec));

	return 0;
}