diff options
-rw-r--r-- | includes/Async.h | 10 | ||||
-rw-r--r-- | includes/AtStartExit.h | 4 | ||||
-rw-r--r-- | includes/BRegex.h | 8 | ||||
-rw-r--r-- | src/Async.cc | 2 | ||||
-rw-r--r-- | src/BRegex.cc | 6 |
5 files changed, 23 insertions, 7 deletions
diff --git a/includes/Async.h b/includes/Async.h index 15e0ac7..6c67546 100644 --- a/includes/Async.h +++ b/includes/Async.h @@ -14,6 +14,7 @@ typedef void (*IdleReadyCallback_t)(void *); class AsyncOperation { protected: + AsyncOperation() { } virtual void run() { } virtual void finish() { } virtual void done() { } @@ -27,6 +28,8 @@ class AsyncOperation { IdleReadyCallback_t m_idleReadyCallback = NULL; void * m_idleReadyParam = NULL; void finalize(); + AsyncOperation(const AsyncOperation &) = delete; + AsyncOperation & operator=(const AsyncOperation &) = delete; friend class AsyncManager; friend class AsyncFinishWorker; @@ -35,6 +38,10 @@ class AsyncOperation { class AsyncFinishWorker : public Thread { public: AsyncFinishWorker(AsyncManager * async, Queue<AsyncOperation> * queue) : m_async(async), m_queue(queue) { } + bool stopped() { return m_stopped; } + private: + AsyncFinishWorker(const AsyncFinishWorker &) = delete; + AsyncOperation & operator=(const AsyncFinishWorker &) = delete; virtual void * proc(); AsyncManager * m_async; Queue<AsyncOperation> * m_queue; @@ -44,6 +51,7 @@ class AsyncFinishWorker : public Thread { class AsyncManager : public Thread { public: + AsyncManager() { } void setFinishers(int minIdle, int maxIdle) { AAssert(minIdle < maxIdle, "Minimum number of threads needs to be less than maximum number of threads."); m_minIdle = minIdle; @@ -58,6 +66,8 @@ class AsyncManager : public Thread { virtual void threadExit(); private: + AsyncManager(const AsyncManager &) = delete; + AsyncManager & operator=(const AsyncManager &) = delete; void checkIdle(); void killOneFinisher(); void startOneFinisher(); diff --git a/includes/AtStartExit.h b/includes/AtStartExit.h index 9b55d93..97dc533 100644 --- a/includes/AtStartExit.h +++ b/includes/AtStartExit.h @@ -7,6 +7,8 @@ class AtStart { AtStart(int priority = 0); virtual void doStart() = 0; private: + AtStart(const AtStart &) = delete; + AtStart & operator=(const AtStart &) = delete; const int m_priority; AtStart * m_next; static AtStart * s_head; @@ -18,6 +20,8 @@ class AtExit { AtExit(int priority = 0); virtual void doExit() = 0; private: + AtExit(const AtExit &) = delete; + AtExit & operator=(const AtExit &) = delete; const int m_priority; AtExit * m_next; static AtExit * s_head; diff --git a/includes/BRegex.h b/includes/BRegex.h index 4a2f207..9b030bc 100644 --- a/includes/BRegex.h +++ b/includes/BRegex.h @@ -11,12 +11,18 @@ namespace Balau { class Regex { public: typedef std::vector<String> Captures; + Regex(const String & regex, bool icase = false) : Regex(regex.to_charp(), icase) { } + Regex(const Regex & regex) : Regex(regex.m_regexStr, regex.m_icase) { } + Regex(Regex && regex) { regex.m_moved = true; m_regex = regex.m_regex; } Regex(const char * regex, bool icase = false) throw (GeneralException); - ~Regex(); + ~Regex() { if (!m_moved) regfree(&m_regex); } Captures match(const char * str) const throw (GeneralException); private: + Regex & operator=(const Regex &) = delete; String getError(int err) const; + String m_regexStr; regex_t m_regex; + bool m_icase, m_moved = false; }; class Regexes { diff --git a/src/Async.cc b/src/Async.cc index afc1879..09465d3 100644 --- a/src/Async.cc +++ b/src/Async.cc @@ -67,7 +67,7 @@ void Balau::AsyncManager::startOneFinisher() { void Balau::AsyncManager::joinStoppedFinishers() { for (auto i = m_workers.begin(); i != m_workers.end(); i++) { AsyncFinishWorker * worker = *i; - if (!worker->m_stopped) + if (!worker->stopped()) continue; Printer::elog(E_ASYNC, "Joining stopped worker at %p", worker); m_numFinishers--; diff --git a/src/BRegex.cc b/src/BRegex.cc index c235de6..1ada2f1 100644 --- a/src/BRegex.cc +++ b/src/BRegex.cc @@ -1,6 +1,6 @@ #include "BRegex.h" -Balau::Regex::Regex(const char * regex, bool icase) throw (GeneralException) { +Balau::Regex::Regex(const char * regex, bool icase) throw (GeneralException) : m_regexStr(regex), m_icase(icase) { int r = regcomp(&m_regex, regex, REG_EXTENDED | (icase ? REG_ICASE : 0)); if (r) throw GeneralException(getError(r)); @@ -30,10 +30,6 @@ Balau::Regex::Captures Balau::Regex::match(const char * str) const throw (Genera return ret; } -Balau::Regex::~Regex() { - regfree(&m_regex); -} - Balau::String Balau::Regex::getError(int err) const { size_t s; char * t; |