Threads in Eu 2.5?

new topic     » topic index » view thread      » older message » newer message

I think threads are needed in Euphoria. The example below would be 
fairly easy to use. Many programs would benifit from this.
procedure new_thread(integer routine_id,sequence params,int priority)
new_thread() starts the thread and returns imediatly.

routine_id is the routine id for the procedure to run

params is "params must be a sequence of argument values of length n, 
where n is the number of arguments required by the procedure. If the 
procedure does not take any arguments then params should be {}."(copied 
from manual: call_proc)

priority is somthing like HIGH, LOW, NORMAL, ABOVENORMAL, ect


procedure a()
integer t
t=time()
for z=1 to 1000000+i do
--do something that takes a lot of time here
end for
?time()-t  --a fairly high number
end procedure

procedure b(integer i)
integer t
t=time()
for z=1 to 1000000+i do
--do something that takes a lot of time here
end for
?time()-t  --a fairly high number
end procedure

integer tt
tt=time()
new_thread(routine_id("a"),{},ABOVENORMAL)
new_thread(routine_id("b"),{rand(10)},LOW)
?time()-tt  --would display a number near 0 because new_thread() returns 
imediatly

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu