[WIP] compiler_base_parallel
Summary
compiler_base_parallel defines the core logic for multitasking execution engine. It aims to provide reusable components and accumulate some general concurrency models for compiler developments.
The compiler_base_parallel crate consists of three main components: Task, Executor, and Reporter.
Task
Task is the smallest executable unit, anything can be considered as a Task can be executed by Executor. Therefore, we provide a trait to define a Task.
To develop a concurrency mechanism for a compiler in a compiler_base_parallel-way, the first step is to create a Task.
For more information about Task, see the docs in source code in ./src/task/mod.rs.
Executor
Executor is responsible for executing the Task.
We also provide a trait to define a Executor.
For more information about Executor, see docs in source code in ./src/executor/mod.rs.
TimeoutExecutor
TimeoutExecutor refers to the concurrency mechanism adopted by rustc in the rust unit testing and mainly contains the following features:
-
Tasks are executed concurrently based on the number of threads.
-
A timeout queue is used to monitor the execution of the
Taskhas timed out. If it does, a warning will be reported, but theTaskwill not stop and will run until it is manually interrupted.
If you want to implement unit testing, fuzz, bench or other you want to do in parallel in your compiler using the same workflow as rustc testing, you can use the TimeoutExecutor. If this workflow is not suitable for your compiler, you can choose to implement your own Executor.