fixed: ThreadMenager should use Lock/Unlock in StartAll() method

added: Job class (system->job object)
       a general mechanism for jobs (by using PT::Space as a job structure)
       WINIX_JOB plugin message will be sent with a pointer to PT::Space



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@829 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2012-04-25 22:24:37 +00:00
parent baf10a9ba9
commit 1da1eef768
19 changed files with 1323 additions and 958 deletions

82
core/job.h Executable file
View File

@@ -0,0 +1,82 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2012, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfile_winix_core_jobs
#define headerfile_winix_core_jobs
#include <vector>
#include <queue>
#include "basethread.h"
#include "confparser/space.h"
#define WINIX_JOBS_HOW_MANY_PRIORITIES 32
class Job : public BaseThread
{
public:
Job();
/*
add a new job to the queue
priority: 0-31 (0 - the lowest priority, 31 - the highest priority)
*/
void Add(PT::Space & job, int priority = 0);
/*
queue size, and size of all jobs in any priority
*/
size_t Size(int priority) const;
size_t Size() const;
/*
true if specified queue is empty
or if all queues are empty
*/
bool Empty(int priority) const;
bool Empty() const;
private:
typedef std::queue<PT::Space> JobsQueue;
typedef std::vector<JobsQueue> JobsQueueTab;
JobsQueueTab jobs_queue_tab;
void CheckPriority(int & priority) const;
void SaveToFile();
void ReadFromFile();
/*
second thread
*/
// standard winix jobs
// Image image;
// sending emails
// etc.
bool SignalReceived();
void Do();
void DoQueue(JobsQueue & jobs_queue);
void DoJob(PT::Space & job);
void DoWinixJob(PT::Space & job);
};
#endif