Files
scylladb/tests/test_runner.hh
Tomasz Grabiec a1fecad8cb tests: Introduce test_runner class
It uses app_template to launch seastar framework and can be used from
outside threads to inject tasks.
2015-01-29 10:30:14 +02:00

27 lines
576 B
C++

/*
* Copyright (C) 2015 Cloudius Systems, Ltd.
*/
#pragma once
#include <memory>
#include "core/reactor.hh"
#include "core/future.hh"
#include "exchanger.hh"
class test_runner {
private:
std::unique_ptr<posix_thread> _thread;
std::atomic<bool> _started{false};
exchanger<std::function<future<>()>> _task;
bool _done = false;
private:
void start(std::function<void()> pre_start);
void stop();
public:
static test_runner& launch_or_get(std::function<void()> pre_start);
~test_runner();
void run_sync(std::function<future<>()> task);
};