Re: Event loop



On Mon, 13 Nov 2000, Nils Rennebarth wrote:

On Sat, Nov 11, 2000 at 02:08:20PM -0500, Havoc Pennington wrote:
The easiest way to do this type of thing in GTK is usually to put
do_something() in an idle handler.

Pretty much any _something() can simply be integrated into the GLib
main loop instead of doing your own busy loop.
In my application I have to save a 1MB image to a file using .png which
takes a lot of time on that oldish P166. What would you suggest to use for
saving the image "in the background"?

- separate process
- use threads
- do the writing in an idle handler

If I use a different process, I need to transfer a lot of data and returning
error messages or progress messages to the user is much work.

You should memorymap the file (mmap) and spawn a separate process.
Prevention of update you do with a semaphore.

GH


An idle handler also needs to split the task of writing the file to write
several lines or how else do I prevent the handler from taking 5 seconds
in a row once it has been started?

Nils

--
*New* *New* *New*    - on shellac records
   Windows HE        - see top 10 reasons to downgrade on
Historical Edition     http://www.microsoft.com/windowshe


----------------------------------------------------------------
Göran Hasse            email: gh raditex se     Tel: 08-6949270
Raditex AB             http://www.raditex.se    Fax: 08-6949280
Sickla Alle 7, 1tr                              Mob: 070-5530148
131 34  NACKA, SWEDEN






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