Re: How to handle long I/O operations



On Sun, Aug 12, 2001 at 08:58:04PM -0700 Tara M wrote:

Hi, what you described sounds similar to a common situation that
I've dealt with. I'm not sure if our design would be applicatable
to your situation, but it's a very simple approach.

We have a primary management function that handles all per ``cycle''
instances that's called by GTK+ timeout. This timeout function
is to a short interval and the function handles the following:

Whenever a callback function generates a `job', a new structure
is alloated to the job list, the members of this structure are
filled with the important data, ie the FILE pointer if you were
downloading a file for example.

However once the job structure is allocated and set up (ie
a file being opened), the callback returns immediatly and does
nothing else.

Then as GTK+ control returns to toplevel, our management timeout
callback function is called, it then handles the list of jobs
per `cycle'.

I hope the tip helps you, let me know if you need a more detailed
explaination. Because this approach is very fundimental and dosen't
require anything fancy other than using GTK+'s timeout callback.

Instead of using cycles in a GTK timeout function you could use the
gtk_idle_add() function where you pass the "job" argument (fd, etc.).
I think this would be faster if you want to load something from disk.

Markus.




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