From 1fdf750ee66ee9e4e872d2810e9ca3bcfa2d555e Mon Sep 17 00:00:00 2001 From: Pixel Date: Sun, 1 Apr 2012 07:18:00 -0700 Subject: More code cleanup. --- includes/Main.h | 2 +- includes/Socket.h | 2 +- includes/Task.h | 7 +++---- src/HttpServer.cc | 4 ++-- src/Main.cc | 2 +- src/Socket.cc | 2 +- src/Task.cc | 4 ++-- src/TaskMan.cc | 8 ++++---- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/includes/Main.h b/includes/Main.h index a890525..60de081 100644 --- a/includes/Main.h +++ b/includes/Main.h @@ -17,7 +17,7 @@ class MainTask : public Task { public: MainTask() : m_stopTaskManOnExit(true) { } virtual ~MainTask(); - virtual const char * getName(); + virtual const char * getName() const; virtual void Do(); void stopTaskManOnExit(bool v) { m_stopTaskManOnExit = v; } private: diff --git a/includes/Socket.h b/includes/Socket.h index 77e1165..4a73277 100644 --- a/includes/Socket.h +++ b/includes/Socket.h @@ -61,7 +61,7 @@ class ListenerBase : public Task { public: virtual void Do(); void stop(); - virtual const char * getName(); + virtual const char * getName() const; protected: ListenerBase(int port, const char * local, void * opaque); virtual void factory(IO & io, void * opaque) = 0; diff --git a/includes/Task.h b/includes/Task.h index 02090c8..592d5c3 100644 --- a/includes/Task.h +++ b/includes/Task.h @@ -126,15 +126,15 @@ class Task { }; Task(); virtual ~Task(); - virtual const char * getName() = 0; - Status getStatus() { return m_status; } + virtual const char * getName() const = 0; + Status getStatus() const { return m_status; } static Task * getCurrentTask(); static void prepare(Events::BaseEvent * evt) { Task * t = getCurrentTask(); t->waitFor(evt); } static void yield(Events::BaseEvent * evt, bool interruptible = false) throw (GeneralException); - TaskMan * getTaskMan() { return m_taskMan; } + TaskMan * getTaskMan() const { return m_taskMan; } struct ev_loop * getLoop(); protected: void yield(bool changeStatus = false); @@ -145,7 +145,6 @@ class Task { m_okayToEAgain = enable; return oldValue; } - TaskMan * getMyTaskMan() { return m_taskMan; } private: static size_t stackSize() { return 64 * 1024; } void setup(TaskMan * taskMan, void * stack); diff --git a/src/HttpServer.cc b/src/HttpServer.cc index c234096..c9cb0ee 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -39,7 +39,7 @@ class HttpWorker : public Task { static void buildErrorTemplate(const String & str) { m_errorTemplate.setTemplate(str); } private: virtual void Do(); - virtual const char * getName(); + virtual const char * getName() const; bool handleClient(); void sendError(int error, const char * msg, const char * details, bool closeConnection, std::vector extraHeaders, std::vector trace); @@ -586,7 +586,7 @@ void Balau::HttpWorker::Do() { clientStop = !handleClient() || m_socket->isClosed(); } -const char * Balau::HttpWorker::getName() { +const char * Balau::HttpWorker::getName() const { return m_name.to_charp(); } diff --git a/src/Main.cc b/src/Main.cc index b2aa739..fd4021f 100644 --- a/src/Main.cc +++ b/src/Main.cc @@ -43,7 +43,7 @@ Balau::MainTask::~MainTask() { TaskMan::stop(0); } -const char * Balau::MainTask::getName() { +const char * Balau::MainTask::getName() const { return "Main Task"; } diff --git a/src/Socket.cc b/src/Socket.cc index 3bcf840..1c3778a 100644 --- a/src/Socket.cc +++ b/src/Socket.cc @@ -590,7 +590,7 @@ Balau::ListenerBase::ListenerBase(int port, const char * local, void * opaque) : Printer::elog(E_SOCKET, "Created a listener task at %p (%s)", this, m_name.to_charp()); } -const char * Balau::ListenerBase::getName() { +const char * Balau::ListenerBase::getName() const { return m_name.to_charp(); } diff --git a/src/Task.cc b/src/Task.cc index 0938ff3..6278fd5 100644 --- a/src/Task.cc +++ b/src/Task.cc @@ -161,10 +161,10 @@ void Balau::Events::TaskEvent::signal() { } void Balau::Events::TaskEvent::gotOwner(Task * task) { - TaskMan * tm = task->getMyTaskMan(); + TaskMan * tm = task->getTaskMan(); m_evt.stop(); - if (tm != m_taskWaited->getMyTaskMan()) { + if (tm != m_taskWaited->getTaskMan()) { m_evt.set(tm->getLoop()); m_evt.set(this); m_evt.start(); diff --git a/src/TaskMan.cc b/src/TaskMan.cc index b909caa..8fd6df5 100644 --- a/src/TaskMan.cc +++ b/src/TaskMan.cc @@ -8,15 +8,15 @@ class Stopper : public Balau::Task { Stopper(int code) : m_code(code) { } private: virtual void Do(); - virtual const char * getName(); + virtual const char * getName() const; int m_code; }; void Stopper::Do() { - getMyTaskMan()->stopMe(m_code); + getTaskMan()->stopMe(m_code); } -const char * Stopper::getName() { +const char * Stopper::getName() const { return "Stopper"; } @@ -321,7 +321,7 @@ int Balau::TaskMan::mainLoop() { void Balau::TaskMan::registerTask(Balau::Task * t, Balau::Task * stick) { if (stick) { - TaskMan * tm = stick->getMyTaskMan(); + TaskMan * tm = stick->getTaskMan(); tm->addToPending(t); tm->m_evt.send(); } else { -- cgit v1.2.3