Skip to content

Commit

Permalink
reorder queue teardown.
Browse files Browse the repository at this point in the history
  • Loading branch information
anarkiwi committed Jul 12, 2024
1 parent a5fdb95 commit 978d334
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/iq_inference_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,21 +284,20 @@ void iq_inference_impl::background_run_inference_() {

bool iq_inference_impl::stop() {
d_logger->info("stopping");
while (!inference_q_.empty()) {
sleep(0.001);
}
running_ = false;
io_service_->stop();
threadpool_.join_all();
run_inference_();
d_logger->info("published {} predictions", predictions_);
return true;
}

void iq_inference_impl::run_inference_() {
boost::beast::error_code ec;
while (!inference_q_.empty()) {
output_item_type output_item;
if (!inference_q_.pop(output_item)) {
break;
}
output_item_type output_item;
while (inference_q_.pop(output_item)) {
nlohmann::json metadata_json;
metadata_json["ts"] = host_now_str_(output_item.rx_time);
metadata_json["sample_clock"] = std::to_string(output_item.sample_clock);
Expand Down Expand Up @@ -483,9 +482,8 @@ int iq_inference_impl::general_work(int noutput_items,
process_tags_(in_first, samples_in_first, in_count, samples_in, power_in);
consume_each(in_count);

while (!json_q_.empty()) {
json_result_type json;
json_q_.pop(json);
json_result_type json;
while (json_q_.pop(json)) {
++predictions_;
message_port_pub(INFERENCE_KEY, string_to_pmt(std::string(json.data())));
}
Expand Down

0 comments on commit 978d334

Please sign in to comment.