void Step:: finishTask(Step::ptr step, int taskid, pBuffer result) { Interval result_interval; if (result) result_interval = result->getInterval (); TASKINFO TaskInfo ti(format("Step::finishTask %2% on %1%") % step.raw ()->operation_name() % result_interval); if (result) { // Result must have the same number of channels and sample rate as previous cache. // Call deprecateCache(Interval::Interval_ALL) to erase the cache when chainging number of channels or sample rate. step.raw ()->cache_->put (result); } auto self = step.write (); int matched_task = self->running_tasks.count (taskid); if (1 != matched_task) { Log("C = %d, taskid = %x on %s") % matched_task % taskid % self->operation_name (); EXCEPTION_ASSERT_EQUALS( 1, matched_task ); } Intervals expected_output = self->running_tasks[ taskid ]; Intervals update_miss = expected_output - result_interval; self->not_started_ |= update_miss; if (!result) { TASKINFO TaskInfo(format("The task was cancelled. Restoring %1% for %2%") % update_miss % self->operation_name()); } else { if (update_miss) { TaskInfo(format("These samples were supposed to be updated by the task but missed: %1% by %2%") % update_miss % self->operation_name()); } if (result_interval - expected_output) { // These samples were not supposed to be updated by the task but were calculated anyway TaskInfo(format("Unexpected extras: %1% = (%2%) - (%3%) from %4%") % (result_interval - expected_output) % result_interval % expected_output % self->operation_name()); // The samples are still marked as invalid. Would need to remove the // extra calculated samples from not_started_ but that would fail // in a situation where deprecatedCache is called after the task has // been created. So not_started_ can't be modified here (unless calls // to deprecatedCache were tracked). } } self->running_tasks.erase ( taskid ); self.unlock (); step.raw ()->wait_for_tasks_.notify_all (); }
void GraphInvalidator:: deprecateCache(const Dag& dag, Step::ptr step, Signal::Intervals what) { // Invalidate the source first what = step.write ()->deprecateCache(what); // Invalidate the targets afterwards // Otherwise the scheduler might start working on data that isn't ready yet for (Step::ptr ts: dag.targetSteps(step)) deprecateCache(dag, ts, what); }