MCPcopy Create free account
hub / github.com/encounter/objdiff / collect_results

Method collect_results

objdiff-core/src/jobs/mod.rs:101–139  ·  view source on GitHub ↗

Collects the results of all finished jobs and handles any errors.

(&mut self)

Source from the content-addressed store, hash-verified

99
100 /// Collects the results of all finished jobs and handles any errors.
101 pub fn collect_results(&mut self) {
102 let mut results = vec![];
103 for (job, result) in self.iter_finished() {
104 match result {
105 Ok(result) => {
106 match result {
107 JobResult::None => {
108 // Job context contains the error
109 }
110 _ => results.push(result),
111 }
112 }
113 Err(err) => {
114 let err = if let Some(msg) = err.downcast_ref::<&'static str>() {
115 anyhow::Error::msg(*msg)
116 } else if let Some(msg) = err.downcast_ref::<String>() {
117 anyhow::Error::msg(msg.clone())
118 } else {
119 anyhow::Error::msg("Thread panicked")
120 };
121 let result = job.context.status.write();
122 if let Ok(mut guard) = result {
123 guard.error = Some(err);
124 } else {
125 drop(result);
126 job.context.status = Arc::new(RwLock::new(JobStatus {
127 title: "Error".to_string(),
128 progress_percent: 0.0,
129 progress_items: None,
130 status: String::new(),
131 error: Some(err),
132 }));
133 }
134 }
135 }
136 }
137 self.results.append(&mut results);
138 self.clear_finished();
139 }
140}
141
142#[derive(Clone)]

Callers 2

pre_updateMethod · 0.80
check_jobsMethod · 0.80

Calls 4

iter_finishedMethod · 0.80
pushMethod · 0.80
clear_finishedMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected