[][src]Macro batched_fn::batched_fn

macro_rules! batched_fn {
    (
        |$batch:ident: $batch_input_type:ty| -> $batch_output_type:ty $fn_body:block,
        max_batch_size = $max_batch_size:expr,
        delay = $delay:expr $(,)?
    ) => { ... };
    (
        |$batch:ident: $batch_input_type:ty| -> $batch_output_type:ty $fn_body:block,
        delay = $delay:expr,
        max_batch_size = $max_batch_size:expr $(,)?
    ) => { ... };
    (
        |$batch:ident: $batch_input_type:ty, $ctx:ident: &$ctx_type:ty| -> $batch_output_type:ty $fn_body:block,
        max_batch_size = $max_batch_size:expr,
        delay = $delay:expr $(,)?
    ) => { ... };
    (
        |$batch:ident: $batch_input_type:ty, $ctx:ident: &$ctx_type:ty| -> $batch_output_type:ty $fn_body:block,
        delay = $delay:expr,
        max_batch_size = $max_batch_size:expr $(,)?
    ) => { ... };
}

Macro for creating a batched function.

This macro has 3 parameters. The first parameter must be the batch handler closure. This is where the actual logic goes for handling a batch of inputs. The two other parameters are must be given by name: delay and max_batch_size.

handler

The handler must be in the form of a closure declaration that takes a batch as input and outputs a different type of batch.

Optionally the closure can also take second argument: a reference to an arbitrary context struct, provided that struct implements Default.

delay

This is the maximum number of milliseconds to wait for a batch to be filled after receiving a single input.

max_batch_size

This is the maximum batch size that will be passed to the batch handler. When a batch of this size is not filled before delay milliseconds the partial batch will be sent to the handler as-is.