Re: Asynchronous File Reading



You can try this little library I wrote..

http://www.flyingbuttmonkeys.com/~rothwell/libgtkasyncfile.tgz

It implements async i/o for files. Enable threads to get better performance.
Unfortunately, filesystem file descriptors don't really support nonblocking
I/O and read() will block anyway, regardless of what the manpage says.
Network sockets do support nonblocking I/O. The short story is, you want to
use threads unless your OS actually supports async I/O. Posix defines async
aio, but Linux does not implement it. Solaris supports aio, I think, and
NT/2000 has io completion ports. There's an AIO library for Linux/glibc, but
it uses threads to do it.

Included in the tarball are several demo programs. Look at gtk_jpeg in src/
to get a look at using async file i/o and gdk_pixbuf to incrementally load
and display images. Copy a JPEG to a floppy disk to get a look at it working
with slow media. Look in multi/ for a glade project that simply reads up to
four files and updates progress bars while doing so.

Keep in mind that, on Linux, filesystems are (typically? always?)
single-threaded. This means that you can read simultaneously from different
volumes, but you have to stand in line when trying to read several files
from a single volume.

My library doesn't implement writes, only reads, but I'm open to accepting
patches.

An additional note: Gtk < 1.2.8 seems to have a problem with the threading
stuff.

-M

----- Original Message -----
From: "Dugas, Alan" <alan dugas analog com>
To: <gtk-app-devel-list gnome org>; <gtk-list gnome org>
Sent: Friday, February 09, 2001 8:22 AM
Subject: Asynchronous File Reading


> Does anyone have a suggestion on how I could asynchronously read a file?
> I've tried using gtk_timeout_add()/gtk_timeout_remove(), but this causes
> "racing" conditions when run over a network.  Any ideas would be greatly
> appreciated.
>
>
>
> -- Stupid Genius
>
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>





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