fn initialize() -> RunLoop {
    let pair = std::sync::Arc::new((
        std::sync::Mutex::new(None),
        std::sync::Condvar::new(),
    ));
    let pair2 = Arc::clone(&pair);
    std::thread::spawn(move || {
        let (lock, cvar) = &*pair2;
        let mut started = lock.lock().unwrap();
        // Get the run loop associated with this thread.
        let run_loop = unsafe { CFRunLoopGetCurrent() };
        *started = Some(run_loop);
        cvar.notify_one();
        // Block this thread with the run loop until the process exits.
        unsafe { CFRunLoopRun() }
    });

    // Wait to get the thread's Run Loop handle.
    let (lock, cvar) = &*pair;
    let mut started = lock.lock().unwrap();
    let run_loop = loop {
        if let Some(run_loop) = started.take() {
            break run_loop;
        }
        started = cvar.wait(started).unwrap();
    };
    run_loop
}
/// Global initialization, may be called more than once.
Global initialization, may be called more than once.
Global initialization may be called more than once .
fn initialize() -> RunLoop {
    let pair = std::sync::Arc::new((
        std::sync::Mutex::new(None),
        std::sync::Condvar::new(),
    ));
    let pair2 = Arc::clone(&pair);
    std::thread::spawn(move || {
        let (lock, cvar) = &*pair2;
        let mut started = lock.lock().unwrap();
        // Get the run loop associated with this thread.
        let run_loop = unsafe { CFRunLoopGetCurrent() };
        *started = Some(run_loop);
        cvar.notify_one();
        // Block this thread with the run loop until the process exits.
        unsafe { CFRunLoopRun() }
    });
    // Wait to get the thread's Run Loop handle.
    let (lock, cvar) = &*pair;
    let mut started = lock.lock().unwrap();
    let run_loop = loop {
        if let Some(run_loop) = started.take() {
            break run_loop;
        }
        started = cvar.wait(started).unwrap();
    };
    run_loop
}
fn initialize ( ) -> RunLoop { let pair = std :: sync :: Arc :: new ( ( std :: sync :: Mutex :: new ( None ) , std :: sync :: Condvar :: new ( ) , ) ) ; let pair2 = Arc :: clone ( & pair ) ; std :: thread :: spawn ( move | | { let ( lock , cvar ) = & * pair2 ; let mut started = lock . lock ( ) . unwrap ( ) ; // Get the run loop associated with this thread. let run_loop = unsafe { CFRunLoopGetCurrent ( ) } ; * started = Some ( run_loop ) ; cvar . notify_one ( ) ; // Block this thread with the run loop until the process exits. unsafe { CFRunLoopRun ( ) } } ) ; // Wait to get the thread's Run Loop handle. let ( lock , cvar ) = & * pair ; let mut started = lock . lock ( ) . unwrap ( ) ; let run_loop = loop { if let Some ( run_loop ) = started . take ( ) { break run_loop ; } started = cvar . wait ( started ) . unwrap ( ) ; } ; run_loop }
Global initialization, may be called more than once.
Global initialization may be called more than once .