Re:Asynchronous Programming in Python: Asyncio
by bullen on Monday May 01, 2017 @04:38PM
(#14241325)
Can goroutines run on separate cores? Because I'm pretty sure go explicitly decided to not share memory between threads because google thinks async. is too hard to understand for programmers...
[ Parent
| on HN ]
Re:Asynchronous Programming in Python: Asyncio
by geoka9 on Monday May 01, 2017 @05:17PM
(#14241728)
You probably mean channels - yes they let you avoid dealing with synchronization of shared memory access explicitly, but they still use mutexes underneath, so you can use those directly if you want (instead of/along with channels).
Re:Asynchronous Programming in Python: Asyncio
by fzzzy on Tuesday May 02, 2017 @07:31AM
(#14245504)
Yes, goroutines run on separate cores. Go uses an M:N threading model. goroutines (M) which are ready to run are scheduled on a thread pool of POSIX threads (N) which I believe is sized to match the number of cores in the processor. Nothing stops those goroutines from racing on shared memory. However, there is a convention that before accessing some shared memory, goroutines synchronize themselves using channels. ("Do not communicate by sharing memory; instead, share memory by communicating.")