MCPcopy Index your code
hub / github.com/encounter/objdiff / start_job

Function start_job

objdiff-core/src/jobs/mod.rs:173–200  ·  view source on GitHub ↗
(
    waker: Waker,
    title: &str,
    kind: Job,
    run: impl FnOnce(JobContext, Receiver<()>) -> Result<JobResult> + Send + 'static,
)

Source from the content-addressed store, hash-verified

171}
172
173fn start_job(
174 waker: Waker,
175 title: &str,
176 kind: Job,
177 run: impl FnOnce(JobContext, Receiver<()>) -> Result<JobResult> + Send + 'static,
178) -> JobState {
179 let status = Arc::new(RwLock::new(JobStatus {
180 title: title.to_string(),
181 progress_percent: 0.0,
182 progress_items: None,
183 status: String::new(),
184 error: None,
185 }));
186 let context = JobContext { status: status.clone(), waker: waker.clone() };
187 let context_inner = JobContext { status: status.clone(), waker };
188 let (tx, rx) = std::sync::mpsc::channel();
189 let handle = std::thread::spawn(move || match run(context_inner, rx) {
190 Ok(state) => state,
191 Err(e) => {
192 if let Ok(mut w) = status.write() {
193 w.error = Some(e);
194 }
195 JobResult::None
196 }
197 });
198 let id = JOB_ID.fetch_add(1, Ordering::Relaxed);
199 JobState { id, kind, handle: Some(handle), context, cancel: tx }
200}
201
202fn update_status(
203 context: &JobContext,

Callers 4

start_create_scratchFunction · 0.85
start_check_updateFunction · 0.85
start_updateFunction · 0.85
start_buildFunction · 0.85

Calls 2

runFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected