An idea on multithreading implementation
Alex Tweedly
alex at tweedly.net
Tue Jan 18 20:00:04 EST 2011
Other than the issue of hitting a breakpoint, can't you simulate this
very closely already.
on addToTimers pMessage, pObject, pFrequency
-- store this info
put pFrequency &TAB& pMessage &TAB& pObject &TAB& pFrequency & CR
after sTimerList
end addToTimers
on removeFromTimers pObject
-- remove from stored list
-- details left as an exercise
end removeFromTimers pObject
on pauseTimers
put false into gTimersAreActive
end pauseTimers
on repetitivelyFireTimers
put empty into tNewList
if gTimersAreActive then
repeat for each line L in sTimerList
subtract 1 from item 1 of L
if item 1 of L = 0 then
send item 2 of L to item 3 of L
put item 4 of L into item 1 of L
end if
put L & CR after tNewList
end repeat
put tNewList into sTimerList
end if
send "repetitivelyFireTimers" to me in 1 second
end repetitivelyFireTimers
P.S. of course, there should be error checking, and you could handle
sub-second (or non-integer second) timers as well - but this general idea
P.P.S I just typed the above script lines in - not tested, not a
technique I generally use.
-- Alex.
end repetitivelyFireTimers
On 18/01/2011 23:57, Jeff Massung wrote:
>
> I - personally - would be much happier if two things were done:
> *** Create a timer control or some method of doing the same thing in code.
> It can be sort of simulated right now like so:
>
> send "foo" to me in 5 seconds
>
> on foo
> ... do stuff ...
> send "foo" to me in 5 seconds
> end
>
> But this has issues (for example, if I have a bug in "foo" so I fail to send
> again, or I hit a breakpoint in "foo" and have to stop execution), and
> sometimes I want to be able to pause send messages, etc. Being able to just
> create an interval that responds well to various situations would be very
> desirable:
>
> send "foo" to me every 5 seconds ## done!
>
> suspend the result ## the message is paused temporarily
> resume the result ## the message will continue from where it left off
>
> Those few things would be very useful to me.
>
> Jeff M.
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
More information about the use-livecode
mailing list