๐Ÿ’ฌ Reply by r00ty

2024-11-16 ๐Ÿ”„ programmerhumor โ”ƒ RE: 2xsaiko

The bingo one actually uses crossbeam channels instead of mutexes, so thatโ€™s nice. I havenโ€™t looked too closely at it though.
The C# original uses the equivalent of read/write locks. But I found it problematic to work the same way in rust and then discovered the communication option was far easier to implement and actually avoids holding up threads. So went with that. Much easier and much faster in execution I think.
I donโ€™t think you can do too much about the Spectrum one if you want to keep the two threads, but hereโ€™s what I would change related to thread synchronization. Lemmy doesnโ€™t seem to allow me to attach patch files for whatever reason so have an archive insteadโ€ฆ dblsaiko.net/pub/tmp/patches.tar.bz2 (I wrote a few notes in the commit messages)
In reality I'm never likely to remake the CPU project in rust. Firstly because I'd need to entirely re-engineer it because it's extensively using hierarchical classes, which just doesn't work the same way in rust. And I'm not sure traits would allow me to do things in even close to the same way. But if it were to work with a CPU emulator they need to share the memory, and also the CPU needs its own thread.
So basically itโ€™s channels indexed by channel number and name? That one is actually one of the easy cases. Store indices instead:
This was something I was thinking about the other evening. I needed to get the index to remove some other data anyway and wondered if I'd be better off having a master vector and usize lookups for that data store. It's one extra lookup, but by index it's the tiniest and the speed isn't a real issue anyway. It's replacing perl scripts pulling data from mysql. It couldn't possibly run slower than that :P
Thanks for the commentary though and I think I'm going to make the changes to use indices to lookup data. I wanted to re-order the way things are done a bit anyway. The problem I see potentially is that the lookups probably need to be regenerated every time I delete something. But actually I think that since it is rebuilt from a file on load. Maybe I just remove the items from the lookups and leave them in the vector. Since next run they would be gone anyway.

r00ty

https://kbin.life/m/programmerhumor@lemmy.ml/t/287977/-/comment/4190130

2xsaiko

๐Ÿ”„ programmerhumor

๐Ÿ’ฌ Replies

No replies.

โ”€โ”€โ”€โ”€

View parent post

View first post in thread

โ”€โ”€โ”€โ”€

๐Ÿ“ก Local feed

๐Ÿ•๏ธ Communities

๐Ÿ”ฅ Hashtags

๐Ÿ”Ž Search posts

๐Ÿ”‘ Sign in

๐Ÿ“Š Status

๐Ÿ›Ÿ Help