#ifndef SPINSCALE_PROBE_COMPONENT_THREAD_H #define SPINSCALE_PROBE_COMPONENT_THREAD_H #include #include #include #include #include #include #include #include #include #include namespace sscl::probe { constexpr std::chrono::milliseconds defaultProbeTaskTimeout{10000}; void runNonViralNurseryOnComponentThread( const std::shared_ptr& componentThread, std::function invokerFactory, std::chrono::milliseconds timeout = defaultProbeTaskTimeout); /** Sync driver: run work on a temporary puppeteer ComponentThread. * * Shared by lcameraDev probe tools and HIL/unit tests. Not tied to gtest. */ class ProbeComponentThreadHarness { public: explicit ProbeComponentThreadHarness( const char *threadName = "spinscale-probe"); ~ProbeComponentThreadHarness(); ProbeComponentThreadHarness(const ProbeComponentThreadHarness &) = delete; ProbeComponentThreadHarness &operator=( const ProbeComponentThreadHarness &) = delete; std::shared_ptr componentThread() const; void runSync( const std::function&)>& work); template void runNonViralNurseryTask( InvokerFactory &&invokerFactory, std::chrono::milliseconds timeout = defaultProbeTaskTimeout) { runSync( [this, &invokerFactory, timeout]( const std::shared_ptr& componentThread) { sscl::probe::runNonViralNurseryOnComponentThread( componentThread, std::forward(invokerFactory), timeout); }); } private: std::string threadName; std::shared_ptr dummyComponent; std::shared_ptr lastComponentThread; }; } // namespace sscl::probe #endif // SPINSCALE_PROBE_COMPONENT_THREAD_H