diff --git a/lib/iq_inference_impl.cc b/lib/iq_inference_impl.cc index 6a82e4a8..35b3da8f 100644 --- a/lib/iq_inference_impl.cc +++ b/lib/iq_inference_impl.cc @@ -287,6 +287,7 @@ bool iq_inference_impl::stop() { while (!inference_q_.empty()) { sleep(0.001); } + pub_json_(); running_ = false; io_service_->stop(); threadpool_.join_all(); @@ -464,6 +465,14 @@ void iq_inference_impl::process_tags_(COUNT_T in_first, in_first, power_in) } +void iq_inference_impl::pub_json_() { + json_result_type json; + while (json_q_.pop(json)) { + ++predictions_; + message_port_pub(INFERENCE_KEY, string_to_pmt(std::string(json.data()))); + } +} + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" int iq_inference_impl::general_work(int noutput_items, @@ -481,13 +490,7 @@ 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); - - json_result_type json; - while (json_q_.pop(json)) { - ++predictions_; - message_port_pub(INFERENCE_KEY, string_to_pmt(std::string(json.data()))); - } - + pub_json_(); return 0; } #pragma GCC diagnostic pop diff --git a/lib/iq_inference_impl.h b/lib/iq_inference_impl.h index 42cd9a69..8ecdaed6 100644 --- a/lib/iq_inference_impl.h +++ b/lib/iq_inference_impl.h @@ -269,6 +269,7 @@ class iq_inference_impl : public iq_inference, base_impl { void delete_inference_(); void background_run_inference_(); void run_inference_(); + void pub_json_(); boost::scoped_ptr torchserve_client_; public: