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

Merge pull request #755 from TomHarte/ExpliticLambdas

Tries to be less lazy with lambda captures.
This commit is contained in:
Thomas Harte 2020-02-15 12:38:12 -05:00 committed by GitHub
commit dde672701f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 26 additions and 27 deletions

View File

@ -72,7 +72,7 @@ Outputs::Speaker::Speaker *MultiCRTMachine::get_speaker() {
}
void MultiCRTMachine::run_for(Time::Seconds duration) {
perform_parallel([=](::CRTMachine::Machine *machine) {
perform_parallel([duration](::CRTMachine::Machine *machine) {
if(machine->get_confidence() >= 0.01f) machine->run_for(duration);
});
@ -82,7 +82,7 @@ void MultiCRTMachine::run_for(Time::Seconds duration) {
void MultiCRTMachine::did_change_machine_order() {
if(scan_target_) scan_target_->will_change_owner();
perform_serial([=](::CRTMachine::Machine *machine) {
perform_serial([](::CRTMachine::Machine *machine) {
machine->set_scan_target(nullptr);
});
CRTMachine::Machine *const crt_machine = machines_.front()->crt_machine();

View File

@ -17,13 +17,13 @@ AudioGenerator::AudioGenerator(Concurrency::DeferringAsyncTaskQueue &audio_queue
void AudioGenerator::set_volume(uint8_t volume) {
audio_queue_.defer([=]() {
volume_ = static_cast<int16_t>(volume) * range_multiplier_;
audio_queue_.defer([this, volume]() {
volume_ = int16_t(volume) * range_multiplier_;
});
}
void AudioGenerator::set_control(int channel, uint8_t value) {
audio_queue_.defer([=]() {
audio_queue_.defer([this, channel, value]() {
control_registers_[channel] = value;
});
}

View File

@ -216,8 +216,7 @@ void AY38910::set_register_value(uint8_t value) {
// If this is a register that affects audio output, enqueue a mutation onto the
// audio generation thread.
if(selected_register_ < 14) {
const int selected_register = selected_register_;
task_queue_.defer([=] () {
task_queue_.defer([this, selected_register = selected_register_, value] () {
// Perform any register-specific mutation to output generation.
uint8_t masked_value = value;
switch(selected_register) {

View File

@ -28,7 +28,7 @@ void Toggle::skip_samples(const std::size_t number_of_samples) {}
void Toggle::set_output(bool enabled) {
if(is_enabled_ == enabled) return;
is_enabled_ = enabled;
audio_queue_.defer([=] {
audio_queue_.defer([this, enabled] {
level_ = enabled ? volume_ : 0;
});
}

View File

@ -55,7 +55,7 @@ void SCC::write(uint16_t address, uint8_t value) {
address &= 0xff;
if(address < 0x80) ram_[address] = value;
task_queue_.defer([=] {
task_queue_.defer([this, address, value] {
// Check for a write into waveform memory.
if(address < 0x80) {
waves_[address >> 5].samples[address & 0x1f] = value;

View File

@ -60,7 +60,7 @@ void VideoBase::set_display_type(Outputs::Display::DisplayType display_type) {
*/
void VideoBase::set_alternative_character_set(bool alternative_character_set) {
set_alternative_character_set_ = alternative_character_set;
deferrer_.defer(Cycles(2), [=] {
deferrer_.defer(Cycles(2), [this, alternative_character_set] {
alternative_character_set_ = alternative_character_set;
if(alternative_character_set) {
character_zones[1].address_mask = 0xff;
@ -78,7 +78,7 @@ bool VideoBase::get_alternative_character_set() {
void VideoBase::set_80_columns(bool columns_80) {
set_columns_80_ = columns_80;
deferrer_.defer(Cycles(2), [=] {
deferrer_.defer(Cycles(2), [this, columns_80] {
columns_80_ = columns_80;
});
}
@ -105,7 +105,7 @@ bool VideoBase::get_page2() {
void VideoBase::set_text(bool text) {
set_text_ = text;
deferrer_.defer(Cycles(2), [=] {
deferrer_.defer(Cycles(2), [this, text] {
text_ = text;
});
}
@ -116,7 +116,7 @@ bool VideoBase::get_text() {
void VideoBase::set_mixed(bool mixed) {
set_mixed_ = mixed;
deferrer_.defer(Cycles(2), [=] {
deferrer_.defer(Cycles(2), [this, mixed] {
mixed_ = mixed;
});
}
@ -127,7 +127,7 @@ bool VideoBase::get_mixed() {
void VideoBase::set_high_resolution(bool high_resolution) {
set_high_resolution_ = high_resolution;
deferrer_.defer(Cycles(2), [=] {
deferrer_.defer(Cycles(2), [this, high_resolution] {
high_resolution_ = high_resolution;
});
}
@ -138,7 +138,7 @@ bool VideoBase::get_high_resolution() {
void VideoBase::set_annunciator_3(bool annunciator_3) {
set_annunciator_3_ = annunciator_3;
deferrer_.defer(Cycles(2), [=] {
deferrer_.defer(Cycles(2), [this, annunciator_3] {
annunciator_3_ = annunciator_3;
high_resolution_mask_ = annunciator_3_ ? 0x7f : 0xff;
});

View File

@ -262,7 +262,7 @@ template <class BusHandler, bool is_iie> class Video: public VideoBase {
public:
/// Constructs an instance of the video feed; a CRT is also created.
Video(BusHandler &bus_handler) :
VideoBase(is_iie, [=] (Cycles cycles) { advance(cycles); }),
VideoBase(is_iie, [this] (Cycles cycles) { advance(cycles); }),
bus_handler_(bus_handler) {}
/*!

View File

@ -35,7 +35,7 @@ void Audio::set_volume(int volume) {
posted_volume_ = volume;
// Post the volume change as a deferred event.
task_queue_.defer([=] () {
task_queue_.defer([this, volume] () {
volume_ = volume;
set_volume_multiplier();
});
@ -47,7 +47,7 @@ void Audio::set_enabled(bool on) {
posted_enable_mask_ = int(on);
// Post the enabled mask change as a deferred event.
task_queue_.defer([=] () {
task_queue_.defer([this, on] () {
enabled_mask_ = int(on);
set_volume_multiplier();
});

View File

@ -18,21 +18,21 @@ Atari2600::TIASound::TIASound(Concurrency::DeferringAsyncTaskQueue &audio_queue)
{}
void Atari2600::TIASound::set_volume(int channel, uint8_t volume) {
audio_queue_.defer([=]() {
volume_[channel] = volume & 0xf;
audio_queue_.defer([target = &volume_[channel], volume]() {
*target = volume & 0xf;
});
}
void Atari2600::TIASound::set_divider(int channel, uint8_t divider) {
audio_queue_.defer([=]() {
audio_queue_.defer([this, channel, divider]() {
divider_[channel] = divider & 0x1f;
divider_counter_[channel] = 0;
});
}
void Atari2600::TIASound::set_control(int channel, uint8_t control) {
audio_queue_.defer([=]() {
control_[channel] = control & 0xf;
audio_queue_.defer([target = &control_[channel], control]() {
*target = control & 0xf;
});
}

View File

@ -485,7 +485,7 @@ void Video::write(int address, uint16_t value) {
// Sync mode and pixel mode.
case 0x05:
// Writes to sync mode have a one-cycle delay in effect.
deferrer_.defer(HalfCycles(2), [=] {
deferrer_.defer(HalfCycles(2), [this, value] {
sync_mode_ = value;
update_output_mode();
});

View File

@ -36,13 +36,13 @@ void SoundGenerator::skip_samples(std::size_t number_of_samples) {
}
void SoundGenerator::set_divider(uint8_t divider) {
audio_queue_.defer([=]() {
audio_queue_.defer([this, divider]() {
divider_ = divider * 32 / clock_rate_divider;
});
}
void SoundGenerator::set_is_enabled(bool is_enabled) {
audio_queue_.defer([=]() {
audio_queue_.defer([this, is_enabled]() {
is_enabled_ = is_enabled;
counter_ = 0;
});

View File

@ -149,7 +149,7 @@
}
// Run the thing.
const auto comparitor = [=] {
const auto comparitor = [] {
// Test the end state.
NSDictionary *const finalState = test[@"final state"];
const auto state = test68000->processor.get_state();