[Adium-devl] Importer API

Graham Booker gbooker at cod3r.com
Wed Apr 11 00:23:13 UTC 2007


On Apr 10, 2007, at 7:00 PM, Peter Hosey wrote:

> On Apr 10, 2007, at 14:06:48, disposable at infinitenexus.com wrote:
>> I'd say this would be even better as it matches patterns (at least  
>> in my experience):
>>
>>   -(BOOL)importAccounts:(NSError **)err;
>
> The problem is that it's synchronous. Putting the log importer on  
> another thread is pointless if the calling thread is just going to  
> wait around for it so that it can accept that BOOL return.
>

The calling thread does *not* wait!  The calling thread is the  
process's run loop, and importing logs takes too long to block this  
thread.  I was simply stating that the user cannot continue to the  
next pane in the import "wizard" until this has completed.   
Essentially, the thread, after it has completed, does a  
performSelectorOnMainThread and then exits.  The run loop is free to  
process other things, such as IMs, logins, etc...  Only this window  
is blocked from continuing further.  For questions on how this can  
work, look at the fire importer.

> Solution: Make it asynchronous. Make it (particularly -importLogs)  
> spawn a thread and then return. The thread goes and does the thing  
> to the thing, then does a main-thread perform to call back the  
> delegate with the results.
>
> And once you make one of them asynchronous, we may as well keep  
> them consistent and make the rest of them asynchronous.

Actually, the others should not be asynchronous.  Granted, the  
situation is rather rare, but the user could possibly mess with the  
accounts while the importer is importing other accounts.  Can you  
guarantee that the addition of accounts, and the addition of status  
messages is thread safe?  Importing logs doesn't mess with Adium's  
internal data structure, and it takes a while, making it a perfect  
candidate for a thread.  Importing accounts and status messages does  
not take long, but screws with Adium's internal data structure,  
making it a lousy candidate for a thread.

Besides, in terms of the API, it changes nothing, except that the  
import log function must do actions which are thread safe, which it  
is very unlikely that it wouldn't in the first place.

> ___________________________________
> \ Peter Hosey / boredzo at adiumx.com
> PGP public key ID: C6550423 (since 2007-01-01)


- Graham


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1603 bytes
Desc: not available
URL: <http://adium.im/pipermail/devel_adium.im/attachments/20070410/ae7ade92/attachment.p7s>


More information about the devel mailing list