ok I now have a working implementation of advent of code 2019/07 in rust, using concurrent VMs communicating via mpsc
-
Show this thread
-
I'm really happy with the interface I've got working here, for example: here is a Machine (the VM) taking a &mut Vec<T> is its input and a &mut T as its output -- it uses the inputs once each and writes every output to the same locationhttps://gist.github.com/jcoglan/f82d9ebff6a6b6d5d9eb72ae35707ad6#file-day_7-rs-L17-L19 …
1 reply 0 retweets 0 likesShow this thread -
this is the meat of part 2, setting up a chain of machines that send signals between each other in a ring:https://gist.github.com/jcoglan/f82d9ebff6a6b6d5d9eb72ae35707ad6#file-day_7-rs-L38-L69 …
1 reply 0 retweets 0 likesShow this thread -
especially fun is this bit: https://gist.github.com/jcoglan/f82d9ebff6a6b6d5d9eb72ae35707ad6#file-day_7-rs-L44-L50 … this machine has a mpsc::Receiver as its input, and something called a "demux" of mpsc::Sender and a &mut T as its output
1 reply 0 retweets 1 likeShow this thread -
what's a demux? short for "demultiplexer", it's an Output that sends what it receives to two other Outputs:https://gist.github.com/jcoglan/f82d9ebff6a6b6d5d9eb72ae35707ad6#file-intcode-rs-L152-L162 …
1 reply 1 retweet 2 likesShow this thread -
that means it can send each output signal to an mpsc::Sender, so it gets routed to the machine holding the corresponding Receiver, *and* it gets copied into `last_value` so we can capture the last emitted output and return it
2 replies 0 retweets 0 likesShow this thread -
Replying to @mountain_ghosts
Uhh somehow like over half of this thread is unavailable in at least Spain?pic.twitter.com/KoHg8MJaXQ
2 replies 0 retweets 0 likes -
-
Add Italy to the bunch.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
Writing about stuff to learn how it works, mostly in Rust.
Lead Engineer at