commore  1.0.6-SNAPSHOT
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
commore::Processor Class Reference

#include <Processor.h>

Classes

struct  HImpl
 

Public Member Functions

 Processor (const char *name, const int nb_max_thread, int min_thread)
 
 Processor (const int nb_max_thread, int min_thread)
 
 ~Processor ()
 
 Processor (const Processor &)
 
Processoroperator= (const Processor &)
 
bool start (const char *name, int min_thread=0, int max_thread=64)
 
bool submit (const PAction &action)
 
bool submit (ActionGroup &actions)
 
bool submit (ProcessFunction f, void *p)
 
void remove_from_submitted_action (const PAction &action)
 
void pause ()
 
void resume ()
 
bool stop ()
 
void abort ()
 
const AStringget_name () const
 
bool waitAction (const PAction &action, const int nTimeOut_ms=0)
 
void waitIdle ()
 
void terminate ()
 

Static Public Member Functions

static ProcessorgetDefaultProcessor ()
 

Detailed Description

Processor implement a thread pool to execute actions

Todo:
add a start method bool start(int nb_max_thread = 0, int nb_min_thread) and manage an inactive state and a min thread pool size.

Constructor & Destructor Documentation

Processor::Processor ( const char *  name,
const int  nb_max_thread,
int  min_thread 
)
Parameters
nb_max_threadmaximal number of thread of the processor. 0 means it will have no limit.
min_trheadnumber min of thread in processor
Remarks
if max_thread is negative the processor is not started if max_thread == 0 there is no limit for thread number Each time a processor runs an action and no thread is available it will create a new thread if the maximal number of thread is not reach
Todo:
add a minimal parameter and a constructor for inactve processor Processor(bool active)
Processor::Processor ( const int  nb_max_thread,
int  min_thread 
)
Processor::~Processor ( )
Processor::Processor ( const Processor p)

Member Function Documentation

void Processor::abort ( )

Send an abort request to all actions and empties the waiting action list

Todo:
set action abort flag on running action
const AString & Processor::get_name ( ) const
Returns
name of processor this is useful only for debug purpose
Processor & Processor::getDefaultProcessor ( )
static
Processor& commore::Processor::operator= ( const Processor )
void Processor::pause ( )

Pause the processor wich will no longer run new actions, running action will continue normally

void Processor::remove_from_submitted_action ( const PAction action)

Unsubmit an action (before it was executed)

Parameters
actionaction to remove
void Processor::resume ( )

Resume the processor

bool Processor::start ( const char *  name,
int  min_thread = 0,
int  max_thread = 64 
)

Start processor

Parameters
max_threadnumber max of thread in processor
min_trheadnumber min of thread in processor
Returns
true if processor is started
Remarks
if max_thread is negative the processor is stopped
bool Processor::stop ( )

Send a stop request to all actions and empties the waiting action list

bool Processor::submit ( const PAction action)

Submit an action to a processor

Parameters
actionaction to run
Todo:
use void submit(const PAction& action);
bool Processor::submit ( ActionGroup actions)

Submit a group of action to a processor

Parameters
actionsgroup of actions
Todo:
use void submit(const ActionGroup& actions);
bool Processor::submit ( ProcessFunction  f,
void *  p 
)

Submit a function

Parameters
ffunction to execute
pfunction argument
void Processor::terminate ( )

Free the processor's thread

Remarks
same as stop()
bool Processor::waitAction ( const PAction action,
const int  nTimeOut_ms = 0 
)
Remarks
not implemented
void Processor::waitIdle ( )
Remarks
not implemented

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