1. Coroutines in Euphoria
- Posted by euphoric (admin) May 20, 2015
- 1490 views
Could the OpenEuphoria programming language benefit from coroutine functionality?
2. Re: Coroutines in Euphoria
- Posted by jimcbrown (admin) May 20, 2015
- 1474 views
Could the OpenEuphoria programming language benefit from coroutine functionality?
I certainly think so.
3. Re: Coroutines in Euphoria
- Posted by bugmagnet May 21, 2015
- 1453 views
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
4. Re: Coroutines in Euphoria
- Posted by irv May 21, 2015
- 1421 views
Can someone explain in Euphoric terms the difference between coroutines and Eu's task functions?
5. Re: Coroutines in Euphoria
- Posted by jmduro May 21, 2015
- 1427 views
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).
6. Re: Coroutines in Euphoria
- Posted by jimcbrown (admin) May 21, 2015
- 1447 views
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
7. Re: Coroutines in Euphoria
- Posted by irv May 21, 2015
- 1410 views
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?
8. Re: Coroutines in Euphoria
- Posted by jimcbrown (admin) May 21, 2015
- 1414 views
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.
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.