Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: timers in Core would be enough imo :-) (was) Re: Re: REBOL multithr

From: petr:krenzelok:trz:cz at: 15-Feb-2002 10:06

Romano Paolo Tenca wrote:
> Hi, Petr > > > And face based mechanism actually can't be used in Core and Command - they > > both don't have face compositing engine. I don't remember correctly, if > > someone from RT already commented this here or not in the past .... it > > would be probably good to have general timers to move into Core language > > ....It would not be much of a problem to implement some kind of make-task > > then. We need either general timer! datatype, or just some kind of > > configurable scheme (open [scheme: 'timer rate: 0.001 awake: my-func]). > > Such port would then be put then in wait-list .... > > I do not think that multitasking can be easily done in Rebol for a reason: i > could be wrong, but if you make a dispatch in the middle of a function and two > tasks are executing the same function, the function's locals will be > corrupted, because both the context and the function body would be shared > between tasks. First, you must save locals of every functions (tree of calls), > second you must rebind every body at every switch. An alternative is to use > functions which duplicate their own bodies at every call, like Ladislav's > e-func (if I remember well) else I think that the overhead would be too big > for > save+binding.
What about following? - kind of a state machine we can get with tcp communication: timer1: open [ scheme: 'timer rate: 0.01 locked: false awake: my-func par1 par2 ] my-func: func [par1 par2][ timer1/locked: true do-some-code timer1/locked: false ] insert wait-list timer1 So, my-func would be called only when timer1 would be in unlocked state, but still the timer could be checked each 0.01 period. It would allow us to run some background processing tasks ... But, I can be wrong here :-) Cheers, -pekr-