Thread model and error handling cleanup #30

Merged
savanni merged 3 commits from refactoring/music-tokio into main 2023-03-11 20:15:47 +00:00
Owner

Here I'm cleaning up the thread model and the error handling.

Error handling was pretty straightforward. I am making a better effort to propogate error conditions and then provide them in the API, when appropriate. Additionally, the client library is now able to handle them when they arrive, although it does nothing beyond printing the error message to the console.

The thread model is more complicated. I'm trying to reduce the complexity that I was creating by delegating things to Tokio, but it turns out that doesn't make sense in most cases. So, now, the core is not a thread at all. Instead it keeps a handle to the scanner thread. That thread is still a standard thread, as it is not asynchronous and is intended to run every minute until the application is shut down.

Playback, however, is now a tokio task. Core will keep hold of a playback controller, which manages that task. The controller will be instantiated for a track. When a new track starts playing, or a stop request arrives, the Core will tell the controller to abort the task before starting to play a new one.

Resolves:

Here I'm cleaning up the thread model and the error handling. Error handling was pretty straightforward. I am making a better effort to propogate error conditions and then provide them in the API, when appropriate. Additionally, the client library is now able to handle them when they arrive, although it does nothing beyond printing the error message to the console. The thread model is more complicated. I'm trying to reduce the complexity that I was creating by delegating things to Tokio, but it turns out that doesn't make sense in most cases. So, now, the core is not a thread at all. Instead it keeps a handle to the scanner thread. That thread is still a standard thread, as it is not asynchronous and is intended to run every minute until the application is shut down. Playback, however, is now a tokio task. Core will keep hold of a playback controller, which manages that task. The controller will be instantiated for a track. When a new track starts playing, or a stop request arrives, the Core will tell the controller to abort the task before starting to play a new one. Resolves: - [Switch from threads to tokio tasks](https://www.pivotaltracker.com/story/show/184663065)
savanni added 1 commit 2023-03-11 20:13:17 +00:00
savanni force-pushed refactoring/music-tokio from 4f47bcd9c3 to 40cce7ce00 2023-03-11 20:15:24 +00:00 Compare
savanni merged commit 40cce7ce00 into main 2023-03-11 20:15:47 +00:00
savanni deleted branch refactoring/music-tokio 2023-03-11 20:15:48 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: savanni/monorepo#30
No description provided.