20 #include <znc/zncconfig.h> 33 #include <condition_variable> 128 void jobDone(
CJob* pJob);
132 bool threadNeeded()
const;
134 CJob* getJobFromPipe()
const;
135 void finishJob(
CJob*)
const;
155 size_t m_num_threads;
164 std::list<CJob*> m_jobs;
167 #endif // HAVE_PTHREAD 168 #endif // !ZNC_THREADS_H
virtual void runThread()=0
This function is called in a separate thread and can do heavy, blocking work.
std::unique_lock< std::mutex > CMutexLocker
A mutex locker should always be used as an automatic variable.
Definition: Threads.h:46
A job is a task which should run without blocking the main thread.
Definition: Threads.h:67
int getReadFD() const
Definition: Threads.h:123
void cancelJobs(const std::set< CJob *> &jobs)
Cancel some jobs that were previously passed to addJob().
void handlePipeReadable() const
EJobState
Definition: Threads.h:71
Definition: Threads.h:100
CJob()
Definition: Threads.h:73
std::mutex CMutex
This class represents a non-recursive mutex.
Definition: Threads.h:39
bool wasCancelled() const
This can be used to check if the job was cancelled.
static CThreadPool & Get()
std::condition_variable_any CConditionVariable
A condition variable makes it possible for threads to wait until some condition is reached at which p...
Definition: Threads.h:52
virtual ~CJob()
Destructor, always called from the main thread.
Definition: Threads.h:76
virtual void runMain()=0
This function is called from the main thread after runThread() finishes.
void cancelJob(CJob *job)
Cancel a job that was previously passed to addJob().
void addJob(CJob *job)
Add a job to the thread pool and run it. The job will be deleted when done.
friend class CThreadPool
Definition: Threads.h:69