Originally posted by dev_null
View Post
Announcement
Collapse
No announcement yet.
GCC 11 Enables Co-Routines Support In C++20 Mode
Collapse
X
-
Originally posted by dev_null View PostThanks!. Looks like it won't work on Linux at full power though, and most likely won't work at gcc-10 without some adoption.
Comment
-
Originally posted by pal666 View Postcoroutines have nothing to do with threads, they are syntactic sugar for callbacks(single threaded). they don't run concurrently and do not require synchronization, which has impact on reasoning and on execution
- Likes 2
Comment
-
The defining characteristic of co-routines is a voluntary yield() call that passes control to the next co-routine (or a dispatch function). After the other co-routine finishes its work and yields, control is returned back to this function after its yield() call. This is usually in a tight loop.
Threads are preemptively scheduled and do not need to yield.
- Likes 1
Comment
-
Originally posted by Mark625 View PostThe defining characteristic of co-routines is a voluntary yield() call that passes control to the next co-routine (or a dispatch function). After the other co-routine finishes its work and yields, control is returned back to this function after its yield() call. This is usually in a tight loop.
Threads are preemptively scheduled and do not need to yield.
I will always remember what a teacher (RIP) taught us in college: when you feel the need to yield(), take a step back and look at the bigger picture - there's a problem somewhere. A simple piece of advice that has kept me out of trouble for almost two decades now.
Of course, outside of this particular peculiarity, was you wrote is spot-on. I also don't know whether, like in the traditional cooperative multitasking case, when one coroutine doesn't play ball, it messes with the other coroutines on the same thread.
- Likes 1
Comment
-
Originally posted by bug77 View Post
And yet, the Thread class in Java has a yield() method
I will always remember what a teacher (RIP) taught us in college: when you feel the need to yield(), take a step back and look at the bigger picture - there's a problem somewhere. A simple piece of advice that has kept me out of trouble for almost two decades now.
Of course, outside of this particular peculiarity, was you wrote is spot-on. I also don't know whether, like in the traditional cooperative multitasking case, when one coroutine doesn't play ball, it messes with the other coroutines on the same thread.
Yield in real threads is always a mistake because it indicates that the programmer doesn't know what their thread is supposed to be doing. If it is supposed to run, then run. If it is supposed to be waiting on some event, then wait on that event. If it is low priority then set a low thread priority. Not this, Oh I might be using too much time so I should see if some other thread wants to butt in.
Comment
-
Originally posted by Zan Lynx View Post
co-routines and other types of async / await programming rely on yield. Otherwise there would be nothing concurrent about it.
Yield in real threads is always a mistake because it indicates that the programmer doesn't know what their thread is supposed to be doing. If it is supposed to run, then run. If it is supposed to be waiting on some event, then wait on that event. If it is low priority then set a low thread priority. Not this, Oh I might be using too much time so I should see if some other thread wants to butt in.
I was just saying, when things are so clear cut, along comes Java and adds yield() to Thread. I'm sure many beginners fell for that.
- Likes 1
Comment
-
Originally posted by bug77 View Post
Yes, I know all that.
I was just saying, when things are so clear cut, along comes Java and adds yield() to Thread. I'm sure many beginners fell for that.
Luckily "the whole system" was just your own PC, but still.
- Likes 1
Comment
-
Originally posted by pal666 View Poststackful and stackless both have their pros and cons, it's good to have both(or something combined, and there was an effort to combine them, but it wasn't successful yet)
microsoft was impatient because they need them for their api
Fibers under the magnifying glass by Gor Nishanov
Originally posted by pal666 View Postcoroutines have nothing to do with threads, they are syntactic sugar for callbacks(single threaded). they don't run concurrently and do not require synchronization, which has impact on reasoning and on executionLast edited by ssokolow; 19 May 2020, 07:38 PM.
- Likes 2
Comment
-
Originally posted by Mark625 View Post
Of course you haven't really had fun until you've programmed on a system with preemptive multitasking and no memory protection between the different processes or the OS. That'll put hair on your chest! And gray hair on your head. One bad pointer and Boom!, down goes the whole system.
Luckily "the whole system" was just your own PC, but still.
I liked doing UIs and presenting stuff. Of course, I ended up mostly as a back-end developer :P Plenty of threads to mess up there, too, but since I'm not doing C/C++, they're the tamer variety.
Comment
Comment