mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
Merge pull request #3003 from rtfeldman/threading
Explicit single vs multithreading for build functions
This commit is contained in:
commit
281602d664
16 changed files with 61 additions and 20 deletions
|
@ -950,6 +950,7 @@ fn enqueue_task<'a>(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn load_and_typecheck_str<'a>(
|
||||
arena: &'a Bump,
|
||||
filename: PathBuf,
|
||||
|
@ -958,6 +959,7 @@ pub fn load_and_typecheck_str<'a>(
|
|||
exposed_types: ExposedByModule,
|
||||
target_info: TargetInfo,
|
||||
render: RenderTarget,
|
||||
threading: Threading,
|
||||
) -> Result<LoadedModule, LoadingProblem<'a>> {
|
||||
use LoadResult::*;
|
||||
|
||||
|
@ -976,6 +978,7 @@ pub fn load_and_typecheck_str<'a>(
|
|||
target_info,
|
||||
cached_subs,
|
||||
render,
|
||||
threading,
|
||||
)? {
|
||||
Monomorphized(_) => unreachable!(""),
|
||||
TypeChecked(module) => Ok(module),
|
||||
|
@ -1093,6 +1096,12 @@ pub enum LoadResult<'a> {
|
|||
Monomorphized(MonomorphizedModule<'a>),
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum Threading {
|
||||
Single,
|
||||
Multi,
|
||||
}
|
||||
|
||||
/// The loading process works like this, starting from the given filename (e.g. "main.roc"):
|
||||
///
|
||||
/// 1. Open the file.
|
||||
|
@ -1146,10 +1155,11 @@ pub fn load<'a>(
|
|||
target_info: TargetInfo,
|
||||
cached_subs: MutMap<ModuleId, (Subs, Vec<(Symbol, Variable)>)>,
|
||||
render: RenderTarget,
|
||||
threading: Threading,
|
||||
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
|
||||
// When compiling to wasm, we cannot spawn extra threads
|
||||
// so we have a single-threaded implementation
|
||||
if cfg!(target_family = "wasm") {
|
||||
if threading == Threading::Single || cfg!(target_family = "wasm") {
|
||||
load_single_threaded(
|
||||
arena,
|
||||
load_start,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue