[Adium-devl] Importer API

Ofri Wolfus ofri.wolfus at gmail.com
Thu Apr 12 17:10:29 UTC 2007


Apparently I'm the only one in that opinion, but I still think  
threading should be avoided whenever possible, especially when you  
don't *need* another thread and its purpose just to keep the UI  
responsive. In my previous suggestion, importLogWithError: is invoked  
periodically by a runloop source, but it doesn't really have to  
import one log at a time. Large logs can be imported in parts and  
spread on multiple invocations of that method.

I truly believe a bit of extra effort for these special log cases is  
worth it if eliminates multi-threading headaches.

- Ofri

- - - - - - - - - - - - - - - - - - -
http://www.dpompa.com
- - - - - - - - - - - - - - - - - - -


On 11/04/2007, at 22:07, Graham Booker wrote:

> On Apr 11, 2007, at 3:16 AM, Ofri Wolfus wrote:
>> All these talking about runloops made me think. Instead of  
>> importing in another thread we can define the method as -(BOOL) 
>> importLogWithError:(NSError *)err. It would then import *one* log  
>> at a time (returning NO when no logs are left), and instead of  
>> invoking it in a secondary thread, it would be added to the main  
>> thread's runloop as an input source. This gives us responsive UI,  
>> avoiding the thread-safety headache, easy canceling (by imply  
>> invalidating the input source or removing it temporarily from the  
>> runloop for pausing) and you could do any AppKit calls safely as  
>> you'll be running in the main thread.
>>
>
> The problem with this comes into play if a log file takes a long  
> time to process.  In the example of the Fire import, any XML files  
> must be completely parsed and reformatted.  This can be a complex  
> operation, and since Fire supported irc, these log files can be  
> really really large.  With the thread, the responsiveness of the  
> app is independent of the size of individual files, or the amount  
> of processing required to import them.
>
> What if a future importer deals with a SQL database or something  
> like that, where the import operations essentially have to be done  
> en-mass?  I think the thread method is the most flexible in the  
> future, allowing the programmer to do expensive operations if they  
> like.
>
>> - Ofri
>>
>> - - - - - - - - - - - - - - - - - - -
>> http://www.dpompa.com
>> - - - - - - - - - - - - - - - - - - -
>
>
>
> _______________________________________________
> Adium-devl mailing list
> Adium-devl at adiumx.com
> http://adiumx.com/mailman/listinfo/adium-devl_adiumx.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://adium.im/pipermail/devel_adium.im/attachments/20070412/9817bb6f/attachment-0001.html>


More information about the devel mailing list