Hacker News new | ask | show | jobs
by Twey 92 days ago
The operations are atomic because of the single-threaded nature of actors. But the operations can be arbitrarily ordered, except for the pairwise ordering constraint (which mirrors the happens-before relation on memory within a thread). If your memory actor has operations like ‘read address’ and ‘write address’ then yes, you precisely get the behaviour we enjoy from shared memory: if you read one address A then address B someone might have changed both of them in the meantime, and if you write A then read it back it might have been changed in the meantime.

The difference is that you're not limited to just ‘read address’ and ‘write address’ operations: the shared actor gets to define higher-level operations that are atomic over larger sections of code.

1 comments

tbh I think "concurrently shared memory that has no data races" is pretty significantly different from practically every other example of shared memory out there. you'll get Mem's behavior in single threaded async system with immutable data (because another actor can't mutate the data you've already received), but I can't think of anything else. that misses on both concurrency and "shared memory" since it's not actually shared. it's shared-readable or something along those lines.