Skip to content

Commit

Permalink
Add more code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
acharron-hl committed Feb 11, 2025
1 parent 4564daf commit 66ffb69
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/wkwebview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,7 @@ unsafe fn window_position(view: &NSView, x: i32, y: i32, height: f64) -> CGPoint
CGPoint::new(x as f64, frame.size.height - y as f64 - height)
}

/// Wait synchronously for the NSRunLoop to run until a receiver has a message.
unsafe fn wait_for_blocking_operation<T>(rx: std::sync::mpsc::Receiver<T>) -> Result<T> {
let interval = 0.0002;
let limit = 1.;
Expand All @@ -1064,13 +1065,12 @@ unsafe fn wait_for_blocking_operation<T>(rx: std::sync::mpsc::Receiver<T>) -> Re
let limit_date = NSDate::dateWithTimeIntervalSinceNow(interval);

let mode = NSString::from_str("NSDefaultRunLoopMode");

println!("Looping for cookies response");
rl.acceptInputForMode_beforeDate(&mode, &limit_date);
thread::sleep(Duration::from_secs_f64(interval));

if let Ok(response) = rx.try_recv() {
// Extra 1ms just to make sure our runloop is cleared.
// See https://github.com/tauri-apps/wry/pull/1486 for a writeup of why this was added.
thread::sleep(Duration::from_millis(1));
return Ok(response);
}
Expand Down

0 comments on commit 66ffb69

Please sign in to comment.