Skip to main content

Module runner

Module runner 

Source
Expand description

The history-run seam — the async RUN machine behind a trait, mirroring the platform-seam shape of brep-app/src/store.rs’s ModelStore (a trait with impls behind it, async surfaced via a poll idiom).

A history run is split SUBMIT → POLL/APPLY: HistoryRunner::submit_run kicks off a run tagged with a monotonic generation, and the completed RunReply is drained later via HistoryRunner::poll_run. The runner OWNS the SceneRunner — so a future thread/worker impl owns the resident registry that execute_history populates — and holds the delta baseline across reruns.

This slice ships the DEFAULT InlineRunner: it runs on submit_run and stashes the reply for an immediate poll_run, so the run stays synchronous and byte-identical to the pre-seam in-process run. A native-thread impl (M2b) and a wasm-worker impl (M3) slot in behind the SAME trait — submit_run defers the work and poll_run surfaces it a frame (or many) later, so the EngineState::pump caller never changes.

Structs§

ApplyRegionChoicesJob
Rebuild an interactive import’s chosen regions as NURBS faces: the conversion’s STEP, the welded mesh the regions index, and one choice per region (brep_reconstruction::import_session::apply_region_choices).
ApplyRegionChoicesReply
CamJob
ONE CAM operation’s generation, off the UI thread (the CAM workbench’s Generate). The job carries everything the generator reads as plain data: the operation, its setup and the document’s tools (the shared model, by value), and the resident solids it machines by (name, handle), which the runner clones out of its registry and tessellates through the CAM kernel adapter. The main side submits ONE operation per job and the next when its reply lands, so a cancel between operations is immediate on every platform; inside a job the native thread’s cancel flag ends it at the generator’s next work chunk, and the browser worker — which cannot read a message while it is inside a job — finishes the operation, whose reply the main side then drops as cancelled. A document Reset drops nothing here: the job holds no parked state across commands.
CamProgress
A generation’s progress, posted from inside the job at its stage and chunk boundaries.
CamReply
A completed CamJob: the toolpath, or why the operation could not be generated (the generator’s own words), and how much work it took.
CamSimJob
One simulation command, paired back by (session, seq).
CamSimProgress
A simulation chunk’s progress, posted between motions.
CamSimReply
The session’s state after a CamSimJob.
FitAttempt
One kind tried by fit_region.
HybridDemotion
One demoted region of a mixed analytic/faceted rebuild.
ImportRegion
One region of the segmentation the mixed builder starts from.
ImportRegions
The segmentation phase of an import.
InlineRunner
The default, SYNCHRONOUS runner: runs on submit, stashes the reply for an immediate poll. Behavior-identical to the pre-seam in-process run.
MeasureQuery
A per-object MEASUREMENT request routed to the runner (which owns the warm registry). The runner resolves owner to its resident handle and measures by kind; the reply is the object-info JSON fragment MINUS the main-injected name/creatingFeature fields. Tagged with a monotonic id so the main side can pair the reply with its pending request.
MeasureReply
A completed MeasureQuery: the object-info measurement fields as a JSON fragment (WITHOUT name/creatingFeature, which the main thread injects from its eager provenance), tagged with the request id.
MeshImportPhaseReply
MeshImportReply
Completed off-thread reconstruction. Success carries validated STEP and diagnostics for a preview or an ordinary IMPORT3D history insertion.
MeshImportRequest
A mesh reconstruction request. The byte payload moves to the native thread or is serialized to the browser worker; no parsing or fitting happens on UI.
NurbsFaceChoice
One region to rebuild as a NURBS face.
NurbsFaceOutcome
What became of one NurbsFaceChoice.
NurbsFit
A least-squares B-spline surface fitted to a region.
PluginActionReply
PluginActionRequest
A callback request against an immutable document/selection snapshot.
PluginInstallReply
PluginInstallRequest
Validate explicitly installed packages away from the UI thread.
RegionFit
The result of fit_region.
RegionFitJob
Refit one region of an interactive import. The caller sends the region’s own triangles (a small mesh), so the runner keeps no import state.
RegionFitReply
RegionFitRequest
Refit one region.
RunProgress
A feature about to EXECUTE inside an in-flight run (cached replays are instant and are not reported): which one, of how many, under which generation. Posted by the runner before the kernel starts the feature, so the UI can name what it is waiting on — and, after a cancel, what it was waiting on.
RunReply
A completed history run, tagged with the generation it was submitted under so the applier can drop stale replies (a newer run that finished first). The output is the SceneRunner delta to apply to the display scene.
SheetLinesReply
A completed SheetLinesRequest: the placement’s lines relative to its position, or why the runner could not draw them (a handle its registry no longer holds, or holds different geometry under).
SheetLinesRequest
A drawing sheet’s exact hidden-line pass for ONE placement, handed to the runner so the UI thread never runs it (see crate::sheets::project::LinesJob). The job names the runner’s own resident solids by handle and content fingerprint, so nothing crosses the seam but the question and the lines.
StepProbeReply
The probe’s answer: the parsed assembly (Some), no structure (None), or a parse failure. The assembly crosses back to the main side whole — its JSON is large (74 MB for the file above) but the trip costs a third of a second against the seconds the parse took.
StepProbeRequest
A STEP text to PROBE for product structure on the runner — the parse that brep_kernel::read_step_assembly performs, which builds every product’s bodies and takes seconds on a real assembly (8.3 s natively for a 5 MB, 140-product file), so it must not run on the browser’s main thread.
StlConversionOptions
Controls recognition and STEP topology construction.
StlConversionOutput
STEP text and its complete conversion report.
StlConversionReport
Detailed conversion outcome suitable for terminal or JSON reporting.
ThreadRunner
TopologyReply
A completed TopologyRequest: a clone of every requested solid the registry still holds, (name, handle, solid). A handle the registry no longer holds (a later run freed it) is left out.
TopologyRequest
A request for the B-rep TOPOLOGY of resident solids, by the handle each display was tessellated from. The drawing sheet’s exact hidden-line pass reads faces and edges, and the resident registry that holds them is thread-local to the runner, so the main side asks for exactly the solids a placement draws and does not already hold. Nothing else ever asks, so a document with no sheet never pays for the topology crossing.

