coin-Bcp
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | List of all members
BCP_single_environment Class Reference

#include <BCP_message_single.hpp>

Inheritance diagram for BCP_single_environment:
Inheritance graph
[legend]
Collaboration diagram for BCP_single_environment:
Collaboration graph
[legend]

Public Member Functions

void set_arguments (const int argnum, const char *const *args)
 
 BCP_single_environment ()
 
virtual ~BCP_single_environment ()
 
int register_process (USER_initialize *user_init)
 A process can register (receive its process id) with the message passing environment. More...
 
int parent_process ()
 Return the process id of the parent process (the process that spawned the currnet process. More...
 
bool alive (const int pid)
 Test if the process given by the argument is alive or not. More...
 
const int * alive (int num, const int *pids)
 Test if the processes given by the process array in the argument are alive or not. More...
 
void send (const int target, const BCP_message_tag tag)
 Send an empty message (message tag only) to the process given by the frist argument. More...
 
void send (const int target, const BCP_message_tag tag, const BCP_buffer &buf)
 Send the message in the buffer with the given message tag to the process given by the first argument. More...
 
void multicast (int num, const int *targets, const BCP_message_tag tag)
 Send an empty message (message tag only) to all the processes in the process array. More...
 
void multicast (int num, const int *targets, const BCP_message_tag tag, const BCP_buffer &buf)
 Send the message in the buffer with the given message tag to all processes in the process array. More...
 
void receive (const int source, const BCP_message_tag tag, BCP_buffer &buf, const double timeout)
 Blocking receive with timeout. More...
 
bool probe (const int source, const BCP_message_tag tag)
 Probe if there are any messages from the given process with the given message tag. More...
 
int start_process (const BCP_string &exe, const bool debug)
 Spawn a new process. More...
 
int start_process (const BCP_string &exe, const BCP_string &machine, const bool debug)
 Spawn a new process on the machine specified by the second argument. More...
 
bool start_processes (const BCP_string &exe, const int proc_num, const bool debug, int *ids)
 Spawn proc_num processes, all with the same executable. More...
 
bool start_processes (const BCP_string &exe, const int proc_num, const BCP_vec< BCP_string > &machines, const bool debug, int *ids)
 Spawn proc_num processes on the machines given by the third argument, all with the same executable. More...
 
- Public Member Functions inherited from BCP_message_environment
virtual ~BCP_message_environment ()
 Being virtual, the destructor invokes the destructor for the real type of the object being deleted. More...
 
virtual int num_procs ()
 Return the number of processes. More...
 

Protected Member Functions

 BCP_single_environment (int my_id)
 

Protected Attributes

int _argnum
 
char ** _arglist
 
int _my_id
 

Static Protected Attributes

static std::map< int,
BCP_process * > 
processes
 

Private Member Functions

 BCP_single_environment (const BCP_single_environment &)
 
BCP_single_environmentoperator= (const BCP_single_environment &)
 

Detailed Description

Definition at line 16 of file BCP_message_single.hpp.

Constructor & Destructor Documentation

BCP_single_environment::BCP_single_environment ( const BCP_single_environment )
private
BCP_single_environment::BCP_single_environment ( int  my_id)
inlineprotected

Definition at line 27 of file BCP_message_single.hpp.

BCP_single_environment::BCP_single_environment ( )
inline

Definition at line 33 of file BCP_message_single.hpp.

virtual BCP_single_environment::~BCP_single_environment ( )
virtual

Member Function Documentation

BCP_single_environment& BCP_single_environment::operator= ( const BCP_single_environment )
private
void BCP_single_environment::set_arguments ( const int  argnum,
const char *const *  args 
)
int BCP_single_environment::register_process ( USER_initialize user_init)
virtual

A process can register (receive its process id) with the message passing environment.

Implements BCP_message_environment.

int BCP_single_environment::parent_process ( )
virtual

Return the process id of the parent process (the process that spawned the currnet process.

Returns null if the process does not have a parent.

Implements BCP_message_environment.

bool BCP_single_environment::alive ( const int  pid)
virtual

Test if the process given by the argument is alive or not.

Return true if alive, false otherwise.

Implements BCP_message_environment.

const int* BCP_single_environment::alive ( int  num,
const int *  pids 
)
virtual

Test if the processes given by the process array in the argument are alive or not.

Return a pointer to the first dead process, or to the end of the array if there are no dead processes.

Implements BCP_message_environment.

void BCP_single_environment::send ( const int  target,
const BCP_message_tag  tag 
)
virtual

Send an empty message (message tag only) to the process given by the frist argument.

Implements BCP_message_environment.

void BCP_single_environment::send ( const int  target,
const BCP_message_tag  tag,
const BCP_buffer buf 
)
virtual

Send the message in the buffer with the given message tag to the process given by the first argument.

Implements BCP_message_environment.

void BCP_single_environment::multicast ( int  num,
const int *  targets,
const BCP_message_tag  tag 
)
virtual

Send an empty message (message tag only) to all the processes in the process array.

Implements BCP_message_environment.

void BCP_single_environment::multicast ( int  num,
const int *  targets,
const BCP_message_tag  tag,
const BCP_buffer buf 
)
virtual

Send the message in the buffer with the given message tag to all processes in the process array.

Implements BCP_message_environment.

void BCP_single_environment::receive ( const int  source,
const BCP_message_tag  tag,
BCP_buffer buf,
const double  timeout 
)
virtual

Blocking receive with timeout.

Wait until a message is received from the given process with the given message tag within the given timelimit. If timeout is positive then the receive routine times out after this many seconds. If it is negative then the method blocks until a message is received. The received message is saved into the buffer. With a 0 pointer as the first argument (or the predefined BCP_AnyProcess process id can be used) a message from any process will be accepted. Messages with any message tag are accepted if the second argument is BCP_Msg_AnyMessage.

Implements BCP_message_environment.

bool BCP_single_environment::probe ( const int  source,
const BCP_message_tag  tag 
)
virtual

Probe if there are any messages from the given process with the given message tag.

Return true if such a message is found, false otherwise. Note that the message is not "read", only its existence is checked. Similarly as above, the wild cards BCP_AnyProcess and BCP_Msg_AnyMessage can be used.

Implements BCP_message_environment.

int BCP_single_environment::start_process ( const BCP_string exe,
const bool  debug 
)
virtual

Spawn a new process.

The first argument contains the path to the executable to be spawned. If the second argument is set to true, then the executable is spawned under a debugger.

Implements BCP_message_environment.

int BCP_single_environment::start_process ( const BCP_string exe,
const BCP_string machine,
const bool  debug 
)
virtual

Spawn a new process on the machine specified by the second argument.

Implements BCP_message_environment.

bool BCP_single_environment::start_processes ( const BCP_string exe,
const int  proc_num,
const bool  debug,
int *  ids 
)
virtual

Spawn proc_num processes, all with the same executable.

NOTE: ids must be allocated already and have enough space for proc_num entries.

Returns
true/false depending on success.

Implements BCP_message_environment.

bool BCP_single_environment::start_processes ( const BCP_string exe,
const int  proc_num,
const BCP_vec< BCP_string > &  machines,
const bool  debug,
int *  ids 
)
virtual

Spawn proc_num processes on the machines given by the third argument, all with the same executable.

NOTE: ids must be allocated already and have enough space for proc_num entries.

Returns
true/false depending on success.

Implements BCP_message_environment.

Member Data Documentation

int BCP_single_environment::_argnum
protected

Definition at line 22 of file BCP_message_single.hpp.

char** BCP_single_environment::_arglist
protected

Definition at line 23 of file BCP_message_single.hpp.

int BCP_single_environment::_my_id
protected

Definition at line 30 of file BCP_message_single.hpp.

std::map<int, BCP_process*> BCP_single_environment::processes
staticprotected

Definition at line 31 of file BCP_message_single.hpp.


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