Launch single-thread executor on own thread

[?]
Oct 27, 2018, 1:54 PM
6DSWVNSYTGYN33VFBLXK655PFELW5ED2IFB2IZVHM4X277QRVUFAC

Dependencies

  • [2] HKSQO7JZ Enable hyper http server and configuration
  • [3] FVVPKFTL Initial commit

Change contents

  • edit in src/main.rs at line 1
    [2.21]
    [2.21]
    #![deny(missing_docs)]
    //! XMPP client service
  • edit in src/main.rs at line 17
    [2.275]
    [2.275]
    use tokio::prelude::future;
    use tokio::runtime::current_thread;
  • replacement in src/main.rs at line 57
    [2.1350][2.1350:1383]()
    hyper::rt::run(http_server);
    [2.1350]
    [3.61]
    let mut rt = Runtime::new().expect("Cann't start tokio");
    rt.spawn(http_server);
    let xmpp_join = std::thread::spawn(|| -> Result<(), tokio::io::Error> {
    // Launch single-threaded runtime
    let mut ctrt = current_thread::Runtime::new()?;
    ctrt.block_on(future::ok::<_, tokio::io::Error>(()))
    });
    println!("Server started");
    rt.shutdown_on_idle().wait().expect("Shutdown error");
    println!("Server stopper");
    xmpp_join
    .join()
    .expect("Join xmpp thread")
    .expect("Result xmpp thread");