1. Coroutines in Euphoria

Could the OpenEuphoria programming language benefit from coroutine functionality?

new topic     » topic index » view message » categorize

2. Re: Coroutines in Euphoria

euphoric said...

Could the OpenEuphoria programming language benefit from coroutine functionality?

I certainly think so.

new topic     » goto parent     » topic index » view message » categorize

3. Re: Coroutines in Euphoria

Like running in different cores at the same time? In Windows, changing the affinity of processes or threads? Wow, that'd be cool!

http://stackoverflow.com/questions/164026/on-win32-how-do-you-move-a-thread-to-another-cpu-core https://msdn.microsoft.com/en-us/library/windows/desktop/ms686223(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms686247%28v=vs.85%29.aspx

bugmagnet

new topic     » goto parent     » topic index » view message » categorize

4. Re: Coroutines in Euphoria

Can someone explain in Euphoric terms the difference between coroutines and Eu's task functions?

new topic     » goto parent     » topic index » view message » categorize

5. Re: Coroutines in Euphoria

I don't see any. Maybe he was thinking about real multitasking when a subroutine has called another one which does not return and you need to interrupt the caller routine (asynchronous mode).

new topic     » goto parent     » topic index » view message » categorize

6. Re: Coroutines in Euphoria

irv said...

Can someone explain in Euphoric terms the difference between coroutines and Eu's task functions?

Tasks are a sort of cooperative multitasking thread system, like the old Java green threads. A co-routine is like a super flexible sub-routine, where instead of having a single entry and exit point from callee to caller, you can have multiple entry points into a co-routine and the co-routine can decide how it wants to return.

The key difference between a non-preemptive cooperative thread system (like EU's tasks) and a co-routine is that for threads (or tasks), there's a builtin scheduler that decides when to stop one thread and switch over to the next. The thread often has very little control in how this decision is made and can only give hints like 'yield'. However, with a co-orutine, the coder decides how and when control is passed over and passed back.

Also, unlike threads, co-orutines are never trully parallel/pre-emptive.

http://stackoverflow.com/questions/1934715/difference-between-a-coroutine-and-a-thread

new topic     » goto parent     » topic index » view message » categorize

7. Re: Coroutines in Euphoria

So, a coroutine would be somewhere between a Eu task and real threaded execution? If Eu actually had threads, would there be a need for coroutines?

new topic     » goto parent     » topic index » view message » categorize

8. Re: Coroutines in Euphoria

irv said...

So, a coroutine would be somewhere between a Eu task and real threaded execution?

No, it's that an Eu task is somewhere between a coroutine and real threaded (preemptive and concurrent/parallel execution) execution. One could even argue that Eu tasks/Java green threads et al are attempts to simulate threading by using coroutines.

irv said...

If Eu actually had threads, would there be a need for coroutines?

Yes, they do different things and serve different purposes. co-routines always execute within the same thread, for example.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu