Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
main_thread_rpc.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <chrono>
6#include <cstddef>
7#include <functional>
8#include <memory>
9
10namespace pulp::inspect {
11
24 public:
25 using Operation = std::function<InspectorMessage()>;
26 using Completion = std::function<void()>;
27 using Post = std::function<bool(std::function<void()>)>;
28 using IsMainThread = std::function<bool()>;
29
30 struct Config {
31 std::chrono::milliseconds timeout = std::chrono::seconds(2);
32 std::size_t max_pending = 64;
33 };
34
37 InspectorMainThreadRpc(Config config, Post post, IsMainThread is_main_thread);
39
42
43 InspectorMessage call(std::int64_t request_id, Operation operation);
48 InspectorMessage call(std::int64_t request_id, Operation operation, Completion completion);
52 InspectorMessage call(std::int64_t request_id, Operation operation, Completion completion,
53 std::chrono::milliseconds timeout);
58 InspectorMessage call_queued_only(std::int64_t request_id, Operation operation,
59 Completion completion, std::chrono::milliseconds timeout);
60
64 void cancel();
84 bool active() const;
86 std::chrono::milliseconds default_timeout() const;
87
88 private:
89 InspectorMessage call_with_inline_policy(std::int64_t request_id, Operation operation,
90 Completion completion,
91 std::chrono::milliseconds timeout, bool allow_inline);
92
93 class Impl;
94 std::shared_ptr<Impl> impl_;
95};
96
97} // namespace pulp::inspect
InspectorMessage call(std::int64_t request_id, Operation operation, Completion completion, std::chrono::milliseconds timeout)
As call(), with a deadline chosen for this request.
std::function< InspectorMessage()> Operation
Definition main_thread_rpc.hpp:25
std::function< bool(std::function< void()>)> Post
Definition main_thread_rpc.hpp:27
void cancel_and_wait()
Cancel queued work and wait for every operation already executing on another thread to reach its comp...
void cancel()
Stop accepting requests and cancel every queued operation that has not started.
bool after_current_operation(Completion completion)
Queue teardown work for the exact point at which the current operation has delivered its completion a...
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...
bool set_posted_lifetime_callbacks(Completion begin, Completion end)
Install callbacks bracketing the aggregate lifetime of each posted callable handed to Post.
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.
InspectorMainThreadRpc(Config config, Post post, IsMainThread is_main_thread)
std::chrono::milliseconds default_timeout() const
Normalized per-call ceiling configured for this dispatcher.
InspectorMessage call(std::int64_t request_id, Operation operation)
std::function< bool()> IsMainThread
Definition main_thread_rpc.hpp:28
InspectorMainThreadRpc(const InspectorMainThreadRpc &)=delete
std::function< void()> Completion
Definition main_thread_rpc.hpp:26
InspectorMainThreadRpc & operator=(const InspectorMainThreadRpc &)=delete
Definition agent_context.hpp:7
@ end
Definition geometry.hpp:370
Definition main_thread_rpc.hpp:30
std::chrono::milliseconds timeout
Definition main_thread_rpc.hpp:31
std::size_t max_pending
Definition main_thread_rpc.hpp:32
A single inspector protocol message (request, response, or event).
Definition protocol.hpp:18