Loading...
Searching...
No Matches
XrdCl::JobManager Class Reference

A synchronized queue. More...

`#include <XrdClJobManager.hh>`

Collaboration diagram for XrdCl::JobManager:

## Public Member Functions

| JobManager (uint32_t workers)
| Constructor.
| ~JobManager ()
| Destructor.
bool | Finalize ()
| Finalize the job manager, clear the queues.
bool | Initialize ()
| Initialize the job manager.
bool | IsWorker ()
void | QueueJob (Job *job, void *arg=0)
| Add a job to be run.
void | RunJobs ()
| Run the jobs.
bool | Start ()
| Start the workers.
bool | Stop ()
| Stop the workers.

## Detailed Description

A synchronized queue.

Definition at line 50 of file XrdClJobManager.hh.

## Constructor & Destructor Documentation

## JobManager()

XrdCl::JobManager::JobManager | ( | uint32_t | workers | ) |

inline

Constructor.

Definition at line 56 of file XrdClJobManager.hh.

{
pRunning = false;
pWorkers.resize( workers );
}

## ~JobManager()

XrdCl::JobManager::~JobManager | ( |  | ) |

inline

Destructor.

Definition at line 65 of file XrdClJobManager.hh.

{
}

## Member Function Documentation

## Finalize()

bool XrdCl::JobManager::Finalize | ( |  | ) |

Finalize the job manager, clear the queues.

Definition at line 52 of file XrdClJobManager.cc.

{
pJobs.Clear();
return true;
}

Referenced by XrdCl::CopyProcess::Run().

Here is the caller graph for this function:

## Initialize()

bool XrdCl::JobManager::Initialize | ( |  | ) |

Initialize the job manager.

Definition at line 44 of file XrdClJobManager.cc.

{
return true;
}

Referenced by XrdCl::CopyProcess::Run().

Here is the caller graph for this function:

## IsWorker()

bool XrdCl::JobManager::IsWorker | ( |  | ) |

inline

Definition at line 102 of file XrdClJobManager.hh.

{
pthread_t thread = pthread_self();
std::vector<pthread_t>::iterator itr =
std::find( pWorkers.begin(), pWorkers.end(), thread );
return itr != pWorkers.end();
}

## QueueJob()

void XrdCl::JobManager::QueueJob | ( | Job * | job,
|  | void * | arg = 0 )

inline

Add a job to be run.

Definition at line 92 of file XrdClJobManager.hh.

{
pJobs.Put( JobHelper( job, arg ) );
}

Referenced by XrdCl::FileStateHandler::Close(), XrdCl::CopyProcess::Run(), XrdCl::Operation< HasHndl >::Run(), XrdEc::ScheduleHandler(), XrdEc::ScheduleHandler(), and XrdCl::FileStateHandler::TimeOutRequests().

Here is the caller graph for this function:

## RunJobs()

void XrdCl::JobManager::RunJobs | ( |  | ) |

Run the jobs.

Definition at line 146 of file XrdClJobManager.cc.

{
pthread_setcanceltype( PTHREAD_CANCEL_DEFERRED, 0 );
for( ;; )
{
JobHelper h = pJobs.Get();
pthread_setcancelstate( PTHREAD_CANCEL_DISABLE, 0 );
h.job->Run( h.arg );
pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, 0 );
}
}

References XrdCl::Job::Run().

Referenced by RunRunnerThread().

Here is the call graph for this function:
Here is the caller graph for this function:

## Start()

bool XrdCl::JobManager::Start | ( |  | ) |

Start the workers.

Definition at line 61 of file XrdClJobManager.cc.

{
XrdSysMutexHelper scopedLock( pMutex );
Log *log = DefaultEnv::GetLog();
log->Debug( JobMgrMsg, "Starting the job manager..." );
if( pRunning )
{
log->Error( JobMgrMsg, "The job manager is already running" );
return false;
}
for( uint32_t i = 0; i < pWorkers.size(); ++i )
{
int ret = ::pthread_create( &pWorkers[i], 0, ::RunRunnerThread, this );
if( ret != 0 )
{
log->Error( JobMgrMsg, "Unable to spawn a job worker thread: %s",
XrdSysE2T( errno ) );
if( i > 0 )
StopWorkers( i );
return false;
}
}
pRunning = true;
log->Debug( JobMgrMsg, "Job manager started, %zu workers", pWorkers.size() );
return true;
}
RunRunnerThread
static void * RunRunnerThread(void *arg)
Definition XrdClJobManager.cc:30
XrdSysE2T
const char * XrdSysE2T(int errcode)
Definition XrdSysE2T.cc:104
XrdCl::DefaultEnv::GetLog
static Log * GetLog()
Get default log.
Definition XrdClDefaultEnv.cc:493
XrdCl::JobMgrMsg
const uint64_t JobMgrMsg
Definition XrdClConstants.hh:42
XrdGlobal::Log
XrdSysError Log
Definition XrdConfig.cc:113

References XrdCl::Log::Debug(), XrdCl::Log::Error(), XrdCl::DefaultEnv::GetLog(), XrdCl::JobMgrMsg, RunRunnerThread(), and XrdSysE2T().

Referenced by XrdCl::CopyProcess::Run().

Here is the call graph for this function:
Here is the caller graph for this function:

## Stop()

bool XrdCl::JobManager::Stop | ( |  | ) |

Stop the workers.

Definition at line 93 of file XrdClJobManager.cc.

{
XrdSysMutexHelper scopedLock( pMutex );
Log *log = DefaultEnv::GetLog();
log->Debug( JobMgrMsg, "Stopping the job manager..." );
if( !pRunning )
{
log->Error( JobMgrMsg, "The job manager is not running" );
return false;
}
StopWorkers( pWorkers.size() );
pRunning = false;
log->Debug( JobMgrMsg, "Job manager stopped" );
return true;
}

References XrdCl::Log::Debug(), XrdCl::Log::Error(), XrdCl::DefaultEnv::GetLog(), and XrdCl::JobMgrMsg.

Referenced by XrdCl::CopyProcess::Run().

Here is the call graph for this function:
Here is the caller graph for this function:

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

- XrdClJobManager.hh
- XrdClJobManager.cc