Threads in Eu 2.5?
- Posted by CoJaBo <cojabo at suscom.net> Jan 25, 2004
- 405 views
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