A decoder buffer's records went onto its queue's completion ring through
posts that waited, with no bound, for the guest to make room. They waited on
whichever thread posted them. The completion-seen handler (EVENT_SIGNALLED
values, CB_COMPLETE) runs on the platform's waiter, where a wait holds every
queue's completions. The submission handler (CB_SUBMITTED, CB_SCHEDULED) runs
on the platform's scheduler thread, or on any thread whose commit submits
ready batches, where a wait holds every queue's submissions. The record
mutexes held across those posts (Submitted, Scheduled, the queue's Line, a
buffer's Signals) coupled them: a lane waiting inside Line::post_through held
the mutex the scheduler thread's submission handler then waited for.
metal2vulkan's handlers must never block.
CompletionPoster::post_unwaiting posts a record on the calling thread where
nothing is handed over before it on the ring and the ring has room, and
otherwise hands it over behind those records. It also posts as many of them
as the ring takes now, in order.
- The queue's service thread posts the rest as room comes: it looks at the
device's 1 ms poll while records wait, and takes the guest's buffers
meanwhile.
- Every later post onto the ring, from any thread, goes behind them.
- What follows a record runs right after the record is posted, or is dropped
at a reset or the queue's end: a value's fan-out to the other holders of the
event's name, the shows of the presents waiting for the buffer, and the
answers waiting for its context's drain.
So the guest sees every record, fan-out and answer in the order it saw them
when the handler waited. The decoder's four record sinks post this way from
every thread. A foreign committer still hands its records over without
posting. The full spells and waits of handed records are told on the service
thread (queue-ring-full, queue-ring-post-waited), never on a thread that hands
them over.
a_read_of_the_display_calls_nothing_back_and_waits_for_no_full_ring changes.
It said the first buffer's completion waits on its completion thread for
room, and it counted 2 records handed over in all. The completion now hands
what the ring has no room for to the queue's service thread and returns, so
those records count as handed over too. The test asserts that some were, and
that the read's commit hands over 2 more.