View unanswered posts | View active topics It is currently Sun May 19, 2013 3:58 pm



Reply to topic  [ 2 posts ] 
 Threads and Concurrency Question 
Author Message

Joined: Nov 02, 2003
Posts: 88
Post Threads and Concurrency Question
I read this in another posting:

" When you call a function that is defined in an attachment script it is executed in the main Indigo Server process (and AppleScript context), which is similar to an embedded AppleScript. "

I have a timer process which executes once per minute and calls an applescript within the attachments folder which potentially causes several Indigo variables to be updated. I also have several trigger actions which trigger on changes to those variables.

So suppose Script 1 activates on a timer and changes Variable 1, then changes Variable 2, then does some other processing before it exits. Script 2 activates on the change in Variable 1, and Script 3 activates on the change in Variable 2.

What is the order of events? Does Script 2 activate before Script 1 is done executing? Does Script 3 activate before Script 2 is done executing (assuming its execution takes several seconds)? If the action of Script 2 depends on the value of variable 2 do I have a problem?[/quote]


Wed Jun 20, 2007 4:49 pm
Profile
Site Admin
User avatar

Joined: Jan 27, 2003
Posts: 11682
Location: Texas
Post Re: Threads and Concurrency Question
wikner wrote:So suppose Script 1 activates on a timer and changes Variable 1, then changes Variable 2, then does some other processing before it exits. Script 2 activates on the change in Variable 1, and Script 3 activates on the change in Variable 2.

Embedded AppleScripts and functions defined in attachment scripts execute in the main Indigo Server thread. Linked AppleScripts execute in their own process. Variable changes cause dependent Trigger Actions to occur immediately after the variable has changed.

So if you have an Attachment script function (or an embedded script) that changes variable foo1 and then variable foo2, and you have a Trigger Action on foo1 and foo2 that execute embedded script actions, then the order will be:

attachment script function (or embedded script)
  change of variable foo1
    foo1 Trigger Action script execute starts
      script executing
    foo1 Trigger Action script finishes
  change of variable foo2
    foo2 Trigger Action script execute starts
      script executing
    foo2 Trigger Action script finishes
end

If the Trigger Actions for variable foo1 and foo2 are linked (not embedded), then they Indigo Server will start a new process to execute the scripts. The order will then be indeterminate. The order will also be indeterminate if your original script is not embedded or isn't all defined inside a single attachment script function (foo2 may get modified before the foo1 Trigger Action script is finished executing).

Regards,
Matt


Thu Jun 21, 2007 2:28 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.