38 lines
1.4 KiB
C++
38 lines
1.4 KiB
C++
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
// SPDX-FileCopyrightText: 2025 ai-ad4 and the FreePDFEditor contributors
|
|
//
|
|
// UIProcess.h — the UI process side of Spike E. Spawns the sandboxed document
|
|
// process, opens the Cap'n Proto RPC channel, sends N Parse requests, and
|
|
// measures the round-trip latency. The UI process does NO untrusted parsing;
|
|
// it hands byte ranges to the document process and validates the responses.
|
|
|
|
#ifndef FREEPDFEDITOR_SPIKE_E_UIPROCESS_H
|
|
#define FREEPDFEDITOR_SPIKE_E_UIPROCESS_H
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
namespace freepdfeditor::spike::e {
|
|
|
|
struct UIResult {
|
|
bool ok = false;
|
|
std::string error;
|
|
std::size_t requests_sent = 0;
|
|
std::size_t requests_acked = 0;
|
|
double avg_latency_us = 0.0; // average round-trip per request
|
|
double min_latency_us = 0.0;
|
|
double max_latency_us = 0.0;
|
|
double total_time_us = 0.0;
|
|
};
|
|
|
|
// Run the UI process: spawn the sandboxed child on `child_fd`, talk to it on
|
|
// `parent_fd`, send `n_requests` Parse requests of `payload_bytes` each, and
|
|
// measure the round-trip latency. The child must already be exec'd and
|
|
// configured to use child_fd; this function just drives the channel.
|
|
UIResult run_ui_process(int parent_fd, int child_fd,
|
|
std::size_t n_requests, std::size_t payload_bytes);
|
|
|
|
} // namespace freepdfeditor::spike::e
|
|
|
|
#endif // FREEPDFEDITOR_SPIKE_E_UIPROCESS_H
|