pub fn pair(
        service: T,
        max_items: usize,
        max_latency: std::time::Duration,
    ) -> (Self, Worker<T, Request>)
    where
        T: Send + 'static,
        T::Error: Send + Sync,
        Request: Send + 'static,
    {
        let (tx, rx) = mpsc::unbounded_channel();

        // The semaphore bound limits the maximum number of concurrent requests
        // (specifically, requests which got a `Ready` from `poll_ready`, but haven't
        // used their semaphore reservation in a `call` yet).
        // We choose a bound that allows callers to check readiness for every item in
        // a batch, then actually submit those items.
        let bound = max_items;
        let (semaphore, close) = Semaphore::new_with_close(bound);

        let (handle, worker) = Worker::new(service, rx, max_items, max_latency, close);
        let batch = Batch {
            tx,
            semaphore,
            handle,
        };

        (batch, worker)
    }
/// Creates a new `Batch` wrapping `service`, but returns the background worker.
///
/// This is useful if you do not want to spawn directly onto the `tokio`
/// runtime but instead want to use your own executor. This will return the
/// `Batch` and the background `Worker` that you can then spawn.
Creates a new `Batch` wrapping `service`, but returns the background worker.
This is useful if you do not want to spawn directly onto the `tokio`
runtime but instead want to use your own executor. This will return the
`Batch` and the background `Worker` that you can then spawn.
Creates a new ` Batch ` wrapping ` service ` but returns the background worker . This is useful if you do not want to spawn directly onto the ` tokio ` runtime but instead want to use your own executor . This will return the ` Batch ` and the background ` Worker ` that you can then spawn .
pub fn pair(
        service: T,
        max_items: usize,
        max_latency: std::time::Duration,
    ) -> (Self, Worker<T, Request>)
    where
        T: Send + 'static,
        T::Error: Send + Sync,
        Request: Send + 'static,
    {
        let (tx, rx) = mpsc::unbounded_channel();
        // The semaphore bound limits the maximum number of concurrent requests
        // (specifically, requests which got a `Ready` from `poll_ready`, but haven't
        // used their semaphore reservation in a `call` yet).
        // We choose a bound that allows callers to check readiness for every item in
        // a batch, then actually submit those items.
        let bound = max_items;
        let (semaphore, close) = Semaphore::new_with_close(bound);
        let (handle, worker) = Worker::new(service, rx, max_items, max_latency, close);
        let batch = Batch {
            tx,
            semaphore,
            handle,
        };
        (batch, worker)
    }
pub fn pair ( service : T , max_items : usize , max_latency : std :: time :: Duration , ) -> ( Self , Worker < T , Request > ) where T : Send + ' static , T :: Error : Send + Sync , Request : Send + ' static , { let ( tx , rx ) = mpsc :: unbounded_channel ( ) ; // The semaphore bound limits the maximum number of concurrent requests // (specifically, requests which got a `Ready` from `poll_ready`, but haven't // used their semaphore reservation in a `call` yet). // We choose a bound that allows callers to check readiness for every item in // a batch, then actually submit those items. let bound = max_items ; let ( semaphore , close ) = Semaphore :: new_with_close ( bound ) ; let ( handle , worker ) = Worker :: new ( service , rx , max_items , max_latency , close ) ; let batch = Batch { tx , semaphore , handle , } ; ( batch , worker ) }
Creates a new `Batch` wrapping `service`, but returns the background worker.
Creates a new ` Batch ` wrapping ` service ` but returns the background worker .
service
T
max_items
usize
max_latency
std::time::Duration