Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Less locks, more atomics #17

Open
hinto-janai opened this issue Jun 24, 2023 · 1 comment
Open

Less locks, more atomics #17

hinto-janai opened this issue Jun 24, 2023 · 1 comment
Labels
shukusai Internals (shukusai) related someday This will be implemented... someday

Comments

@hinto-janai
Copy link
Owner

What

There are some key global data structures that have static lifetime.

E.g, AUDIO_STATE, RESET_STATE.

Atomics are simpler, easier to use, more performant, and won't ever deadlock.

Although these global structures aren't fully compatible with atomics, and there will be data races if the whole structure isn't updated atomically, e.g:

  • GUI requests to clear queue and stop playback
  • Audio clears AUDIO_STATE's` queue
  • GUI reads AUDIO_STATE, empty queue but still playing?
  • Audio sets playing to false

The whole struct should be updated at once before any other thread can read it as a whole.

Todo

Either shard the current structures in a well defined way, or use something like AtomicCell.

@hinto-janai hinto-janai added post v1.0.0 shukusai Internals (shukusai) related labels Jun 24, 2023
@hinto-janai hinto-janai mentioned this issue Jun 24, 2023
Closed
@hinto-janai hinto-janai added Before Next Major someday This will be implemented... someday and removed Before Next Major labels Jul 13, 2023
@hinto-janai
Copy link
Owner Author

https://github.com/hinto-janai/someday is the main data sharing primitive in https://github.com/hinto-janai/sansan (which will eventually replace shukusai/src/audio).

It uses lock-free MVCC, and atomically updates the entire structure at once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
shukusai Internals (shukusai) related someday This will be implemented... someday
Projects
None yet
Development

No branches or pull requests

1 participant