25 ms·
> Async Ruby is similar to Go's goroutine model. Goroutines are just (lightweight) threads - they can run in parallel. You need locks whenever you access share
by pansa2 5y ago
> Async Ruby is similar to Go's goroutine model.
Goroutines are just (lightweight) threads - they can run in parallel. You need locks whenever you access shared data.
AFAIK Ruby’s fibers are cooperatively scheduled and can only yield at function calls. Code that doesn’t make a function call (e.g. incrementing an integer) is safe to run on multiple fibers without locks.
For comparison, Python’s stackless coroutines can safely do anything except `await` without requiring locks.