rt: a timed wait on the completion thread is refused too, and the test's room answers compile

The own-thread test formatted `made.as_ref().map(drop)` (a Result<(), &Error>) through a
closure taking Result<(), Error>, which failed to compile under --cfg m2v_gpu (check 48115). It
formats the borrowed result directly now. The test gains one answer: in a completed handler,
wait_until_signaled_value(1, Duration::ZERO) for a value not reached is WaitOnOwnThread, not
false at its timeout: the thread that would observe the value is the one waiting, so a false
there would be the runtime's artefact. The refusal already applied to every timeout; the README
and the event's doc now say so.
This commit is contained in:
Anees Iqbal committed 2026-11-18 14:04:45 -08:00
1 parent 518800af99
commit b70c5fb618
3 files changed
+24 -15

No files matched your search

+10 -9
View File
@@ -643,15 +643,16 @@ made, with no lock, and never rewritten for layouts.
- The completion thread retires command buffers as the progress semaphore reaches them, a
submission's in commit order: the status, the blocks they kept, their recorders and their place
in the queue, then the completed handlers. Completed handlers and listeners run on it, in
turn. A wait in one for what that thread has not yet done is `Refusal::WaitOnOwnThread`, and
one already met answers at once: `wait_until_completed` for a command buffer not yet completed
(its own handler's command buffer has), `wait_until_scheduled` for one not yet scheduled,
`wait_until_signaled_value` for a value not yet reached, and `CommandQueue::command_buffer` on a
queue whose maximum count are made and not yet completed, which a scheduled handler answers
the same way. No wait of the runtime's hangs by construction. A command buffer of a group is seen complete
with the group's last: up to the GPU time of the fifteen after it late. Only a queue already three
submissions behind holds a group; one whose submissions have completed sends its next command
buffer alone. Without a wait or a hint, the lateness is bounded only while three submissions are
turn. A wait in one for what that thread has not yet done is `Refusal::WaitOnOwnThread`, and one
already met answers at once: `wait_until_completed` for a command buffer not yet completed (its
own handler's command buffer has), `wait_until_scheduled` for one not yet scheduled,
`wait_until_signaled_value` for a value not yet reached (a timed wait too: it is refused, never
false at its timeout, since the thread that would observe the value is the one waiting), and
`CommandQueue::command_buffer` on a queue whose maximum count are made and not yet completed,
which a scheduled handler answers the same way. No wait of the runtime's hangs by construction.
A command buffer of a group is seen complete with the group's last: up to the GPU time of the
fifteen after it late. Only a queue already three submissions behind holds a group; one whose
submissions have completed sends its next command buffer alone. Without a wait or a hint, the lateness is bounded only while three submissions are
in flight, and the completion that leaves fewer sends the group (the measured lateness is under
"Known gaps"). A command buffer ended while its queue holds a group joins it, and retires in its
place; the group goes at once.
+2 -1
View File
@@ -157,7 +157,8 @@ impl SharedEvent {
///
/// Err: [`Refusal::InScheduledHandler`](crate::Refusal::InScheduledHandler) in a scheduled
/// handler; [`Refusal::WaitOnOwnThread`](crate::Refusal::WaitOnOwnThread) in a completed
/// handler or a listener of its device for a value not yet reached.
/// handler or a listener of its device for a value not yet reached, whatever `timeout`: no
/// false there, since that thread observes the value.
pub fn wait_until_signaled_value(&self, value: u64, timeout: Duration) -> Result<bool, Error> {
crate::command::not_in_scheduled_handler()?;
let inner = &self.event.inner;
+12 -5
View File
@@ -2153,8 +2153,8 @@ pub(crate) mod on_device {
}
/// On the completion thread, in a completed handler and in a listener, a wait for what that
/// thread has not yet done is refused with `WaitOnOwnThread`, and one already met answers at
/// once: the handler's own command buffer has completed. A command buffer asked of a full
/// thread has not yet done is refused with `WaitOnOwnThread`, a timed one too, never false at
/// its timeout, and one already met answers at once: the handler's own command buffer has completed. A command buffer asked of a full
/// queue is refused there and in a scheduled handler, on the submit thread.
#[test]
fn every_device_refuses_in_a_handler_each_wait_its_own_thread_would_have_to_end() {
@@ -2200,7 +2200,14 @@ pub(crate) mod on_device {
),
("completed: value 0", format!("{:?}", waited(0))),
("completed: value 1", format!("{:?}", waited(1))),
("completed: room", answer(made.as_ref().map(drop))),
(
"completed: value 1 at once",
format!(
"{:?}",
in_event.wait_until_signaled_value(1, Duration::ZERO)
),
),
("completed: room", format!("{:?}", made.as_ref().map(drop))),
(
"completed: a full queue",
answer(in_queue.command_buffer().map(drop)),
@@ -2241,7 +2248,7 @@ pub(crate) mod on_device {
"listener: done completed",
answer(in_done.wait_until_completed()),
),
("listener: room", answer(made.as_ref().map(drop))),
("listener: room", format!("{:?}", made.as_ref().map(drop))),
(
"listener: a full queue",
answer(in_queue.command_buffer().map(drop)),
@@ -2270,7 +2277,7 @@ pub(crate) mod on_device {
};
assert_eq!(*got, want, "{name}: {call}");
}
assert_eq!(lines.len(), 15, "{name}: {lines:?}");
assert_eq!(lines.len(), 16, "{name}: {lines:?}");
// Outside a handler the same waits answer as before.
assert_eq!(word(&a), 5, "{name}");
assert_eq!(held.status(), CommandBufferStatus::NotEnqueued, "{name}");