Skip to content
Snippets Groups Projects
Commit fe44c457 authored by Florian Schmaus's avatar Florian Schmaus
Browse files

Merge branch 'io-uring-madvise' into 'master'

[IO] add a madvise Future

See merge request !206
parents 4349781f 939081b6
No related branches found
No related tags found
No related merge requests found
...@@ -112,6 +112,11 @@ class Future : public Logger<LogSubsystem::IO> { ...@@ -112,6 +112,11 @@ class Future : public Logger<LogSubsystem::IO> {
virtual void prepareSqe(io_uring_sqe* sqe) = 0; virtual void prepareSqe(io_uring_sqe* sqe) = 0;
void submitAndForget() {
state.forgotten = true;
submit();
}
void setCompletion(int32_t res) { void setCompletion(int32_t res) {
assert(!state.completed); assert(!state.completed);
LOGD("Complete " << this); LOGD("Complete " << this);
...@@ -578,10 +583,7 @@ class CloseFuture : public Future { ...@@ -578,10 +583,7 @@ class CloseFuture : public Future {
public: public:
CloseFuture(int fildes) : Future(Operation::CLOSE, fildes, nullptr, 0, 0){}; CloseFuture(int fildes) : Future(Operation::CLOSE, fildes, nullptr, 0, 0){};
void submitAndForget() { void submitAndForget() { Future::submitAndForget(); }
state.forgotten = true;
submit();
}
}; };
/* /*
...@@ -647,4 +649,17 @@ class CancelWrapper : public Future { ...@@ -647,4 +649,17 @@ class CancelWrapper : public Future {
public: public:
CancelWrapper(Future& future) : Future(Operation::CANCEL, 0, &future, 0, 0){}; CancelWrapper(Future& future) : Future(Operation::CANCEL, 0, &future, 0, 0){};
}; };
/*
* @brief Request a madvise operation
*/
class MadviseFuture : public Future {
void prepareSqe(io_uring_sqe* sqe) override { io_uring_prep_madvise(sqe, buf, len, flags); }
public:
MadviseFuture(void* addr, size_t len, int advise)
: Future(Operation::MADVISE, 0, addr, len, advise){};
void submitAndForget() { Future::submitAndForget(); }
};
} // namespace emper::io } // namespace emper::io
...@@ -44,6 +44,9 @@ auto operator<<(std::ostream& os, const Operation& op) -> std::ostream& { ...@@ -44,6 +44,9 @@ auto operator<<(std::ostream& os, const Operation& op) -> std::ostream& {
case Operation::CANCEL: case Operation::CANCEL:
os << "cancel"; os << "cancel";
break; break;
case Operation::MADVISE:
os << "madvise";
break;
default: default:
abort(); abort();
} }
......
...@@ -19,6 +19,7 @@ enum class Operation { ...@@ -19,6 +19,7 @@ enum class Operation {
LINK_TIMEOUT, LINK_TIMEOUT,
TIMEOUT, TIMEOUT,
CANCEL, CANCEL,
MADVISE,
NUMBER_OF_OPERATIONS NUMBER_OF_OPERATIONS
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment