コード例 #1
0
static void adjust_clock (PseudoTcpSocket *sock)
{
  guint64 timeout = 0;

  if (pseudo_tcp_socket_get_next_clock (sock, &timeout)) {
    timeout -= g_get_monotonic_time () / 1000;
    g_debug ("Socket %p: Adjusting clock to %" G_GUINT64_FORMAT " ms", sock, timeout);
    if (sock == left) {
      if (left_clock != 0)
         g_source_remove (left_clock);
      left_clock = g_timeout_add (timeout, notify_clock, sock);
    } else {
      if (right_clock != 0)
         g_source_remove (right_clock);
      right_clock = g_timeout_add (timeout, notify_clock, sock);
    }
  } else {
    g_debug ("Socket %p should be destroyed, it's done", sock);
    if (sock == left)
      left_closed = TRUE;
    else
      right_closed = TRUE;
    if (left_closed && right_closed)
      g_main_loop_quit (mainloop);
  }
}
コード例 #2
0
static void
update_timer(PseudoTcpChannel *tcp) {
	gboolean res;
	long relative_timeout;
	res = pseudo_tcp_socket_get_next_clock(tcp->pseudo_tcp, &relative_timeout);

	if(res == FALSE)
		return;

	static long last_abs_timeout = -1;
	static PseudoTcpChannel *last_tcp;
	static guint timer = -1;

	if(timer = -1) {
		guint new_timeout = timeout;
	}
	else {
		long abs_time
		if(last_timeout )
		g_source_remove
	}

	timer = g_timeout_add(new_timeout, timedout, tcp);
}