20 #include <znc/zncconfig.h> 33 #include <condition_variable> 111 void addJob(
CJob* job);
116 void cancelJob(
CJob* job);
121 void cancelJobs(
const std::set<CJob*>& jobs);
125 void handlePipeReadable()
const;
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
bool wasCancelled() const
This can be used to check if the job was cancelled.
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
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
int getReadFD() const
Definition: Threads.h:123
virtual void runMain()=0
This function is called from the main thread after runThread() finishes.
friend class CThreadPool
Definition: Threads.h:69