Enums§

CamSimRequest
A CAM SIMULATION request (lane C17b). The runner keeps ONE simulation session resident (its stock and checkpoints live runner-side; a thread local, so the native thread and the wasm worker hold it the same way); the main side loads it once and then asks it to advance in bounded chunks, so a cancel between chunks is immediate on every platform and a chunk stops between two motions on the native thread.
Command
A command sent main → runner (thread channel OR worker postMessage) over one ordered stream (so a Reset before a Run stays before it). Run carries the whole request; the driver coalesces consecutive Runs to shed a slider drag’s backlog (the thread in thread_main, the worker’s main side in WorkerRunner).
ConversionBackend
Topology path used to produce the final STEP body.
ConversionPolicy
Whether an unprovable analytic conversion may preserve the mesh as a repaired faceted STEP solid.
FitKind
What to fit a region as.
MeasureKind
Which exact measurement a MeasureQuery wants, mirroring the object-info kinds (crate::metadata): a whole solid, one named face, or one named edge.
MeshImportFormat
Mesh encoding accepted by the off-thread reconstruction channel.
MeshImportPhase
One phase of an interactive mesh import, posted from inside the reconstruction before its MeshImportReply.
RegionKind
What a region is (proposed or fitted) as.
Reply
A reply sent runner → main; the main side demuxes it into per-kind buffers.
SessionOnMain
The history-run seam: SUBMIT a run, POLL for its completed reply, RESET the delta baseline, plus a QUERY channel for per-object measurements (routed to the runner so the warm registry answers them, never the cold main-side one). The Inline impl runs everything synchronously; a later thread/worker impl defers the work and surfaces the replies through the same poll idiom. Where the main thread gets the assembly session of the run it applied (HistoryRunner::session_for_main).

Constants§

CAM_TRIANGLE_BUDGET
The most triangles a CAM job’s part mesh may have (the triangle index and the drop-cutter queries scale with it).
UNASSIGNED_REGION
Unassigned triangles’ region id, re-exported for callers colouring them.

Traits§

HistoryRunner

Functions§

apply_region_choices_reply
Apply region choices wherever the runner runs.
process_command
Execute ONE Command against runner and return the Reply it produces, if any. The shared step both async drivers run: the native thread_main calls it for each (post-coalescing) command on the runner thread; the wasm WorkerRunner’s worker_entry calls it per postMessage on the worker. Run → a Reply::Run; Query → a Reply::Query; Reset drops the delta baseline AND the runner’s OWN kernel history cache (the resident registry lives with the runner — thread or worker — not on main) and yields no reply.
region_fit_reply
Run a region refit wherever the runner runs.
set_reply_waker
Install (or with None remove) the hook a runner thread calls after each reply it posts. The desktop event loop installs its own waker here.