Respawning idle functions...



This question is independent from the previous one.

I'm working on etherape, a program that displays graphically network connections. I'm using a timeout function to update the diagram, but in high load conditions or with short refresh periods there might be an overrun.

I'm trying to solve the problem by turning the timeout into an idle function with this code

  if (!is_idle)
    {
      if (diff_msecs > refresh_period * 1.1)
        {
          diagram_timeout =
            g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
                             (GtkFunction) update_diagram,
                             canvas,
                             (GDestroyNotify) destroying);
          is_idle = TRUE;
          return FALSE;         /* Removes the timeout */
        }
    }
  else
    {
      if (diff_msecs < refresh_period)
        {
          diagram_timeout = gtk_timeout_add (refresh_period,
                                             (GtkFunction) update_diagram,
                                             canvas);
          is_idle = FALSE;
          return FALSE;         /* removes the idle */
        }
    }
  return TRUE;                  /* Keep on calling this function */
 

It can work fine, but sometimes (pretty soon) it seems as though a removed idle is still being called.
 

Here is some debug output that could help you understand...

Target refresh period is 800. The first time it goes over 110% of that it goes to idle and back with no problem, but the second time, even though the destroy function is called, it's as if update_diagram was called once idle and once timeout.

Any insight would be much appreciated. Perhaps I should submit a bug report?

Regards,
Juan.
 

Message: Number of nodes: 3. Refresh Period: 872. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 106. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 94. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 1142. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 50. IDLE.
Message: An idle function has been destroyed
Message: Number of nodes: 3. Refresh Period: 855. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 811. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 805. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 804. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 808. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 810. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 800. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 810. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 809. TIMEOUT.
DEBUG: Creating link: encomix-NEBAJ. Number of links 5
DEBUG: Creating link: NEBAJ-encomix. Number of links 6

** WARNING **: Widget not found: UDP_UNKNOWN
Message: UDP_UNKNOWN in white
DEBUG: Creating canvas_link: NEBAJ-encomix. Number of links 5
DEBUG: Creating canvas_link: encomix-NEBAJ. Number of links 6
Message: Number of nodes: 3. Refresh Period: 1263. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 152. IDLE.
Message: An idle function has been destroyed
Message: Number of nodes: 3. Refresh Period: 11. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 7. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 213. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 614. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 168. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 640. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 176. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 631. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 171. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 640. TIMEOUT.
Message: Number of nodes: 3. Refresh Period: 171. TIMEOUT.
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]