RE: The iterator interface



 

>-----Original Message-----
>From: tinymail-devel-list-bounces gnome org 
>[mailto:tinymail-devel-list-bounces gnome org] On Behalf Of 
>ext James "Doc" Livingston
>Sent: Monday, August 07, 2006 12:32
>To: tinymail-devel-list gnome org
>Subject: RE: The iterator interface
>
>On Mon, 2006-08-07 at 10:49 +0200, Philip Van Hoof wrote:
>> On Mon, 2006-08-07 at 11:31 +0300, Dirk-Jan Binnema nokia com wrote:
>> > That sounds like a good plan; make 'm void. And then maybe add 
>> > ref'ing and non-ref'ing versions of _current, maybe with a 
>bool flag?
>> > 
>> > ie.
>> > GObject* tny_iterator_iface_current (const TnyIteratorIface *self, 
>> > gboolean add_ref);
>>
>> I agree but without the boolean flag. I think it's better to 
>simply be 
>> consistent and always add the reference.

Yeah, it's not *so* important.

>I'm currently writing a more details response to the original 
>post, but I'd agree with Phillip here. The whole point of 
>doing this would be to fix potential thread-safety issues, and 
>letting people pass FALSE for "add ref" would just be putting 
>those issues back in again.
>
>If for some reason you can't cope with handling 
>reference-counting properly, you can always call 
>g_object_unref directly after you get the object. I think 
>making it always return an added reference would be better, 
>because it means that people who don't understand this 
>particular issue will do it the safe way, rather then making 
>it easier for them to write broken code without realising it.

Hmmm.... I was thinking about programmer friendliness; if I always
have to unref the reference, I always have to assign the retval
to a variable, and do the unref.

However, maybe I'd like to do something like:

while (!tny_iterator_iface_is_done (iter)) {
	do_something_nifty (tny_iterator_iface_current(iter, FALSE));
	tny_iterator_iface_next (iter);
}

Of course, nothing really special, but it would make for a little
bit nicer client code. Alternatively, instead of the boolean, we
could have tny_iterator_iface_current_floating.

Anyway, not a big deal. 

Best wishes,
Dirk.





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