Hmm.  I wonder.

On Jul 17, 2012, at 11:02 PM, Mark Wieder wrote:
> You may find some useful information in the notes to bug 1242.

Thank you, Mark.  

I have some questions on this.  I hope folks have some ideas.  My first...

Here is the first part of the applicable note:


Adding these notes at the request of Mark Wieder. These notes relate to using
SendCardMessage in the context of an OS event rather than in the context of an
external handler. Information was provided by Mark Waddingham.

1) Use "send in time" with SendCardMessage. This way the message will execute
at a time when the engine will allow a script to run and in an environment
where "no unpleasant sate might be hanging around". This is necessary for
externals on OS X or Windows.


I picture three types of OS "events" that might trigger external code:
1. callbacks that bypass any thread's run loop
2. callbacks that are triggered by events and called at the top of the LiveCode 
run loop
3. callbacks triggered by events in some other thread and called in its run loop

It is not clear to me why it is needed in case 2, but I can see how it might be 
and the use of "send in time" should not hurt.  I can attach callbacks to the 
main run loop.  

However, I don't see how "send in time" is adequate in the other cases.  It is 
very unlikely that the pendingMessages queue is thread safe.  There is nothing 
to prevent the callback from occurring in the middle of a 'send', 'cancel' or 
dispatch.  The use of 'send in time' might reduce the probability of problems, 
but it might be just an illusion.  When I say "nothing to prevent", I mean 
nothing that I can see, I am quite willing to be convinced.  

Does one have to convert cases 1 and 3 to case 2?  (Ouch)  Or do they somehow 
work?  How?

Dar




_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to