MCS
0.3.3-alpha7
|
Base class for MCS threaded objects. More...
#include <mcs.hh>
Public Member Functions | |
BaseThread (const BaseThread &) | |
Declared to avoid using of default copy constructor. More... | |
BaseThread (Thread *parent, int lID) | |
Constructor invoked from ClienThread objects. More... | |
BaseThread (Thread *parent, const char *ltID) | |
Constructor invoked from other objects. More... | |
int | chkExt (string &s) |
Check if an external program or script is registered in the configuration file. More... | |
BaseThread & | operator= (const BaseThread &) |
Declared to avoid using of default assignment operator. More... | |
const char * | tid () |
Return the thread identifier. More... | |
~BaseThread () | |
Destructor. More... | |
![]() | |
Event * | error () |
Return last error message. More... | |
int | id () |
Returns the Thread object identificator. More... | |
Thread * | parent () |
Returns the address of the parent. More... | |
void | start () |
Start a new thread in the joinable state. More... | |
void | startDetached (bool selfDelete=false) |
Start a new thread in the detached state. More... | |
int | state () |
Return the state of the thread. More... | |
void | stop () |
Stop thread execution. More... | |
Thread (int id=0, Thread *parent=NULL) | |
Declared to avoid using of default copy constructor. More... | |
virtual | ~Thread () |
Destructor. More... | |
Static Public Member Functions | |
static int | fileType (string fn) |
Determine the file type of an external program or script. More... | |
static int | spawn (string fn, string pars, string wpath=".", string thrID="x", string user="x", string pass="x", string dbname="x", string fout="out", string ferr="err") |
Execute an external program or script in a dedicated environment. More... | |
Protected Member Functions | |
RetValue | Log (Event e) |
Logging facility. More... | |
![]() | |
virtual void | final () |
Finalization method. More... | |
virtual void | initial () |
Initialization method. More... | |
virtual void | notify (int id, Thread *ref) |
A method called from child threads to notify their termination. More... | |
virtual void | run () |
Body of the thread execution. More... | |
void | set_cancel_state (bool cancel) |
Set cancellation state for current thread. More... | |
void | test_cancel () |
Test if a cancellation request is pending. More... | |
Static Protected Attributes | |
static Env * | env |
Pointer to the actual Env object, this can be seen in all threaded object. More... | |
Private Attributes | |
MCS_DEBUG_ALLOC | |
char | tID [4] |
Thread identifier stored as a null terminated string. More... | |
Additional Inherited Members | |
![]() | |
Event * | lerror |
Last error. More... | |
Base class for MCS threaded objects.
This is the basic class for all threaded objects inside MCS. It offers a log facility as well as a static access to a Env object.
mcs::BaseThread::BaseThread | ( | const BaseThread & | ) |
Declared to avoid using of default copy constructor.
mcs::BaseThread::BaseThread | ( | Thread * | parent, |
int | lID | ||
) |
Constructor invoked from ClienThread objects.
ClienThread objects are identified by a numeric identifier.
parent | Parent thread; |
lID | Numeric identifier. |
Definition at line 75 of file BaseThread.cc.
mcs::BaseThread::BaseThread | ( | Thread * | parent, |
const char * | ltID | ||
) |
Constructor invoked from other objects.
The other objects are identified by a mnemonic string identifier.
parent | Parent thread; |
ltID | String identifier. |
Definition at line 81 of file BaseThread.cc.
mcs::BaseThread::~BaseThread | ( | ) |
Destructor.
Definition at line 87 of file BaseThread.cc.
int mcs::BaseThread::chkExt | ( | string & | s | ) |
Check if an external program or script is registered in the configuration file.
The name (as registered in the configuration file) must be given as parameter. Upon return the parameter will contain the complete path to the real file.
An exception will be thrown if the external program or script is not registered in the configuration file or if the file type (as returned by ()) is fileType MCS_FT_UNKNOWN.
Definition at line 140 of file BaseThread.cc.
|
static |
Determine the file type of an external program or script.
This method is used when a user issue a MCS_CMD_EXEC command, to execute an external program or script, to determine the file type. Return value can be one of the following:
fn | Path to file. |
ERROR | MSG_CANT_OPEN_FILE. |
Definition at line 112 of file BaseThread.cc.
Logging facility.
e | Event object containing information about an event. |
Definition at line 29 of file BaseThread.cc.
BaseThread& mcs::BaseThread::operator= | ( | const BaseThread & | ) |
Declared to avoid using of default assignment operator.
|
static |
Execute an external program or script in a dedicated environment.
This routine will create an environment with the following variables, the content of which can be specified via this method's parameters:
Then the external program or script will be executed in the directory specified in the "wpath" parameter, and its standard output and error will be captured in the files specified in the "fout" and "ferr" parameters.
Scripts will be executed under the "sh" shell. The "wpath", "fout", "ferr" parameters can be either absolute paths or path relative to the current working dir, that is what is returned by mcs::Pwd().
fn | Complete path to the program or script; |
pars | Arguments to the program or script; |
wpath | Directory where the program or script will be executed, also content of the PWD environment variable; |
thrID | Content of the MCS_CID environment variable; |
user | Content of the MCS_USER environment variable; |
pass | Content of the MCS_PASS environment variable; |
dbname | Content of the MCS_DBNAME environment variable; |
fout | Path to the file that will contain the standard output result; |
ferr | Path to the file that will contain the standard error result; |
Definition at line 159 of file BaseThread.cc.
const char * mcs::BaseThread::tid | ( | ) |
Return the thread identifier.
Definition at line 90 of file BaseThread.cc.
|
staticprotected |
|
private |
![]() |
MCS (My Customizable Server) ver. 0.3.3-alpha7
|