/// Returns the result of invoking `xnet_client.query()` against an HTTP server
/// in a spawned thread that processes a single request using `handle_request`.
Returns the result of invoking `xnet_client.query()` against an HTTP server
in a spawned thread that processes a single request using `handle_request`.
Returns the result of invoking ` xnet_client . query () ` against an HTTP server in a spawned thread that processes a single request using ` handle_request ` .
fn do_xnet_client_query<H: Fn(Request) + Send + 'static>(
    xnet_client: XNetClientImpl,
    handle_request: H,
) -> Result<CertifiedStreamSlice, XNetClientError> {
    let (server, uri) = get_server_and_url_for_test();
    // Use a barrier to ensure we only query after the server thread is running.
    let barrier = Arc::new(Barrier::new(2));
    let server_barrier = barrier.clone();
    // Spawn thread to have `server` handle a single request, using
    // `handle_request`.
    let join_handle = std::thread::spawn(move || {
        server_barrier.wait();
        match server.recv() {
            Ok(request) => handle_request(request),
            Err(e) => panic!("server.recv() returned error: {}", e),
        }
    });
    barrier.wait();
    let result = do_async_query(xnet_client, uri);
    // Join the server thread, ensure it didn't panic.
    join_handle
        .join()
        .unwrap_or_else(|e| panic!("Server thread has panicked: {:?}", e));
    result
}
fn do_xnet_client_query < H : Fn ( Request ) + Send + ' static > ( xnet_client : XNetClientImpl , handle_request : H , ) -> Result < CertifiedStreamSlice , XNetClientError > { let ( server , uri ) = get_server_and_url_for_test ( ) ; // Use a barrier to ensure we only query after the server thread is running. let barrier = Arc :: new ( Barrier :: new ( 2 ) ) ; let server_barrier = barrier . clone ( ) ; // Spawn thread to have `server` handle a single request, using // `handle_request`. let join_handle = std :: thread :: spawn ( move | | { server_barrier . wait ( ) ; match server . recv ( ) { Ok ( request ) => handle_request ( request ) , Err ( e ) => panic ! ( " " e ) , } } ) ; barrier . wait ( ) ; let result = do_async_query ( xnet_client , uri ) ; // Join the server thread, ensure it didn't panic. join_handle . join ( ) . unwrap_or_else ( | e | panic ! ( " " e ) ) ; result }
Returns the result of invoking `xnet_client.query()` against an HTTP server
in a spawned thread that processes a single request using `handle_request`.
Returns the result of invoking ` xnet_client . query () ` against an HTTP server in a spawned thread that processes a single request using ` handle_request ` .
xnet_client
XNetClientImpl
handle_request
H