Lightweight threading / task system impl. questions
[1/2] from: m::koopmans2::chello::nl at: 1-Feb-2002 10:13
Hi All,
In my rewrite o Rugby I am cuurently incorporating a "task" system. It works
like a queue of code blocks of which one is executed when there is no IO for
a certain time.
This may be very useful for others as well, so.... I would like to expose
that set in a programmer-friendly way. Normally you'd have interruptable
threads with a certain state associated, and you would have to be sure that
your IO does not block athread (i.e. prevent it from receiving an interupt).
In a functional-style eavluator you'd have to count reductions (and weight
them), which is hard with natives....
My current way would be to implement task that executes a certain set of
code and hands control back to the Rebol process itself.
Something like:
task [signature]
[
some-code ;
suspend;
some-other code;
suspend;
label demo;
some-code
suspend/on-return demo
]
The suspend would put you back in the queue (with state preserved).
suspend/on-return with the label will allow for repetetive code blocks in a
task. The drawback is obvious: you have to think about how to partition your
code in a task. OTOH, you *are* in control.
I would typically add a few non-blocking IO operations, such as fetch-web,
fetch-file etc. that you could use in your tasks to make sure that IO
doesn't hang-up a task.
My questions:
- Is this workable?
- what IO operations should be available at least?
- what other blocking operations can you think of?
As this is a side effect of Rugby the task system will be there. Depending
on the feedback and usefullness it will be visible.
--Maarten
[2/2] from: robert:muench:robertmuench at: 1-Feb-2002 15:06
> -----Original Message-----
> From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]On Behalf Of
<<quoted lines omitted: 5>>
> like a queue of code blocks of which one is executed when there is no IO for
> a certain time.
Hi Maarten, you might want to have a look at the state-machine-based
multitasking system used in the Xitami www-server (http://www.xitami.com) The
task-system is available as a seperate library with docs. Robert
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted