io_uring: remove unnecessary interior mutability
This commit is contained in:
parent
fe80440f38
commit
20b1f29343
4 changed files with 41 additions and 45 deletions
|
|
@ -6,33 +6,28 @@ use {
|
|||
},
|
||||
utils::errorfmt::ErrorFmt,
|
||||
},
|
||||
std::cell::Cell,
|
||||
uapi::c,
|
||||
};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct AsyncCancelTask {
|
||||
id: Cell<u64>,
|
||||
target: Cell<u64>,
|
||||
id: u64,
|
||||
target: u64,
|
||||
}
|
||||
|
||||
impl IoUringData {
|
||||
pub fn cancel_task_in_kernel(&self, target: u64) {
|
||||
let task = self.cached_cancels.pop().unwrap_or_else(|| {
|
||||
Box::new(AsyncCancelTask {
|
||||
id: Cell::new(0),
|
||||
target: Cell::new(0),
|
||||
})
|
||||
});
|
||||
let id = self.id_raw();
|
||||
task.id.set(id);
|
||||
task.target.set(target);
|
||||
let mut task = self.cached_cancels.pop().unwrap_or_default();
|
||||
task.id = id;
|
||||
task.target = target;
|
||||
self.schedule(task);
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Task for AsyncCancelTask {
|
||||
fn id(&self) -> u64 {
|
||||
self.id.get()
|
||||
self.id
|
||||
}
|
||||
|
||||
fn complete(self: Box<Self>, ring: &IoUringData, res: i32) {
|
||||
|
|
@ -46,7 +41,7 @@ unsafe impl Task for AsyncCancelTask {
|
|||
|
||||
fn encode(&self, sqe: &mut io_uring_sqe) {
|
||||
sqe.opcode = IORING_OP_ASYNC_CANCEL;
|
||||
sqe.u2.addr = self.target.get();
|
||||
sqe.u2.addr = self.target;
|
||||
}
|
||||
|
||||
fn is_cancel(&self) -> bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue