🐛 fix(main): 修复了在主线程中错误地使用线程的问题, 将部分功能移出线程以避免潜在的竞态条件
This commit is contained in:
parent
1dc82485bd
commit
c2bb86a267
18
src/main.rs
18
src/main.rs
|
@ -77,16 +77,14 @@ fn main() {
|
|||
println!("L8 Frame Draw use time: {:?}", duration);
|
||||
})
|
||||
.unwrap();
|
||||
crossbeam::scope(|_| {
|
||||
let fltk_l_image =
|
||||
RgbImage::new(l_data.as_raw(), w, h, ColorDepth::L8).unwrap();
|
||||
camera_frame.set_image(Some(fltk_l_image));
|
||||
color_frame.set_size(w, h);
|
||||
camera_frame.redraw();
|
||||
let duration = start.elapsed();
|
||||
println!("RGB8 Frame Draw use time: {:?}", duration);
|
||||
})
|
||||
.unwrap();
|
||||
// 尝试将部分功能移出线程
|
||||
let fltk_l_image =
|
||||
RgbImage::new(l_data.as_raw(), w, h, ColorDepth::L8).unwrap();
|
||||
camera_frame.set_image(Some(fltk_l_image));
|
||||
color_frame.set_size(w, h);
|
||||
camera_frame.redraw();
|
||||
let duration = start.elapsed();
|
||||
println!("RGB8 Frame Draw use time: {:?}", duration);
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("捕获错误: {}", e);
|
||||
|
|
Loading…
Reference in New Issue