The Original CHomP Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
chomp::multiwork::mwSubWorker< dim, coord > Class Template Reference

This class defines a worker for the multi-work subdivision framework. More...

#include <mwsubdiv.h>

Inheritance diagram for chomp::multiwork::mwSubWorker< dim, coord >:
chomp::multiwork::mwWorker chomp::multiwork::mwTask

Public Member Functions

 mwSubWorker (fcompute _compute)
 The constructor. More...
 
- Public Member Functions inherited from chomp::multiwork::mwWorker
 mwWorker ()
 The default constructor. More...
 
virtual ~mwWorker ()
 The destructor. More...
 
int Work ()
 Runs the worker on this computer. More...
 
void KeepWorker (bool keep=true)
 Makes the worker keep running after the coordinator has disconnected. More...
 
- Public Member Functions inherited from chomp::multiwork::mwTask
 mwTask ()
 The default constructor. More...
 
virtual ~mwTask ()
 The destructor. More...
 
void Port (int number)
 Sets the port number for the communication or 0 to use none. More...
 
int Port () const
 Returns the current port number. More...
 
void ControlNumber (unsigned int number)
 Sets the control number for identification. More...
 
unsigned int ControlNumber () const
 Returns the currently set identification control number. More...
 
void TimeOut (int seconds)
 Sets the network connection time-out interval in seconds. More...
 
int TimeOut () const
 Returns the currently set network connection time-out interval. More...
 
int LogFile (const char *filename)
 Begins logging detailed communication debug information to the given file. More...
 
void LogFile (const mwTask &other)
 Uses another task's log file to log this task's information. More...
 
void LogClose ()
 Closes the log file and adds a line with the time information unless this log file was borrowed from another task. More...
 
int Add (const char *name, int port=-1)
 Adds an address to the list of computers to connect to at the beginning of working or coordinating. More...
 
int Load (const char *filename)
 Loads computer addresses from the given file. More...
 
int QuitWorkers ()
 Quits all the workers whose addresses were added with the 'Add' and 'Load' functions. More...
 

Private Member Functions

int Process (mwData &data)
 A function for processing the data by a worker. More...
 

Private Attributes

fcompute compute
 The address of a function to use for the computations. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from chomp::multiwork::mwTask
static int SendMessage (int fd, unsigned int ctrl, unsigned int code, const mwData &x)
 Sends a message with data to the given socket. More...
 
static int RecvMessage (int fd, unsigned int &ctrl, unsigned int &code, mwData &x)
 Receives a message with data from the given socket. More...
 
- Protected Attributes inherited from chomp::multiwork::mwTask
std::ofstream * logFile
 The debug log file stream. More...
 
std::vector< std::string > computers
 A list of workers or coordinators to connect to at start-up. More...
 
std::vector< int > ports
 A list of port numbers of workers to connect to at start-up. More...
 

Detailed Description

template<int dim, class coord>
class chomp::multiwork::mwSubWorker< dim, coord >

This class defines a worker for the multi-work subdivision framework.

Definition at line 107 of file mwsubdiv.h.

Constructor & Destructor Documentation

◆ mwSubWorker()

template<int dim, class coord >
chomp::multiwork::mwSubWorker< dim, coord >::mwSubWorker ( fcompute  _compute)
inline

The constructor.

Definition at line 125 of file mwsubdiv.h.

125 :
126 compute (_compute)
127{
128 return;
129} /* mwSubWorker<dim,coord>::mwSubWorker */
fcompute compute
The address of a function to use for the computations.
Definition: mwsubdiv.h:118

Member Function Documentation

◆ Process()

template<int dim, class coord >
int chomp::multiwork::mwSubWorker< dim, coord >::Process ( mwData data)
privatevirtual

A function for processing the data by a worker.

Reimplemented from chomp::multiwork::mwWorker.

Definition at line 134 of file mwsubdiv.h.

135{
136 // decode the number of the data pack to process
137 int current = 0;
138 data >> current;
139
140 // say which data pack is being processed
141 sout << "- " << current << ".\n";
142
143 // decode the subdivision level
144 int level = 0;
145 data >> level;
146
147 // decode the information on whether this is a full box or a probe
148 bool full = false;
149 data >> full;
150
151 // the intervals
152 double left [dim];
153 double right [dim];
154 for (int i = 0; i < dim; ++ i)
155 {
156 data >> left [i];
157 if (full)
158 data >> right [i];
159 }
160
161 // the marker of the end of data
162 int dataEndMarker = 0;
163 data >> dataEndMarker;
164 if (dataEndMarker != 13)
165 {
166 data. Reset ();
167 sout << "! Incompatible data received. Rejecting it.\n";
168 return mwReject;
169 }
170
171 // rune one set of computations
172 int result = compute (left, full ? right : left, dim, level);
173
174 // if the result is wrong then reject this piece of data
175 if (result < 0)
176 {
177 sout << "! Data no. " << current <<
178 " produced a negative result. Rejecting it.\n";
179 return mwReject;
180 }
181
182 // say what has been computed
183 sout << "= " << current << " " << result << ".\n";
184
185 // send back the data containing the result of the processing
186 data. Reset ();
187 data << current;
188 data << result;
189 return mwOk;
190} /* mwSubWorker<dim,coord>::Process */
outputstream sout
A replacement for standard output stream, with optional logging and other features provided by the cl...
@ mwReject
The data has been rejected.
Definition: mwconfig.h:169
@ mwOk
Everything is fine.
Definition: mwconfig.h:159

References chomp::multiwork::mwOk, chomp::multiwork::mwReject, and chomp::homology::sout.

Member Data Documentation

◆ compute

template<int dim, class coord >
fcompute chomp::multiwork::mwSubWorker< dim, coord >::compute
private

The address of a function to use for the computations.

Definition at line 118 of file mwsubdiv.h.


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