My Project
Loading...
Searching...
No Matches
LibThread::Job Class Referenceabstract

Public Member Functions

 Job ()
 
 ~Job ()
 
void addDep (Job *job)
 
void addDep (vector< Job * > &jobs)
 
void addDep (long ndeps, Job **jobs)
 
void addNotify (vector< Job * > &jobs)
 
void addNotify (Job *job)
 
virtual bool ready ()
 
virtual void execute ()=0
 
void run ()
 
- Public Member Functions inherited from LibThread::SharedObject
 SharedObject ()
 
virtual ~SharedObject ()
 
void set_type (int type_init)
 
int get_type ()
 
void set_name (std::string &name_init)
 
void set_name (const char *s)
 
std::string & get_name ()
 
void incref (int by=1)
 
long decref ()
 
long getref ()
 
virtual BOOLEAN op2 (int op, leftv res, leftv a1, leftv a2)
 
virtual BOOLEAN op3 (int op, leftv res, leftv a1, leftv a2, leftv a3)
 

Data Fields

ThreadPoolpool
 
long prio
 
size_t id
 
long pending_index
 
vector< Job * > deps
 
vector< Job * > notify
 
vector< Trigger * > triggers
 
vector< string > args
 
string result
 
void * data
 
bool fast
 
bool done
 
bool queued
 
bool running
 
bool cancelled
 

Detailed Description

Definition at line 1544 of file shared.cc.

Constructor & Destructor Documentation

◆ Job()

LibThread::Job::Job ( )
inline

Definition at line 1561 of file shared.cc.

1561 : SharedObject(), pool(NULL), deps(), pending_index(-1), fast(false),
1562 done(false), running(false), queued(false), cancelled(false), data(NULL),
1563 result(), args(), notify(), triggers(), prio(0)
1564 { set_type(type_job); }
vector< string > args
Definition shared.cc:1553
vector< Job * > deps
Definition shared.cc:1550
ThreadPool * pool
Definition shared.cc:1546
string result
Definition shared.cc:1554
long pending_index
Definition shared.cc:1549
vector< Job * > notify
Definition shared.cc:1551
vector< Trigger * > triggers
Definition shared.cc:1552
void set_type(int type_init)
Definition shared.cc:158
int type_job
Definition shared.cc:238
#define NULL
Definition omList.c:12

◆ ~Job()

LibThread::Job::~Job ( )

Definition at line 1608 of file shared.cc.

1608 {
1609 vector<Job *>::iterator it;
1610 for (it = deps.begin(); it != deps.end(); it++) {
1611 releaseShared(*it);
1612 }
1613}
void releaseShared(SharedObject *obj)
Definition shared.cc:192

Member Function Documentation

◆ addDep() [1/3]

void LibThread::Job::addDep ( Job * job)
inline

Definition at line 1566 of file shared.cc.

1566 {
1567 deps.push_back(job);
1568 }

◆ addDep() [2/3]

void LibThread::Job::addDep ( long ndeps,
Job ** jobs )

Definition at line 1957 of file shared.cc.

1957 {
1958 for (long i = 0; i < ndeps; i++) {
1959 deps.push_back(jobs[i]);
1960 }
1961}
int i
Definition cfEzgcd.cc:132

◆ addDep() [3/3]

void LibThread::Job::addDep ( vector< Job * > & jobs)

Definition at line 1953 of file shared.cc.

1953 {
1954 deps.insert(deps.end(), jobs.begin(), jobs.end());
1955}

◆ addNotify() [1/2]

void LibThread::Job::addNotify ( Job * job)

Definition at line 1970 of file shared.cc.

1970 {
1971 notify.push_back(job);
1972 if (done) {
1973 Scheduler::notifyDeps(pool->scheduler, this);
1974 }
1975}
static void notifyDeps(Scheduler *scheduler, Job *job)
Definition shared.cc:1824

◆ addNotify() [2/2]

void LibThread::Job::addNotify ( vector< Job * > & jobs)

Definition at line 1963 of file shared.cc.

1963 {
1964 notify.insert(notify.end(), jobs.begin(), jobs.end());
1965 if (done) {
1966 Scheduler::notifyDeps(pool->scheduler, this);
1967 }
1968}

◆ execute()

◆ ready()

bool LibThread::Job::ready ( )
virtual

Reimplemented in LibThread::AccTrigger, LibThread::CountTrigger, LibThread::ProcTrigger, and LibThread::SetTrigger.

Definition at line 1600 of file shared.cc.

1600 {
1601 vector<Job *>::iterator it;
1602 for (it = deps.begin(); it != deps.end(); it++) {
1603 if (!(*it)->done) return false;
1604 }
1605 return true;
1606}

◆ run()

void LibThread::Job::run ( )

Definition at line 1977 of file shared.cc.

1977 {
1978 if (!cancelled) {
1979 running = true;
1980 pool->scheduler->lock.unlock();
1981 pool->scheduler->running++;
1982 execute();
1983 pool->scheduler->running--;
1984 pool->scheduler->lock.lock();
1985 running = false;
1986 }
1987 done = true;
1988}
virtual void execute()=0

Field Documentation

◆ args

vector<string> LibThread::Job::args

Definition at line 1553 of file shared.cc.

◆ cancelled

bool LibThread::Job::cancelled

Definition at line 1560 of file shared.cc.

◆ data

void* LibThread::Job::data

Definition at line 1555 of file shared.cc.

◆ deps

vector<Job *> LibThread::Job::deps

Definition at line 1550 of file shared.cc.

◆ done

bool LibThread::Job::done

Definition at line 1557 of file shared.cc.

◆ fast

bool LibThread::Job::fast

Definition at line 1556 of file shared.cc.

◆ id

size_t LibThread::Job::id

Definition at line 1548 of file shared.cc.

◆ notify

vector<Job *> LibThread::Job::notify

Definition at line 1551 of file shared.cc.

◆ pending_index

long LibThread::Job::pending_index

Definition at line 1549 of file shared.cc.

◆ pool

ThreadPool* LibThread::Job::pool

Definition at line 1546 of file shared.cc.

◆ prio

long LibThread::Job::prio

Definition at line 1547 of file shared.cc.

◆ queued

bool LibThread::Job::queued

Definition at line 1558 of file shared.cc.

◆ result

string LibThread::Job::result

Definition at line 1554 of file shared.cc.

◆ running

bool LibThread::Job::running

Definition at line 1559 of file shared.cc.

◆ triggers

vector<Trigger *> LibThread::Job::triggers

Definition at line 1552 of file shared.cc.


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