diff --git a/rcf-extensions/include/rcf-extensions/detail/round-robin-scheduler/work-methods.h b/rcf-extensions/include/rcf-extensions/detail/round-robin-scheduler/work-methods.h index df0547c824e6ea76b09aeff33fa708822f025131..84587fd5a36e3efc19bb0da980e7aadda75225dd 100644 --- a/rcf-extensions/include/rcf-extensions/detail/round-robin-scheduler/work-methods.h +++ b/rcf-extensions/include/rcf-extensions/detail/round-robin-scheduler/work-methods.h @@ -372,9 +372,14 @@ template <typename Worker> struct work_methods_base { // *this-pointer counts toward arity + // For workers with reinit functionality (which we test via availability of the perform_reinit + // method), we expect two arguments, since in addition to the work, we get the session id. For + // workers without reinit functionality, we expect one argument, the work. static_assert( - (boost::function_types::function_arity<trait::method_work_t<Worker>>::value == 2), - "work-method of Worker has to take exactly one argument!"); + (trait::has_method_perform_reinit<Worker>::value && + boost::function_types::function_arity<trait::method_work_t<Worker>>::value == 3) || + (boost::function_types::function_arity<trait::method_work_t<Worker>>::value == 2), + "work-method of Worker has to take exactly one (or two) argument(s)!"); // *this-pointer counts toward arity static_assert( @@ -403,7 +408,7 @@ struct work_methods_reinit : public work_methods_base<Worker> { // *this-pointer counts toward arity static_assert( - (boost::function_types::function_arity<trait::method_perform_reinit_t<Worker>>::value == 3), + (boost::function_types::function_arity<trait::method_perform_reinit_t<Worker>>::value == 4), "perform_reinit-method of Worker has to take exactly two arguments!"); static_assert(trait::has_session_id_v<Worker>, "Worker has no session id!"); diff --git a/rcf-extensions/include/rcf-extensions/detail/round-robin-scheduler/worker-thread-reinit.tcc b/rcf-extensions/include/rcf-extensions/detail/round-robin-scheduler/worker-thread-reinit.tcc index 6e39e6fc433c35801d186d66cec372b7c8a370c0..49d048962a1226cb41994cce200f87a833da6e25 100644 --- a/rcf-extensions/include/rcf-extensions/detail/round-robin-scheduler/worker-thread-reinit.tcc +++ b/rcf-extensions/include/rcf-extensions/detail/round-robin-scheduler/worker-thread-reinit.tcc @@ -113,7 +113,7 @@ void WorkerThreadReinit<W>::main_thread(std::stop_token st) hw_id = "mockmode"; } try { - auto retval = wtr_t::m_worker.work(work); + auto retval = wtr_t::m_worker.work(work, pkg.session_id); // In case a timeout was encountered connection is reset which requires performing // a reinit to bring chip back in usable state if (wtr_t::m_worker.check_for_timeout(std::get<0>(retval))) { @@ -310,7 +310,7 @@ bool WorkerThreadReinit<W>::perform_reinit(bool force) *m_current_session_id, wtr_t::m_input.is_empty() ? std::make_optional(100ms) : std::nullopt); if (reinit_data) { RCF_LOG_TRACE(wtr_t::m_log, "Performing reinit.."); - wtr_t::m_worker.perform_reinit(*reinit_data, force); + wtr_t::m_worker.perform_reinit(*reinit_data, *m_current_session_id, force); m_session_storage.reinit_set_done(*m_current_session_id); m_current_reinit_id = m_session_storage.get_reinit_id_notified(*m_current_session_id); return true; @@ -333,7 +333,7 @@ bool WorkerThreadReinit<W>::perform_reinit_snapshot(bool const block) (wtr_t::m_input.is_empty() && !block) ? std::make_optional(20ms) : std::nullopt); if (reinit_data) { RCF_LOG_TRACE(wtr_t::m_log, "Performing reinit snapshot.."); - wtr_t::m_worker.perform_reinit_snapshot(*reinit_data); + wtr_t::m_worker.perform_reinit_snapshot(*reinit_data, *m_current_session_id); return true; } else { RCF_LOG_WARN( diff --git a/rcf-extensions/include/rcf-extensions/detail/round-robin-scheduler/worker-thread.tcc b/rcf-extensions/include/rcf-extensions/detail/round-robin-scheduler/worker-thread.tcc index cd111927d1505d3fcc1f47bc162427d6b7c5d8f6..a2da8fa6270fb63c234d01a8be31faa1f9a13436 100644 --- a/rcf-extensions/include/rcf-extensions/detail/round-robin-scheduler/worker-thread.tcc +++ b/rcf-extensions/include/rcf-extensions/detail/round-robin-scheduler/worker-thread.tcc @@ -104,8 +104,16 @@ void WorkerThread<W>::main_thread(std::stop_token st) set_busy(); try { - auto retval = m_worker.work(work); - pkg.context.parameters().r.set(retval); + // For workers with reinit functionality (which we test via availability of the perform_reinit + // method), we expect two arguments, since in addition to the work, we get the session id. For + // workers without reinit functionality, we expect one argument, the work. + if constexpr (trait::has_method_perform_reinit<W>::value) { + auto retval = m_worker.work(work, pkg.session_id); + pkg.context.parameters().r.set(retval); + } else { + auto retval = m_worker.work(work); + pkg.context.parameters().r.set(retval); + } m_output.push_back(std::move(pkg.context)); } catch (std::exception& e) { RCF_LOG_ERROR(m_log, pkg << " encountered exception: " << e.what());