MotionApprovalPromptSlot Class
The one place an operator's motion-approval answer is delivered, and the claim that keeps two motions from waiting on it at once. More...
Declaration
Included Headers
Public Member Typedefs Index
| using | AnswerCell = std::shared_ptr< std::atomic< Answer > > |
Enumerations Index
| enum class | Answer { ... } |
|
What the operator said, or that they have not said anything yet. More... | |
| enum class | Delivery { ... } |
|
What became of an answer. Each refusal needs different words to the operator, so they stay distinct. More... | |
Public Member Functions Index
| AnswerCell | tryClaim (std::string preview_id) |
|
Claim the slot for a new prompt. More... | |
| Delivery | answer (std::string_view preview_id, bool approved) |
|
Deliver the operator's answer to the prompt it names. More... | |
Private Member Attributes Index
| std::mutex | mutex_ |
| std::weak_ptr< std::atomic< Answer > > | waiting_ |
| std::string | waiting_preview_id_ |
Description
The one place an operator's motion-approval answer is delivered, and the claim that keeps two motions from waiting on it at once.
The answer arrives on a service advertised for the life of the Runtime, while the prompt that wants it is created and destroyed per motion. Rather than let the service callback reach into the prompt — where it would race the prompt's destruction — the prompt takes a shared answer cell from here and the callback only ever writes to that cell. The cell outlives whichever of the two lets go first, so a late answer lands somewhere harmless instead of on freed memory.
Holding the cell is the claim: it is released when the prompt drops it, including by a throw partway through construction, so there is no path that wedges the gate for the rest of the process.
Every answer names the prompt it is for, so an answer that outlives its own prompt is refused rather than applied to whichever motion happens to be waiting when it arrives.
Definition at line 33 of file motion_approval_prompt_slot.hpp.
Public Member Typedefs
AnswerCell
|
Definition at line 53 of file motion_approval_prompt_slot.hpp.
Enumerations
Answer
| strong |
What the operator said, or that they have not said anything yet.
Definition at line 37 of file motion_approval_prompt_slot.hpp.
Delivery
| strong |
What became of an answer. Each refusal needs different words to the operator, so they stay distinct.
Definition at line 45 of file motion_approval_prompt_slot.hpp.
Public Member Functions
answer()
|
Deliver the operator's answer to the prompt it names.
- Parameters
-
preview_id The prompt being answered, as carried by the preview the operator was shown.
approved What the operator decided.
Declaration at line 69 of file motion_approval_prompt_slot.hpp, definition at line 27 of file motion_approval_prompt_slot.cpp.
tryClaim()
|
Claim the slot for a new prompt.
- Parameters
-
preview_id Identity the answer must name to be accepted. The gate stamps it on the previewed Solution, so the operator's app can echo it back.
- Returns
The cell to poll, or nullptr when another prompt already holds the slot. Keep the cell alive for as long as the prompt waits; dropping it releases the claim.
Declaration at line 62 of file motion_approval_prompt_slot.hpp, definition at line 14 of file motion_approval_prompt_slot.cpp.
Private Member Attributes
mutex_
|
Definition at line 72 of file motion_approval_prompt_slot.hpp.
waiting_
|
Definition at line 74 of file motion_approval_prompt_slot.hpp.
waiting_preview_id_
|
Definition at line 76 of file motion_approval_prompt_slot.hpp.
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.