[Adium-devl] Importer API
Ofri Wolfus
ofri.wolfus at gmail.com
Wed Apr 11 08:16:50 UTC 2007
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.
- Ofri
- - - - - - - - - - - - - - - - - - -
http://www.dpompa.com
- - - - - - - - - - - - - - - - - - -
On 11/04/2007, at 08:47, Peter Hosey wrote:
> On Apr 10, 2007, at 17:23:13, Graham Booker wrote:
>> The calling thread does *not* wait!
>
> Then there's no reason for the -beginImportingAccounts method to
> return anything, except maybe a token that can be used to cancel
> the import. (Allowing Cancel would probably be a good idea.)
>
>> The calling thread is the process's run loop,
>
> Run loops are per-thread, not per-process. Any thread can have a
> run loop if it wants one.
>
> Perhaps you meant:
>
> The calling thread is the main thread,
>
> I'll continue under that assumption.
>
>> Essentially, the thread, after it has completed, does a
>> performSelectorOnMainThread and then exits.
>
> So it would be performing some sort of delegate callback message?
>
>> … 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.
>>
>> ⋮
>>
>> The run loop is free to process other things, such as IMs, logins,
>> etc... Only this window is blocked from continuing further.
>
> Seems like we don't need the import wizard for that. We can order
> out the wizard and just show a regular progress panel, rather like
> the one Sparkle uses.
>
>>> 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. …
>> 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.
>
> Agreed.
>
>> 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.
>
> Right. That's really not an API issue at all; it's an
> implementation detail.
> ___________________________________
> \ Peter Hosey / boredzo at adiumx.com
> PGP public key ID: C6550423 (since 2007-01-01)
>
>
> _______________________________________________
> 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/20070411/4dc80294/attachment-0001.html>
More information about the devel
mailing list