Commit c7166a67 authored by Dan Melnic's avatar Dan Melnic Committed by Facebook GitHub Bot

Initialize the context first to skip the tests if the backend is not available

Summary: Initialize the context first to skip the tests if the backend is not available

Reviewed By: kevin-vigor

Differential Revision: D25742461

fbshipit-source-id: 4cbe9545d358dd2bb3ca9297d8b46e80c54f53f7
parent 910b7520
......@@ -185,6 +185,11 @@ class AsyncBase {
AsyncBase& operator=(const AsyncBase&) = delete;
virtual ~AsyncBase();
/**
* Initialize context
*/
virtual void initializeContext() = 0;
/**
* Wait for at least minRequests to complete. Returns the requests that
* have completed; the returned range is valid until the next call to
......@@ -247,7 +252,6 @@ class AsyncBase {
bool isInit() const { return init_.load(std::memory_order_relaxed); }
void decrementPending(size_t num = 1);
virtual void initializeContext() = 0;
virtual int submitOne(AsyncBase::Op* op) = 0;
virtual int submitRange(Range<AsyncBase::Op**> ops) = 0;
......
......@@ -74,8 +74,9 @@ class AsyncIO : public AsyncBase {
AsyncIO& operator=(const AsyncIO&) = delete;
~AsyncIO() override;
private:
void initializeContext() override;
private:
int submitOne(AsyncBase::Op* op) override;
int submitRange(Range<AsyncBase::Op**> ops) override;
......
......@@ -98,8 +98,9 @@ class IoUring : public AsyncBase {
int unregister_buffers();
private:
void initializeContext() override;
private:
int submitOne(AsyncBase::Op* op) override;
int submitRange(Range<AsyncBase::Op**> ops) override;
......
......@@ -65,7 +65,10 @@ struct TestUtil {
template <typename TAsync>
std::unique_ptr<TAsync> getAIO(size_t capacity, AsyncBase::PollMode pollMode) {
try {
return std::make_unique<TAsync>(capacity, pollMode);
auto ret = std::make_unique<TAsync>(capacity, pollMode);
ret->initializeContext();
return ret;
} catch (const std::runtime_error&) {
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment