-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metal: delay rendering until shortly before page flip
- Loading branch information
Showing
9 changed files
with
113 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use crate::{ | ||
io_uring::{ | ||
ops::timeout::timespec64, | ||
sys::{io_uring_sqe, IORING_OP_LINK_TIMEOUT, IORING_TIMEOUT_ABS}, | ||
IoUring, IoUringData, Task, | ||
}, | ||
time::Time, | ||
}; | ||
|
||
#[derive(Default)] | ||
pub struct TimeoutLinkTask { | ||
id: u64, | ||
timespec: timespec64, | ||
} | ||
|
||
impl IoUring { | ||
pub(super) fn schedule_timeout_link(&self, timeout: Time) { | ||
let id = self.ring.id_raw(); | ||
{ | ||
let mut to = self.ring.cached_timeout_links.pop().unwrap_or_default(); | ||
to.id = id; | ||
to.timespec.tv_sec = timeout.0.tv_sec as _; | ||
to.timespec.tv_nsec = timeout.0.tv_nsec as _; | ||
self.ring.schedule(to); | ||
} | ||
} | ||
} | ||
|
||
unsafe impl Task for TimeoutLinkTask { | ||
fn id(&self) -> u64 { | ||
self.id | ||
} | ||
|
||
fn complete(self: Box<Self>, ring: &IoUringData, _res: i32) { | ||
ring.cached_timeout_links.push(self); | ||
} | ||
|
||
fn encode(&self, sqe: &mut io_uring_sqe) { | ||
sqe.opcode = IORING_OP_LINK_TIMEOUT; | ||
sqe.u2.addr = &self.timespec as *const _ as _; | ||
sqe.len = 1; | ||
sqe.u3.timeout_flags = IORING_TIMEOUT_ABS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters