pub fn create() -> Result<Handle, Error> {
    let create_start = Instant::now();

    let (message_tx, message_rx) = crossbeam_channel::unbounded();
    let (notify_tx, notify_rx) = notify::create()?;

    let handle_inner = Arc::new(HandleInner {
        message_tx,
        notify_tx,
        thread_terminated: AtomicBool::default(),
    });
    let handle_weak = Arc::downgrade(&handle_inner);

    thread::Builder::new().name(String::from(AGENT_THREAD_NAME)).spawn(move || {
        let agent = Agent {
            multi: curl::multi::Multi::new(),
            multi_messages: crossbeam_channel::unbounded(),
            message_rx,
            notify_rx,
            requests: Slab::new(),
            close_requested: false,
            handle: handle_weak,
        };

        debug!("agent took {:?} to start up", create_start.elapsed());

        // Intentionally panic the thread if an error occurs.
        agent.run().unwrap();
    })?;

    Ok(Handle {
        inner: handle_inner,
    })
}
/// Create an agent that executes multiple curl requests simultaneously.
///
/// The agent maintains a background thread that multiplexes all active requests using a single "multi" handle.
Create an agent that executes multiple curl requests simultaneously.
The agent maintains a background thread that multiplexes all active requests using a single "multi" handle.
Create an agent that executes multiple curl requests simultaneously . The agent maintains a background thread that multiplexes all active requests using a single " multi " handle .
pub fn create() -> Result<Handle, Error> {
    let create_start = Instant::now();
    let (message_tx, message_rx) = crossbeam_channel::unbounded();
    let (notify_tx, notify_rx) = notify::create()?;
    let handle_inner = Arc::new(HandleInner {
        message_tx,
        notify_tx,
        thread_terminated: AtomicBool::default(),
    });
    let handle_weak = Arc::downgrade(&handle_inner);
    thread::Builder::new().name(String::from(AGENT_THREAD_NAME)).spawn(move || {
        let agent = Agent {
            multi: curl::multi::Multi::new(),
            multi_messages: crossbeam_channel::unbounded(),
            message_rx,
            notify_rx,
            requests: Slab::new(),
            close_requested: false,
            handle: handle_weak,
        };
        debug!("agent took {:?} to start up", create_start.elapsed());
        // Intentionally panic the thread if an error occurs.
        agent.run().unwrap();
    })?;
    Ok(Handle {
        inner: handle_inner,
    })
}
pub fn create ( ) -> Result < Handle , Error > { let create_start = Instant :: now ( ) ; let ( message_tx , message_rx ) = crossbeam_channel :: unbounded ( ) ; let ( notify_tx , notify_rx ) = notify :: create ( ) ? ; let handle_inner = Arc :: new ( HandleInner { message_tx , notify_tx , thread_terminated : AtomicBool :: default ( ) , } ) ; let handle_weak = Arc :: downgrade ( & handle_inner ) ; thread :: Builder :: new ( ) . name ( String :: from ( AGENT_THREAD_NAME ) ) . spawn ( move | | { let agent = Agent { multi : curl :: multi :: Multi :: new ( ) , multi_messages : crossbeam_channel :: unbounded ( ) , message_rx , notify_rx , requests : Slab :: new ( ) , close_requested : false , handle : handle_weak , } ; debug ! ( " " create_start elapsed ( ) ) ; // Intentionally panic the thread if an error occurs. agent . run ( ) . unwrap ( ) ; } ) ? ; Ok ( Handle { inner : handle_inner , } ) }
Create an agent that executes multiple curl requests simultaneously.
Create an agent that executes multiple curl requests simultaneously .