Obsidian
Probabilistic Geophysical Joint Inversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
stateline::comms::Requester Class Reference

Requester object that takes jobs and returns results. Communicates with a delegator living in a (possibly) different thread. More...

#include <requester.hpp>

Public Member Functions

 Requester (Delegator &d)
 Create a new Requester. More...
 
ResultData operator() (const JobData &j)
 Computes a job and returns a result. More...
 
void submit (uint id, const JobData &j)
 Submits a job for computation and immediately returns. An id is included to allow the job to be identified later, because when jobs are retrieved they may not arrive in the order they were submitted. More...
 
std::pair< uint, ResultDataretrieve ()
 Retrieves a job that has previously been submitted for computation. A pair is returned, with the id of the job (from the submit call), and the result. Note that jobs may not be retrieved in the order they were submitted. More...
 
std::vector< ResultDatabatch (const std::vector< JobData > &jobs)
 Computes a batch of jobs and returns a result. The function returns when all results have been returned. More...
 
void batchSubmit (uint id, const std::vector< JobData > &jobs)
 Submits a batch of jobs for computation and immediately returns. An id is included to allow the batch to be identified later, because when batches are retrieved they may not arrive in the order they were submitted. More...
 
std::pair< uint, std::vector
< ResultData > > 
batchRetrieve ()
 Retrieves a batch of jobs that have previously been submitted for computation. A pair is returned, with the id of the batch (from the submit call), and the results. Note that batch may not be retrieved in the order they were submitted. More...
 

Detailed Description

Requester object that takes jobs and returns results. Communicates with a delegator living in a (possibly) different thread.

Template Parameters
JobTypeThe type of a job specification.
ResultTypeThe type being return as a result. /

Constructor & Destructor Documentation

stateline::comms::Requester::Requester ( Delegator d)

Create a new Requester.

Parameters
dA reference to the delegator object to communicate with

Member Function Documentation

std::vector< ResultData > stateline::comms::Requester::batch ( const std::vector< JobData > &  jobs)

Computes a batch of jobs and returns a result. The function returns when all results have been returned.

Warning
Do not interleave different types of job call pairs and blocking calls. This will break horribly. For example, don't call submit in between batchsubmit and batch retrieve.
Parameters
jobsThe vector of jobs to compute
Returns
The results of the job computations
std::pair< uint, std::vector< ResultData > > stateline::comms::Requester::batchRetrieve ( )

Retrieves a batch of jobs that have previously been submitted for computation. A pair is returned, with the id of the batch (from the submit call), and the results. Note that batch may not be retrieved in the order they were submitted.

Warning
Do not interleave different types of job call pairs and blocking calls. This will break horribly. For example, don't call submit in between batchsubmit and batch retrieve.
Returns
A pair of the job id and the result
void stateline::comms::Requester::batchSubmit ( uint  id,
const std::vector< JobData > &  jobs 
)

Submits a batch of jobs for computation and immediately returns. An id is included to allow the batch to be identified later, because when batches are retrieved they may not arrive in the order they were submitted.

Warning
Do not interleave different types of job call pairs and blocking calls. This will break horribly. For example, don't call submit in between batchsubmit and batch retrieve.
Parameters
idThe id of the batch
jobsThe vector of jobs to compute
Returns
The results of the job computations
ResultData stateline::comms::Requester::operator() ( const JobData j)

Computes a job and returns a result.

Warning
Do not interleave different types of job call pairs and blocking calls. This will break horribly. For example, don't call submit in between batchsubmit and batch retrieve.
Parameters
jThe job to compute.
Returns
The result of the job computation.
std::pair< uint, ResultData > stateline::comms::Requester::retrieve ( )

Retrieves a job that has previously been submitted for computation. A pair is returned, with the id of the job (from the submit call), and the result. Note that jobs may not be retrieved in the order they were submitted.

Warning
Do not interleave different types of job call pairs and blocking calls. This will break horribly. For example, don't call submit in between batchsubmit and batch retrieve.
Returns
A pair of the job id and the result
void stateline::comms::Requester::submit ( uint  id,
const JobData j 
)

Submits a job for computation and immediately returns. An id is included to allow the job to be identified later, because when jobs are retrieved they may not arrive in the order they were submitted.

Warning
Do not interleave different types of job call pairs and blocking calls. This will break horribly. For example, don't call submit in between batchsubmit and batch retrieve.
Parameters
idThe job ID.
jThe job to compute.

The documentation for this class was generated from the following files: