Skip to content

Commit

Permalink
Initialize the context first to skip the tests if the backend is not …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
dmm-fb authored and facebook-github-bot committed Jan 1, 2021
1 parent 910b752 commit c7166a6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
6 changes: 5 additions & 1 deletion folly/experimental/io/AsyncBase.h
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion folly/experimental/io/AsyncIO.h
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion folly/experimental/io/IoUring.h
Expand Up @@ -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;

Expand Down
5 changes: 4 additions & 1 deletion folly/experimental/io/test/AsyncBaseTestLib.h
Expand Up @@ -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&) {
}

Expand Down

0 comments on commit c7166a6

Please sign in to comment.