Hacker News new | past | comments | ask | show | jobs | submit login

> Real preemptive threads it seems (as opposed to Go’s goroutines which are cooperative threads/coroutines).

Go's goroutines are preemptive.




> Go's goroutines are preemptive.

Not quite. Since 1.2, goroutines can yield on non-inlined function calls (in 1.1 it happens only on IO or on an explicit Gosched() call). A goroutine with no funcall or only inlined function calls will still block the scheduler (and the whole system if there's only one scheduler).


This tends not to be an issue in practice as you almost always have non-inlined function calls or short-executing loops. The one way in which this might be a problem is if you try and implement a spinlock, but there is no excuse for that given the go concurrency features.


> This tends not to be an issue in practice as you almost always have non-inlined function calls or short-executing loops.

Until it's an issue because somebody set up CPU-bound image processing, and then by lying you've set people up for failure and you've given them a huge blind spot once things start not working correctly.


Good point. It was a shortcut that I shouldn't have taken.


You're right, it's generally not an issue. Acting like Goroutines are preemptive isn't likely to land you in a lot of trouble.

Nevertheless, they aren't preemptive, so you shouldn't say that they are. Maybe "almost preemptive"?


:) I like that phrasing, it gets to the main result (you shouldnt ever worry about it) while still giving you the out that more leaks under the covers (in case you think this might be biting you.)


If you use libgreen in Rust, you don't even have the preemption at function calls, and it works OK. I agree that this isn't much of an issue in practice.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: