Re: concept from Io language

new topic     » goto parent     » topic index » view thread      » older message » newer message
PL said...

Hello, I discovered euphoria sometime ago and find it interesting (specially, due to speed, co-routines, ...)

Concerning co-routines, I found a nice concept in language Io.

From the Io Docs:

Io uses coroutines (user level cooperative threads), instead of preemptive OS level threads to implement concurrency. This avoids the substantial costs (memory, system calls, locking, caching issues, etc) associated with native threads and allows Io to support a very high level of concurrency with thousands of active threads.

So it looks like at least superficially, we have this in the form of multi-tasking

PL said...

Let's give a small example:

V1 := O1 M1 

This line execute method "M1" of object O1 and put result in variable V1. Nothing special ...

V1 := O1 @M1 

Do the same but, - create a "future" (a special object) V1 - create a co-routine to execute the method asynchronously - when method is ended, V1 become an variable and get result of method

During execution of method, - the program can continue - If you try to access V1 (ex: V2 := V1 ...), program block untill M1 is finished. - You can of course check if M1 is finished

Future plans for euphoria include the possibility of coroutines, generators and iterators, so this basic idea should happen at some point.

PL said...

You can for example, do sth like:

V1 := URL with("http://example1.com/") @fetch 
V2 := URL with("http://example2.com/") @fetch 
V3 := URL with("http://example3.com/") @fetch 
. . . 
do sth with V1 , V2 , V3 
[snip]

Could that be implemented in euphoria ?

I think the above paradigm could probably be done with the current multitasking API, though I haven't worked with it enough to say how well it would suit what you're describing.

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu