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

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

#include <delegator.hpp>

Public Member Functions

 Delegator (const std::string &commonSpecData, const std::vector< uint > &jobId, const std::vector< std::string > &jobSpecData, const std::vector< std::string > &jobResultsData, const DelegatorSettings &settings)
 Create a new delegator. More...
 
 ~Delegator ()
 Safely stops all polling threads and cleans up.
 
zmq::context_t & zmqContext ()
 Return a reference to the context object owned by the delegator. this allows a requester to use inproc sockets and connect. More...
 
void start ()
 Start the delegator socket polling.
 
void stop ()
 Stop the delegator socket polling.
 
void sendWorkerProblemSpec (const Message &m)
 Initialise a worker by giving it the problem specification. More...
 
void connectWorker (const Message &m)
 Connect a worker that has previously been sent a problem spec. More...
 
void sendJob (const Message &m)
 Send a job to a worker that has requested one. More...
 
void disconnectWorker (const Message &m)
 Disconnect a worker by removing it from the list of connected workers. More...
 
void sendFailed (const Message &m)
 When a send fails, we disconnect the worker. More...
 
void jobRequest (const Message &m)
 Process a job request by sending a job to the worker if available, otherwise add to a needs job queue. More...
 
void jobSwap (const Message &m)
 Get a result from a worker, then swap it for a new job. More...
 
void newJob (const Message &m)
 Receive a new job from the requesters, and add it to the queue or send it directly to an idle worker. More...
 

Detailed Description

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

Constructor & Destructor Documentation

stateline::comms::Delegator::Delegator ( const std::string &  commonSpecData,
const std::vector< uint > &  jobId,
const std::vector< std::string > &  jobSpecData,
const std::vector< std::string > &  jobResultsData,
const DelegatorSettings settings 
)

Create a new delegator.

Parameters
commonSpecDataThe serialised common problem specification.
jobIdThe available job IDs.
jobSpecDataThe serialised problem specifications for each job.
jobResultsDataThe serialised problem results for each job.
settingsThe configuration object.

Member Function Documentation

void stateline::comms::Delegator::connectWorker ( const Message m)

Connect a worker that has previously been sent a problem spec.

Parameters
mThe JOBREQUEST message the connecting worker sent.
void stateline::comms::Delegator::disconnectWorker ( const Message m)

Disconnect a worker by removing it from the list of connected workers.

Parameters
mThe GOODBYE message the connecting worker sent.
void stateline::comms::Delegator::jobRequest ( const Message m)

Process a job request by sending a job to the worker if available, otherwise add to a needs job queue.

Parameters
mThe JOBREQUEST message.
void stateline::comms::Delegator::jobSwap ( const Message m)

Get a result from a worker, then swap it for a new job.

Parameters
mThe JOBSWAP message.
void stateline::comms::Delegator::newJob ( const Message m)

Receive a new job from the requesters, and add it to the queue or send it directly to an idle worker.

Parameters
mThe JOBSWAP message.
void stateline::comms::Delegator::sendFailed ( const Message m)

When a send fails, we disconnect the worker.

Parameters
mThe message that failed to send.
void stateline::comms::Delegator::sendJob ( const Message m)

Send a job to a worker that has requested one.

Parameters
mthe job request message.
void stateline::comms::Delegator::sendWorkerProblemSpec ( const Message m)

Initialise a worker by giving it the problem specification.

Parameters
mThe HELLO message the new worker sent.
zmq::context_t& stateline::comms::Delegator::zmqContext ( )
inline

Return a reference to the context object owned by the delegator. this allows a requester to use inproc sockets and connect.

Returns
a reference to the zmq::context_t object

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