mirror of
https://github.com/latentPrion/libspinscale.git
synced 2026-06-23 19:48:32 +00:00
Adversarial review on test porting plan
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#ifndef SPINSCALE_TEST_SUPPORT_COROUTINE_DRIVER_H
|
||||
#define SPINSCALE_TEST_SUPPORT_COROUTINE_DRIVER_H
|
||||
|
||||
#include <exception>
|
||||
|
||||
#include <boost/asio/io_context.hpp>
|
||||
|
||||
#include <support/threadHarness.h>
|
||||
|
||||
namespace sscl::tests {
|
||||
|
||||
class CoroutineDriver
|
||||
{
|
||||
public:
|
||||
template <typename Invoker>
|
||||
static auto completedReturnValue(Invoker &invoker)
|
||||
{
|
||||
if (invoker.completedReturnValues().myExceptionPtr) {
|
||||
std::rethrow_exception(
|
||||
invoker.completedReturnValues().myExceptionPtr);
|
||||
}
|
||||
|
||||
return invoker.completedReturnValues().myReturnValue;
|
||||
}
|
||||
|
||||
template <typename Invoker>
|
||||
static auto pumpUntilIdleAndReturnValue(
|
||||
boost::asio::io_context &ioContext,
|
||||
Invoker &invoker)
|
||||
{
|
||||
IoContextPump::pumpUntilIdle(ioContext);
|
||||
return completedReturnValue(invoker);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace sscl::tests
|
||||
|
||||
#endif // SPINSCALE_TEST_SUPPORT_COROUTINE_DRIVER_H
|
||||
Reference in New Issue
Block a user