1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-22 12:33:29 +00:00

Avoid the whole thread hop for a zero-length run_for.

This commit is contained in:
Thomas Harte 2022-07-13 15:05:34 -04:00
parent 10108303e7
commit 75f3f1a77f

View File

@ -368,6 +368,10 @@ template <typename SampleSource> class PullLowpass: public LowpassBase<PullLowpa
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(Concurrency::DeferringAsyncTaskQueue &queue, const Cycles cycles) { void run_for(Concurrency::DeferringAsyncTaskQueue &queue, const Cycles cycles) {
if(cycles == Cycles(0)) {
return;
}
queue.defer([this, cycles] { queue.defer([this, cycles] {
run_for(cycles); run_for(cycles);
}); });
@ -383,10 +387,7 @@ template <typename SampleSource> class PullLowpass: public LowpassBase<PullLowpa
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) {
std::size_t cycles_remaining = size_t(cycles.as_integral()); process(size_t(cycles.as_integral()));
if(!cycles_remaining) return;
process(cycles_remaining);
} }
SampleSource &sample_source_; SampleSource &sample_source_;