pub trait Payload:
Sized
+ Send
+ 'static {
// Required methods
fn new_pair() -> (Self, Self);
fn prepare(&mut self);
fn process(&mut self);
}
Expand description
One benchmark payload, to be processed by each worker involved in each benchmark.
Payloads are created in pairs because the workers are created in pairs. Depending on the benchmark scenario, the pair of payloads may be connected (e.g. reader and writer) or independent (equivalent, two workers doing the same thing).
The lifecycle of a payload is:
- A payload pair is created on the main thread.
- Each payload in the pair is transferred to a specific thread hosting a specific worker.
- The
prepare()
method is called to generate any input data. - The payload pair is exchanged between the two paired workers.
- The
process()
method is called to process the data received from the other pair member. - The payload pair is dropped.
Note that some work distribution modes (named *Self
) may skip
the payload exchange step.
Required Methods§
Sourcefn new_pair() -> (Self, Self)
fn new_pair() -> (Self, Self)
Creates the payload pair that will be used to initialize one worker pair in one benchmark iteration. This will be called on the main thread.
Sourcefn prepare(&mut self)
fn prepare(&mut self)
Performs any initialization required. This will be called before the benchmark time span measurement starts. It will be called on a worker thread but the payload may be moved to a different worker thread before the benchmark starts (as workers by default prepare work for each other, to showcase what happens when the work is transferred between threads).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.