This class wraps around the socket used for communication to the background worker and implements a simple messaging mechanism. More...
#include <BackgroundSocket.h>
Public Types | |
enum | Type { T_START_JOB, T_SET_INPUT_FILE, T_SET_ENTRY, T_EXECUTE, T_EXECUTE_CONFIRM, T_END_JOB, T_END_JOB_CONFIRM, T_INVALID } |
the type of message we send around More... | |
Public Member Functions | |
void | testInvariant () const |
test the invariant of this object | |
BackgroundSocket (int val_socket) | |
standard constructor | |
~BackgroundSocket () | |
standard destructor | |
void | write (Type type, const std::string &payload) |
write a message to the socket | |
void | read (Type &type, std::string &payload) |
read a message from the socket | |
Static Public Member Functions | |
static void | makeSockets (int sockets[2]) |
make a pair of sockets suitable for communication | |
static std::auto_ptr < BackgroundSocket > | startWorker (const BackgroundJob &job) |
start a background worker connected by socket |
This class wraps around the socket used for communication to the background worker and implements a simple messaging mechanism.
Messages here just consist of a type and a string as a payload. We do not worry about bringing thinks into a portable format, as this is only meant for communicating between machines employing the same architecture.
the type of message we send around
T_START_JOB |
start the job the payload indicates a file containing the information about the job. |
T_SET_INPUT_FILE |
set the next input file the payload is the name of the file to open |
T_SET_ENTRY |
set the tree entry the payload is a Long64_t wrapped into a string that contains the tree entry |
T_EXECUTE |
execute the event there is no payload for this |
T_EXECUTE_CONFIRM |
confirm a T_EXECUTE |
T_END_JOB |
end the job the payload indicates a file to which to save the histogram information. |
T_END_JOB_CONFIRM |
confirm a T_END_JOB |
T_INVALID |
an invalid message this is guaranteed to be the last entry in the enum, so that it can be used to check that the enum is read correctly |
EL::BackgroundSocket::BackgroundSocket | ( | int | val_socket | ) |
standard constructor
EL::BackgroundSocket::~BackgroundSocket | ( | ) |
standard destructor
void EL::BackgroundSocket::makeSockets | ( | int | sockets[2] | ) | [static] |
make a pair of sockets suitable for communication
I rather do this myself instead of leaving it to the user, as this allows me to make sure the settings are correct.
void EL::BackgroundSocket::read | ( | Type & | type, | |
std::string & | payload | |||
) |
read a message from the socket
std::auto_ptr< BackgroundSocket > EL::BackgroundSocket::startWorker | ( | const BackgroundJob & | job | ) | [static] |
start a background worker connected by socket
void EL::BackgroundSocket::testInvariant | ( | ) | const |
test the invariant of this object
void EL::BackgroundSocket::write | ( | Type | type, | |
const std::string & | payload | |||
) |
write a message to the socket