1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00

Gets explicit that the delegate_ doesn't need a memory barrier.

This commit is contained in:
Thomas Harte 2020-07-31 18:20:35 -04:00
parent f34a9b4346
commit 7b1708f0bc
2 changed files with 3 additions and 3 deletions

View File

@ -131,7 +131,7 @@ template <typename SampleSource> class LowpassSpeaker: public Speaker {
at construction, filtering it and passing it on to the speaker's delegate if there is one. at construction, filtering it and passing it on to the speaker's delegate if there is one.
*/ */
void run_for(const Cycles cycles) { void run_for(const Cycles cycles) {
const auto delegate = delegate_.load(); const auto delegate = delegate_.load(std::memory_order::memory_order_relaxed);
if(!delegate) return; if(!delegate) return;
const int scale = get_scale(); const int scale = get_scale();

View File

@ -89,7 +89,7 @@ class Speaker {
virtual void speaker_did_change_input_clock([[maybe_unused]] Speaker *speaker) {} virtual void speaker_did_change_input_clock([[maybe_unused]] Speaker *speaker) {}
}; };
virtual void set_delegate(Delegate *delegate) { virtual void set_delegate(Delegate *delegate) {
delegate_ = delegate; delegate_.store(delegate, std::memory_order::memory_order_relaxed);
} }
@ -99,7 +99,7 @@ class Speaker {
protected: protected:
void did_complete_samples(Speaker *, const std::vector<int16_t> &buffer, bool is_stereo) { void did_complete_samples(Speaker *, const std::vector<int16_t> &buffer, bool is_stereo) {
// Test the delegate for existence again, as it may have changed. // Test the delegate for existence again, as it may have changed.
const auto delegate = delegate_.load(); const auto delegate = delegate_.load(std::memory_order::memory_order_relaxed);
if(!delegate) return; if(!delegate) return;
++completed_sample_sets_; ++completed_sample_sets_;