Re: Someone changed my Thread Manager writeup?
- Posted by Al Getz <Xaxo at aol.com> Aug 12, 2005
- 554 views
Pete Lomax wrote: > > On Wed, 10 Aug 2005 07:10:31 -0700, Matt Lewis > <guest at RapidEuphoria.com> wrote: > > <snip> > I have to agree with Matt on this. The main thing I would say here is > that if Rob offers something like this in 2.6, I'll not be happy. I > certainly don't want him to start thinking that now Al Getz's "Thread > Manager" is in the archives, I don't have to bother. > > >Al Getz wrote: > >BTW, what single word name would you use to describe these pseudo 'threads'? > "Background task manager", basically a time()-based wrapper around > doEvents() (or the WinClass equivalent). Multiple background tasks can > be started, but the last one started must complete before any previous > can resume. In particular, blocked I/O (still) stalls the entire app. > > >It does in fact use: > >"Preemptive Multitasking" > >ie uses some criteria to decide how long any one task should run > >before giving another task a turn to use the operating system. > No, it does not. At best you might claim it is "Dualtasking", between > the top of the background task stack and the GUI message loop, but > *Multi* tasking is just downright misleading. > > >I guess i could add a scheduling mechanism if that would make more > >people happy :) > I'd be very surprised if you could. > > >I really think you should try a few applications using this kind of > >technique before you pass judgement. > I don't need to, since I already know how to call doEvents()) > > >Note that if thread 2 is almost done when thread 3 is initiated, > >after thread 3 is complete thread 2 completes rather quickly > >because it's almost done. > Which begs the question: Why bother with a stack of time() values? > Why not just have a single atom? > > Some other notes: > There should be a built-in single procedure call for: > }}} <eucode> > if CheckThread() then > if QueryQuitMessage(0) then > end if > ContinueThread(TimeSlice) > end if > <font color="#330033"></eucode> {{{ </font> > rather than having to code the whole of that in every task loop. > > Here is the win32lib equivalent: > }}} <eucode> > atom TimeSlice > atom EndSlice > > global procedure StartThread(atom t) > TimeSlice = t > EndSlice=time()+TimeSlice > end procedure > > global procedure CheckThread() > if time()>EndSlice then > EndSlice=time()+TimeSlice > doEvents(0) > end if > end procedure > <font color="#330033"></eucode> {{{ </font> > > Regards, > Pete > > Hello Pete, Sorry, i just dont feel like arguing about this anymore. It's in the archives -- download it and try it, or assume you know what it does and dont. Take care, Al And, good luck with your Euphoria programming! My bumper sticker: "I brake for LED's"