#ifndef SPINSCALE_TEST_SUPPORT_PROBE_COMPONENT_THREAD_H #define SPINSCALE_TEST_SUPPORT_PROBE_COMPONENT_THREAD_H #include #include #include #include #include #include #include #include #include namespace sscl::tests { constexpr std::chrono::milliseconds defaultProbeTaskTimeout{10000}; void runNonViralNurseryOnComponentThread( const std::shared_ptr& componentThread, std::function invokerFactory, std::chrono::milliseconds timeout = defaultProbeTaskTimeout); 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::tests::runNonViralNurseryOnComponentThread( componentThread, std::forward(invokerFactory), timeout); }); } private: std::string threadName; std::shared_ptr dummyComponent; std::shared_ptr lastComponentThread; }; } // namespace sscl::tests #endif // SPINSCALE_TEST_SUPPORT_PROBE_COMPONENT_THREAD_H