Bounded response-after-apply handoff from an inspector transport thread to the registered host main thread. More...
#include <main_thread_rpc.hpp>
Classes | |
| struct | Config |
Public Types | |
| using | Operation = std::function<InspectorMessage()> |
| using | Completion = std::function<void()> |
| using | Post = std::function<bool(std::function<void()>)> |
| using | IsMainThread = std::function<bool()> |
Public Member Functions | |
| InspectorMainThreadRpc () | |
| InspectorMainThreadRpc (Config config) | |
| InspectorMainThreadRpc (Config config, Post post, IsMainThread is_main_thread) | |
| ~InspectorMainThreadRpc () | |
| InspectorMainThreadRpc (const InspectorMainThreadRpc &)=delete | |
| InspectorMainThreadRpc & | operator= (const InspectorMainThreadRpc &)=delete |
| InspectorMessage | call (std::int64_t request_id, Operation operation) |
| InspectorMessage | call (std::int64_t request_id, Operation operation, Completion completion) |
| As call(), with a callback that runs exactly once when the operation is no longer capable of applying: immediately for work cancelled before it starts, or after a started operation actually returns. | |
| InspectorMessage | call (std::int64_t request_id, Operation operation, Completion completion, std::chrono::milliseconds timeout) |
| As call(), with a deadline chosen for this request. | |
| InspectorMessage | call_queued_only (std::int64_t request_id, Operation operation, Completion completion, std::chrono::milliseconds timeout) |
| Strict variant for callers that require an enforceable response deadline. | |
| void | cancel () |
| Stop accepting requests and cancel every queued operation that has not started. | |
| void | cancel_and_wait () |
| Cancel queued work and wait for every operation already executing on another thread to reach its completion callback. | |
| bool | set_posted_lifetime_callbacks (Completion begin, Completion end) |
| Install callbacks bracketing the aggregate lifetime of each posted callable handed to Post. | |
| bool | executing_on_current_thread () const |
| bool | after_current_operation (Completion completion) |
| Queue teardown work for the exact point at which the current operation has delivered its completion and left RPC execution. | |
| bool | active () const |
| std::chrono::milliseconds | default_timeout () const |
| Normalized per-call ceiling configured for this dispatcher. | |
Bounded response-after-apply handoff from an inspector transport thread to the registered host main thread.
A request that times out before execution is cancelled and cannot mutate later. A request that times out after execution starts returns a fenced mayHaveApplied error at the deadline; the posted task retains its own state and discards any late response. Operations must therefore own everything they may access until they return. Calls already executing inline on the main thread cannot be preempted and therefore cannot return at their deadline. If inline work crosses the deadline, call() reports a fenced timeout only after that work returns. A Post implementation owns every callable copy it accepts until that copy is destroyed, including cancelled callables that will never execute.
| using pulp::inspect::InspectorMainThreadRpc::Completion = std::function<void()> |
| using pulp::inspect::InspectorMainThreadRpc::IsMainThread = std::function<bool()> |
| using pulp::inspect::InspectorMainThreadRpc::Operation = std::function<InspectorMessage()> |
| using pulp::inspect::InspectorMainThreadRpc::Post = std::function<bool(std::function<void()>)> |
| pulp::inspect::InspectorMainThreadRpc::InspectorMainThreadRpc | ( | ) |
|
explicit |
| pulp::inspect::InspectorMainThreadRpc::InspectorMainThreadRpc | ( | Config | config, |
| Post | post, | ||
| IsMainThread | is_main_thread ) |
| pulp::inspect::InspectorMainThreadRpc::~InspectorMainThreadRpc | ( | ) |
|
delete |
| bool pulp::inspect::InspectorMainThreadRpc::active | ( | ) | const |
| bool pulp::inspect::InspectorMainThreadRpc::after_current_operation | ( | Completion | completion | ) |
Queue teardown work for the exact point at which the current operation has delivered its completion and left RPC execution.
Returns false when the caller is not inside an operation owned by this RPC.
| InspectorMessage pulp::inspect::InspectorMainThreadRpc::call | ( | std::int64_t | request_id, |
| Operation | operation ) |
| InspectorMessage pulp::inspect::InspectorMainThreadRpc::call | ( | std::int64_t | request_id, |
| Operation | operation, | ||
| Completion | completion ) |
As call(), with a callback that runs exactly once when the operation is no longer capable of applying: immediately for work cancelled before it starts, or after a started operation actually returns.
This distinction lets owners retain mutation leases across a fenced started timeout.
| InspectorMessage pulp::inspect::InspectorMainThreadRpc::call | ( | std::int64_t | request_id, |
| Operation | operation, | ||
| Completion | completion, | ||
| std::chrono::milliseconds | timeout ) |
| InspectorMessage pulp::inspect::InspectorMainThreadRpc::call_queued_only | ( | std::int64_t | request_id, |
| Operation | operation, | ||
| Completion | completion, | ||
| std::chrono::milliseconds | timeout ) |
Strict variant for callers that require an enforceable response deadline.
It never executes inline: invocation from the registered main thread fails before apply and runs completion exactly once. Other callers use the normal bounded queued path.
| void pulp::inspect::InspectorMainThreadRpc::cancel | ( | ) |
Stop accepting requests and cancel every queued operation that has not started.
Running operations retain their own state and are not waited for. Safe to call repeatedly during host teardown.
| void pulp::inspect::InspectorMainThreadRpc::cancel_and_wait | ( | ) |
Cancel queued work and wait for every operation already executing on another thread to reach its completion callback.
Accepted dispatcher closures that have not run are cancelled but remain owned by the dispatcher; this operation does not wait for their callable storage to be released. When called from the executing operation itself, cancellation is applied but waiting is skipped so reentrant host teardown cannot deadlock.
| std::chrono::milliseconds pulp::inspect::InspectorMainThreadRpc::default_timeout | ( | ) | const |
Normalized per-call ceiling configured for this dispatcher.
| bool pulp::inspect::InspectorMainThreadRpc::executing_on_current_thread | ( | ) | const |
|
delete |
| bool pulp::inspect::InspectorMainThreadRpc::set_posted_lifetime_callbacks | ( | Completion | begin, |
| Completion | end ) |
Install callbacks bracketing the aggregate lifetime of each posted callable handed to Post.
Copies made by Post share one lifetime. The end callback runs only when the final callable copy is destroyed. May be installed only once and while no posted callable lifetime is outstanding; returns false otherwise.