The Lock Class
When writing concurrent code in Raku, we want to avoid sharing data between
tasks. This is because code that shares no data is automatically safe and
doesn’t have to worry about interdependencies with other code. So, when you can,
you should do your work through Supply, Promise, and Channel objects that
are then synchronized together by a central thread. That way, all the state
changes are safe.
This is not always practical, though. Sometimes it really is more efficient to share data that can change between tasks running on separate threads. However, such sharing is inherently unsafe.