[Adium-devl] Blocking AppleScript Commands

Matt Handley applmak at gmail.com
Mon Apr 21 22:30:42 UTC 2008


Right. If the server decided to die, right as the command was  
executed, then we'd block for quite some time (too long).

AS usually uses the "with timeout/end timeout" construct to give a  
timeout for these sorts of things. If the command doesn't reply  
within the timeout, then the event fails, and control is returned to  
the script. Of course, Adium is still blocked until the command is  
resolved, even though the script is no longer waiting for it.

Would it be possible to try to wait (runMode:beforeDate:) until the  
command timeout (which may be accessible from within Cocoa...)  
elapses? Were that possible, then without a timeout specified, then  
Adium would not block. Yet if the scripter wanted to be able to  
specify the elapsed time, he would still have such a mechanism.

The only things I see as preventing this from working is if: a) there  
is no way to get the timeout field of the apple event (unlikely), b)  
if the right NSRunLoop is hard to get to (we're multi-threaded,  
right?), or c) if the NSRunLoop does tricky things that we don't  
necessarily want to run over and over again while we're waiting for a  
response from a server.

What do you think?

Matt

On Apr 21, 2008, at 5:07 PM, Evan Schoenberg wrote:

>
> On Apr 21, 2008, at 5:34 PM, Peter Hosey wrote:
>
>> On Apr 21, 2008, at 13:21:35, Evan Schoenberg wrote:
>>> If I understand your question correctly: there is no guarantee that
>>> an account will be offline immediately after being told to go
>>> offline. It may take some time for it to actually be offline or for
>>> contacts on that account to be marked offline and in no group.
>>
>> Perhaps the “go offline” command should block (using -[NSRunLoop
>> run]) until the account is disconnected, so that the reply can be an
>> error if appropriate.
>>
>> This would also apply to the other “go [status]” commands.
>
> This could potentially be a long block... and we need the run loop to
> find out when the account disconnects, anyways, because it might (for
> example) be a process of the account sending "I want to go offline
> cleanly" to the server, the server doing some stuff or sending last
> minute information, and then the server replying (some time later),
> "Okay, go right ahead."
>
> -Evan
> _______________________________________________
> Adium-devl mailing list
> Adium-devl at adiumx.com
> http://adiumx.com/mailman/listinfo/adium-devl_adiumx.com





More information about the devel mailing list