cdepillabout / cdepillabout/break-time
switch from threads and channels to an actor model for concurrency (and fix horrible code)
- Dominant language
- Rust
- Stars
- 22
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
Some of the break-time code is really horrible. There are a mess of thread-based state machines, all communicating over [mpsc channels](https://doc.rust-lang.org/std/sync/mpsc/fn.channel.html).
Here are the main state machines:
- https://github.com/cdepillabout/break-time/blob/6bad134cf96089ebd0ee372412d83d896b9f8633/src/scheduler/idle_detector.rs#L47-L100
- https://github.com/cdepillabout/break-time/blob/6bad134cf96089ebd0ee372412d83d896b9f8633/src/scheduler.rs#L141-L254
- https://github.com/cdepillabout/break-time/blob/6bad134cf96089ebd0ee372412d83d896b9f8633/src/lib.rs#L31-L67
It would be great to refactor this code to not be so horrible.
One of the main problems I had is that there are some types that can't easily be passed between threads, including handles for connecting to Google Calendar, and connection handles for X. Ideally, the code that handles both of these tasks would have their own threads.
I'm not sure the best solution to all these problems, but I was thinking that instead of using threads and channels for concurrency and communication, it would be easier to use some sort of service-oriented actor model, where each state machine would be it's own actor, as well as the parts of the code that can't be passed between threads.
Testing and simplifying all of the state-transitions would also be very helpful. There are probably some state transitions that don't make any sense, yet are still possible in the current code.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.