logoalt Hacker News

the__alchemisttoday at 3:10 PM1 replyview on HN

It is interesting to see the different patterns used due to different cases and tastes. For example, my concurrency patterns rarely use locks, and are instead usually one of:

  - Dedicated hardware via DMA, multiple cores/MCUs etc
  - Thread pools (e.g rayon)
  - GPU
  - SIMD
  - Atomics
  - Interrupts and their ISRs
  - Event loops
  - std::sync Thread and MPSC (My Std rust default for not blocking the GUI etc)

Replies

surajrmaltoday at 4:11 PM

Most of it comes down to avoiding shared data. Unfortunately it requires forethought to do that well. There are also many cases where you do want to share data for optimal performance as other options are ultimately too heavyweight.

Also worth noting that an event loop by itself doesn't give you serialization by itself, it can just allow you to gain concurrency without parallelism. You still need some form of serialization by way of something like actors (or async locks).