Re: thread cancellation
- From: Soeren Sandmann <sandmann daimi au dk>
- To: gnome-devel-list gnome org
- Subject: Re: thread cancellation
- Date: 16 Sep 2003 14:33:24 +0200
Colin Walters <walters verbum org> writes:
> This problem can be solved by adding the ability to perform these
> operations incrementally; for instance, if GHashTable had an iterator
> interface, or if I could feed data to the libxml SAX parser
> incrementally instead of all at once (I might switch to GMarkup, which
> allows this).
I am pretty sure that libxml allows being fed data
incrementally. xmlParseChunk() or something? It's a long time since I
used it.
You are right that cancelling a traversal of a GHashTable is not
possible. You might want to file a bug against glib requesting this
feature. The right way to do it is probably to have an iterator
interface, as you say.
A solution for now might be to use the GTree data structure instead of
a hash table. It will still provide reasonably fast lookups and
inserts (O(log n) for the tree vs. O(1) for the hashtable), and its
traversal functions are cancellable.
> Still though, even this feels kind of unclean. It feels like what I
> really want here are exceptions. But since my application is written in
> C, that just leaves me with setjmp/longjmp, which will be quite
> difficult to use because I will have to be careful to free any allocated
> memory used along the way.
I don't think in general GLib supports throwing exceptions or
longjumping out of its callbacks. To support this GLib would have to
be careful not to make any assumptions that the callbacks actually
return.
Søren
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]