io/uring/Operation: add method ReplaceUring()
This commit is contained in:
parent
382273abc5
commit
4001379663
@ -67,6 +67,16 @@ public:
|
|||||||
// TODO: io_uring_prep_cancel()
|
// TODO: io_uring_prep_cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Replace(Operation &old_operation,
|
||||||
|
Operation &new_operation) noexcept {
|
||||||
|
assert(operation == &old_operation);
|
||||||
|
assert(old_operation.cancellable == this);
|
||||||
|
|
||||||
|
old_operation.cancellable = nullptr;
|
||||||
|
operation = &new_operation;
|
||||||
|
new_operation.cancellable = this;
|
||||||
|
}
|
||||||
|
|
||||||
void OnUringCompletion(int res) noexcept {
|
void OnUringCompletion(int res) noexcept {
|
||||||
if (operation == nullptr)
|
if (operation == nullptr)
|
||||||
return;
|
return;
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "Operation.hxx"
|
#include "Operation.hxx"
|
||||||
#include "CancellableOperation.hxx"
|
#include "CancellableOperation.hxx"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace Uring {
|
namespace Uring {
|
||||||
@ -46,4 +47,14 @@ Operation::CancelUring() noexcept
|
|||||||
std::exchange(cancellable, nullptr)->Cancel(*this);
|
std::exchange(cancellable, nullptr)->Cancel(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Operation::ReplaceUring(Operation &new_operation) noexcept
|
||||||
|
{
|
||||||
|
assert(IsUringPending());
|
||||||
|
|
||||||
|
cancellable->Replace(*this, new_operation);
|
||||||
|
|
||||||
|
assert(cancellable == nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Uring
|
} // namespace Uring
|
||||||
|
@ -62,6 +62,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
void CancelUring() noexcept;
|
void CancelUring() noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace this pending operation with a new one. This method
|
||||||
|
* is only legal if IsUringPending().
|
||||||
|
*/
|
||||||
|
void ReplaceUring(Operation &new_operation) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called when the operation completes.
|
* This method is called when the operation completes.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user