36 using namespace XrdCl;
56 TaskSet::iterator it, itE;
57 for( it = pTasks.begin(); it != pTasks.end(); ++it )
77 int ret = ::pthread_create( &pRunnerThread, 0, ::
RunRunnerThread,
this );
103 if( ::pthread_cancel( pRunnerThread ) != 0 )
111 int ret = pthread_join( pRunnerThread, (
void **)&threadRet );
135 pTasks.insert( TaskHelper( task, time, own ) );
147 pToBeUnregistered.push_back( task );
161 pthread_setcanceltype( PTHREAD_CANCEL_DEFERRED, 0 );
165 pthread_setcancelstate( PTHREAD_CANCEL_DISABLE, 0 );
174 TaskList::iterator listIt = pToBeUnregistered.begin();
175 TaskSet::iterator it, itE;
176 std::list<TaskSet::iterator> iteratorList;
177 std::list<TaskSet::iterator>::iterator itRem;
178 for( ; listIt != pToBeUnregistered.end(); ++listIt )
180 for( it = pTasks.begin(); it != pTasks.end(); ++it )
182 if( it->task == *listIt )
183 iteratorList.push_back( it );
187 for( itRem = iteratorList.begin(); itRem != iteratorList.end(); ++itRem )
189 Task *tsk = (*itRem)->task;
190 bool own = (*itRem)->own;
192 pTasks.erase( *itRem );
197 pToBeUnregistered.clear();
202 time_t now = time(0);
203 std::list<TaskHelper> toRun;
204 std::list<TaskHelper>::iterator trIt;
207 itE = pTasks.upper_bound( TaskHelper( 0, now ) );
209 for( ; it != itE; ++it )
210 toRun.push_back( TaskHelper( it->task, 0, it->own ) );
212 pTasks.erase( pTasks.begin(), itE );
218 for( trIt = toRun.begin(); trIt != toRun.end(); ++trIt )
221 trIt->task->GetName().c_str() );
222 time_t schedule = trIt->task->Run( now );
226 trIt->task->GetName().c_str(),
229 pTasks.insert( TaskHelper( trIt->task, schedule, trIt->own ) );
235 trIt->task->GetName().c_str() );
244 pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, 0 );
245 pthread_testcancel();
static void * RunRunnerThread(void *arg)
const char * XrdSysE2T(int errcode)
static Log * GetLog()
Get default log.
void Error(uint64_t topic, const char *format,...)
Report an error.
void Dump(uint64_t topic, const char *format,...)
Print a dump message.
void Debug(uint64_t topic, const char *format,...)
Print a debug message.
void RegisterTask(Task *task, time_t time, bool own=true)
void RunTasks()
Run the tasks - this loops infinitely.
TaskManager()
Constructor.
bool Start()
Start the manager.
~TaskManager()
Destructor.
void UnregisterTask(Task *task)
Interface for a task to be run by the TaskManager.
const std::string & GetName() const
Name of the task.
static std::string TimeToString(time_t timestamp)
Convert timestamp to a string.
static void Wait(int milliseconds)
const uint64_t TaskMgrMsg