3 ms·
Erlang processes (Actors) solve this kind of problem naturally, with code that is concise, asynchronous and parallelized. For example, look at solutions for 'Sl
by mikhailfranco 6y ago
Erlang processes (Actors) solve this kind of problem naturally, with code that is concise, asynchronous and parallelized. For example, look at solutions for 'Sleeping Barber'. It's possible to write a full solution in <40 SLOC.
Starting 1000 processes is trivial and fast in Erlang. See the first few pages of Joe's presentation from 20 years ago: process creation time ~10us (up to 30k processes); message time ~1us [1]. The code is in his book and the email thread [2]:
[1] https://www.rabbitmq.com/resources/armstrong.pdf https://www.rabbitmq.com/resources/armstrong.pdf
[2] https://erlang.org/pipermail/erlang-questions/2007-July/028068.html https://erlang.org/pipermail/erlang-questions/2007-July/0280...
- neilwilson 6y agoIt’s rather more tricky than the sleeping barber. It’s more that their are 100 hairdressers, each household has a set of seven of them and each hairdresser only has a fixed amount of hair colour so not everybody will be served, and you need to be able to repeat the visits deterministically based on a random seed so the only whole process is verifiable.