Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit async builder with new thread. #172

Merged
merged 2 commits into from
Mar 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions implants/golem/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ async fn execute_tomes_in_parallel(tome_name_and_content: Vec<(String, String)>)
Ok((error_code, result))
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
fn main() -> anyhow::Result<()> {
let matches = Command::new("golem")
.arg(Arg::with_name("INPUT")
.help("Set the tomes to run")
Expand All @@ -85,7 +84,22 @@ async fn main() -> anyhow::Result<()> {
tome_files_and_content.push( (tome_path, tome_contents) )
}

let (error_code, result) = execute_tomes_in_parallel(tome_files_and_content).await?;
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();


let (error_code, result) = match runtime.block_on(
execute_tomes_in_parallel(tome_files_and_content)
) {
Ok(response) => response,
Err(error) => {
println!("Error executing tomes {:?}", error);
(-1, Vec::new())
},
};

if result.len() > 0 {
println!("{:?}", result);
}
Expand Down Expand Up @@ -120,8 +134,22 @@ async fn main() -> anyhow::Result<()> {
tome_files_and_content.push( (tome_path, tome_contents) )
}

}
let (error_code, result) = execute_tomes_in_parallel(tome_files_and_content).await?;
}
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();

let (error_code, result) = match runtime.block_on(
execute_tomes_in_parallel(tome_files_and_content)
) {
Ok(response) => response,
Err(error) => {
println!("Error executing tomes {:?}", error);
(-1, Vec::new())
},
};

if result.len() > 0 {
println!("{:?}", result);
}
Expand Down