Precedence of Send commands

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Precedence of Send commands

Post by townsend » Mon Jul 02, 2012 8:52 pm

I'm really getting to like the Send command.
But I'm a little hesitant about using them more often,
due to concern on how they'll interact with other Handlers.

What happens when 2 or more send commands are concurrent?
Lets say I have 2 handlers: handler.one & handler.two.
handler.one takes a long time. Say 2 minutes to complete.
But during that 2 minutes another Send command triggers handler.two.
which only takes a moment to complete. Does it get precedence?
Is there any way to control precedence?
Or do CPU cycles get split evenly?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Precedence of Send commands

Post by bn » Mon Jul 02, 2012 9:23 pm

townsend,

have a look here
http://forums.runrev.com/phpBB2/viewtop ... 340#p58383

which references Dar Scott's Primer on Message Mechanics
http://pages.swcp.com/dsc/revstacks.html

it is the most thorough sample/description of "send" I know.

as far as your question is concerned: difficult to say, is handler.one blocking? Or has it a wait with messages part? If handler.one runs and suppose it is blocking who could issue the 2. send? If the 2. send was issued before handler.one started but was timed to a time during execution of handler.one it will execute handler.two after handler.one finishes.

Well I guess it all depends. But Dar Scott does a tremendously good job of covering all the possibilities.

Kind regards
Bernd

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Precedence of Send commands

Post by jacque » Mon Jul 02, 2012 11:27 pm

Messages that are sent will only trigger during the next idle. If the 2-min handler doesn't have any "wait with messages" in it, then the second "send" will never even trigger until the first handler is completed.

If the long handler does allow idle cycles, then whichever "send" should occur earliest will trigger during the idle. The originally running handler will pause until the sent message handler completes, then resume its long process.

Only one handler can be running at any time.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply