Vixen
dd8b0a81
csharp
public sealed class CompilerPool

Runs importers in worker processes, and survives one of them dying.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The promise is crash isolation, and it is not the same promise an exception handler makes. ImportPipeline already catches an importer that throws and fails that one asset. What it cannot catch is an importer that takes the process down — a malformed FBX inside a C++ library, a stack overflow inside a recursive scene graph, a native access violation. Doc 08 calls that the difference between "one bad file" and "the editor won't open", and the only way to have it is a process boundary.

One pipe per worker, not one pipe with many instances. A shared pipe would need every message to carry a correlation id and every worker to be told which replies are its own; a pipe per worker makes a request and its response the only two things on that stream, so the framing is a length prefix and nothing else.

Artefacts come back over the wire rather than being written by the worker. N processes writing into one content-addressed store is a correctness problem — partial files, torn reads, no single place that knows what was written — for a saving that is a memory copy. The coordinator stays the only writer, which is also what keeps the cache and the sidecars in one copy.

The pool runs as many imports at once as it is given, and it is now given several. ImportPipeline dispatches MaxConcurrency jobs at a time and keeps a dependent's answer identical to the path-ordered loop's by waiting per asset rather than by serialising the run — so WorkerCount is a real ceiling rather than a number nothing reached. What crosses the pipe is unchanged: one asset's worth of work, with the coordinator still the only writer.

Fields and properties (3)

  • public int WorkerCount

    How many workers it may run at once.

  • public int Restarts

    How many times a worker has died and been replaced.

  • public IReadOnlyList<string> UnreachableImporters

    Contributed importers no worker can be given, because they have no file.

Methods (4)

  • public CompilerPool(string projectRoot, int workers = 0, IReadOnlyList<string>? workerCommand = null, ImporterContributions? contributed = null)

    Starts a pool over a project.

  • public static IReadOnlyList<string> DefaultCommand()

    How to start a worker when nobody said.

  • public ValueTask<ExecutedImport> ExecuteAsync(ImportJob job, CancellationToken cancellationToken = default(CancellationToken))

    Runs one import.

  • public void Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Used by (4)

  • CompilerPoolTestsVixen.AssetCompiler.Tests
  • ImportRunnerVixen.Cli
  • PluginImporterTestsVixen.AssetCompiler.Tests
  • WorkerVixen.AssetCompiler