Re: The iterator interface
- From: Philip Van Hoof <spam pvanhoof be>
- To: tinymail-devel-list gnome org
- Subject: Re: The iterator interface
- Date: Sun, 06 Aug 2006 17:02:47 +0200
On Sun, 2006-08-06 at 16:56 +0200, Philip Van Hoof wrote:
> The Python language binding discussion with James stumbled on an
> interesting point of discussion:
>
> GObject* tny_iterator_iface_next (TnyIteratorIface *self);
> GObject* tny_iterator_iface_prev (TnyIteratorIface *self);
> GObject* tny_iterator_iface_first (TnyIteratorIface *self);
> GObject* tny_iterator_iface_nth (TnyIteratorIface *self, guint nth);
> GObject* tny_iterator_iface_current (TnyIteratorIface *self);
>
>
> Shouldn't these methods add a reference to the returned object? If while
> iterating a list gets modified (for example an item gets removed) and
> the current item is the one that was modified (removed), the current
> would other possibly be destroyed.
>
> This would only happen in a multi-threaded situation, of course.
>
> I was thinking about not letting the first four return the GObject, and
> letting _current add a reference. What do you guys think?
Note that on top of that:
For supporting altering the list when iterators are active in another
thread, all the iterators created must be fixed each time a list
changes.
The change proposed here wouldn't be the only required change to support
this. But the proposed change would indeed be required.
I'm open to discussion about supporting it. But it's not exactly easy to
get it 100% right. Yet I'm interested in ideas. I'm even more interested
in patches :-)
It's possible to get it right, indeed. Back when I implemented the
iterator stuff in tinymail, it didn't have a priority. This is the
reason why it's not supported to change the list while an iterator is
active (in another thread nor in the same thread).
--
Philip Van Hoof, software developer at x-tend
home: me at pvanhoof dot be
gnome: pvanhoof at gnome dot org
work: vanhoof at x-tend dot be
http://www.pvanhoof.be - http://www.x-tend.be
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]