From 40b45c3d91000fa3a4f3253ff7877cba06681a73 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 16 Apr 2012 08:36:50 +0200 Subject: [PATCH] Renamed event/condvar/mutex/thread classes to match other class names. --- base/condvar.cpp | 18 +++++++++--------- base/condvar.h | 16 ++++++++-------- base/configcollection.h | 6 +++--- base/confighive.h | 6 +++--- base/event.h | 14 +++++++------- base/mutex.cpp | 14 +++++++------- base/mutex.h | 16 ++++++++-------- base/socket.h | 10 +++++----- base/tcpclient.h | 2 +- base/tcpserver.h | 2 +- base/thread.cpp | 17 ++++------------- base/thread.h | 13 +++++++------ base/timer.h | 2 +- icinga/virtualendpoint.cpp | 2 +- icinga/virtualendpoint.h | 2 +- jsonrpc/jsonrpcclient.h | 2 +- 16 files changed, 67 insertions(+), 75 deletions(-) diff --git a/base/condvar.cpp b/base/condvar.cpp index 7f33ed1b7..c0c479c4a 100644 --- a/base/condvar.cpp +++ b/base/condvar.cpp @@ -2,7 +2,7 @@ using namespace icinga; -condvar::condvar(void) +CondVar::CondVar(void) { #ifdef _WIN32 InitializeConditionVariable(&m_CondVar); @@ -11,7 +11,7 @@ condvar::condvar(void) #endif /* _WIN32 */ } -condvar::~condvar(void) +CondVar::~CondVar(void) { #ifdef _WIN32 /* nothing to do here */ @@ -20,16 +20,16 @@ condvar::~condvar(void) #endif /* _WIN32 */ } -void condvar::wait(mutex *mtx) +void CondVar::Wait(Mutex& mtx) { #ifdef _WIN32 - SleepConditionVariableCS(&m_CondVar, mtx->get(), INFINITE); + SleepConditionVariableCS(&m_CondVar, mtx.Get(), INFINITE); #else /* _WIN32 */ - pthread_cond_wait(&m_CondVar, mtx->get()); + pthread_cond_wait(&m_CondVar, mtx.Get()); #endif /* _WIN32 */ } -void condvar::signal(void) +void CondVar::Signal(void) { #ifdef _WIN32 WakeConditionVariable(&m_CondVar); @@ -38,7 +38,7 @@ void condvar::signal(void) #endif /* _WIN32 */ } -void condvar::broadcast(void) +void CondVar::Broadcast(void) { #ifdef _WIN32 WakeAllConditionVariable(&m_CondVar); @@ -49,9 +49,9 @@ void condvar::broadcast(void) #ifdef _WIN32 -CONDITION_VARIABLE *condvar::get(void) +CONDITION_VARIABLE *CondVar::Get(void) #else /* _WIN32 */ -pthread_cond_t *condvar::get(void) +pthread_cond_t *CondVar::Get(void) #endif /* _WIN32 */ { return &m_CondVar; diff --git a/base/condvar.h b/base/condvar.h index 2c51a09ee..03c92b332 100644 --- a/base/condvar.h +++ b/base/condvar.h @@ -4,7 +4,7 @@ namespace icinga { -class I2_BASE_API condvar +class I2_BASE_API CondVar { private: #ifdef _WIN32 @@ -14,17 +14,17 @@ private: #endif /* _WIN32 */ public: - condvar(void); - ~condvar(void); + CondVar(void); + ~CondVar(void); - void wait(mutex *mtx); - void signal(void); - void broadcast(void); + void Wait(Mutex& mtx); + void Signal(void); + void Broadcast(void); #ifdef _WIN32 - CONDITION_VARIABLE *get(void); + CONDITION_VARIABLE *Get(void); #else /* _WIN32 */ - pthread_cond_t *get(void); + pthread_cond_t *Get(void); #endif /* _WIN32 */ }; diff --git a/base/configcollection.h b/base/configcollection.h index b8ea38512..ebc00261a 100644 --- a/base/configcollection.h +++ b/base/configcollection.h @@ -27,9 +27,9 @@ public: void ForEachObject(function callback); - event OnObjectCreated; - event OnObjectRemoved; - event OnPropertyChanged; + Event OnObjectCreated; + Event OnObjectRemoved; + Event OnPropertyChanged; }; } diff --git a/base/confighive.h b/base/confighive.h index c7e54c33e..95034b2ed 100644 --- a/base/confighive.h +++ b/base/confighive.h @@ -20,9 +20,9 @@ public: void ForEachObject(const string& type, function callback); - event OnObjectCreated; - event OnObjectRemoved; - event OnPropertyChanged; + Event OnObjectCreated; + Event OnObjectRemoved; + Event OnPropertyChanged; }; } diff --git a/base/event.h b/base/event.h index e306d73b0..5785f376f 100644 --- a/base/event.h +++ b/base/event.h @@ -13,7 +13,7 @@ struct I2_BASE_API EventArgs : public Object }; template -class event +class Event { public: typedef function DelegateType; @@ -22,25 +22,25 @@ private: list m_Delegates; public: - void hook(const DelegateType& delegate) + void Hook(const DelegateType& delegate) { m_Delegates.push_front(delegate); } - void unhook(const DelegateType& delegate) + void Unhook(const DelegateType& delegate) { m_Delegates.remove(delegate); } - event& operator +=(const DelegateType& rhs) + Event& operator +=(const DelegateType& rhs) { - hook(rhs); + Hook(rhs); return *this; } - event& operator -=(const DelegateType& rhs) + Event& operator -=(const DelegateType& rhs) { - unhook(rhs); + Unhook(rhs); return *this; } diff --git a/base/mutex.cpp b/base/mutex.cpp index 5a3b59601..9a49e5b90 100644 --- a/base/mutex.cpp +++ b/base/mutex.cpp @@ -2,7 +2,7 @@ using namespace icinga; -mutex::mutex(void) +Mutex::Mutex(void) { #ifdef _WIN32 InitializeCriticalSection(&m_Mutex); @@ -11,7 +11,7 @@ mutex::mutex(void) #endif /* _WIN32 */ } -mutex::~mutex(void) +Mutex::~Mutex(void) { #ifdef _WIN32 DeleteCriticalSection(&m_Mutex); @@ -20,7 +20,7 @@ mutex::~mutex(void) #endif /* _WIN32 */ } -bool mutex::tryenter(void) +bool Mutex::TryEnter(void) { #ifdef _WIN32 return (TryEnterCriticalSection(&m_Mutex) == TRUE); @@ -29,7 +29,7 @@ bool mutex::tryenter(void) #endif /* _WIN32 */ } -void mutex::enter(void) +void Mutex::Enter(void) { #ifdef _WIN32 EnterCriticalSection(&m_Mutex); @@ -38,7 +38,7 @@ void mutex::enter(void) #endif /* _WIN32 */ } -void mutex::exit(void) +void Mutex::Exit(void) { #ifdef _WIN32 LeaveCriticalSection(&m_Mutex); @@ -48,9 +48,9 @@ void mutex::exit(void) } #ifdef _WIN32 -CRITICAL_SECTION *mutex::get(void) +CRITICAL_SECTION *Mutex::Get(void) #else /* _WIN32 */ -pthread_mutex_t *mutex::get(void) +pthread_mutex_t *Mutex::Get(void) #endif /* _WIN32 */ { return &m_Mutex; diff --git a/base/mutex.h b/base/mutex.h index 9c632bc04..a0ed1c024 100644 --- a/base/mutex.h +++ b/base/mutex.h @@ -4,7 +4,7 @@ namespace icinga { -class I2_BASE_API mutex +class I2_BASE_API Mutex { private: #ifdef _WIN32 @@ -14,17 +14,17 @@ private: #endif /* _WIN32 */ public: - mutex(void); - ~mutex(void); + Mutex(void); + ~Mutex(void); - bool tryenter(void); - void enter(void); - void exit(void); + bool TryEnter(void); + void Enter(void); + void Exit(void); #ifdef _WIN32 - CRITICAL_SECTION *get(void); + CRITICAL_SECTION *Get(void); #else /* _WIN32 */ - pthread_mutex_t *get(void); + pthread_mutex_t *Get(void); #endif /* _WIN32 */ }; diff --git a/base/socket.h b/base/socket.h index 9b9e7da9f..3f6f51771 100644 --- a/base/socket.h +++ b/base/socket.h @@ -40,12 +40,12 @@ public: static void CloseAllSockets(void); - event OnReadable; - event OnWritable; - event OnException; + Event OnReadable; + Event OnWritable; + Event OnException; - event OnError; - event OnClosed; + Event OnError; + Event OnClosed; virtual bool WantsToRead(void) const; virtual bool WantsToWrite(void) const; diff --git a/base/tcpclient.h b/base/tcpclient.h index 91c027730..cca15442d 100644 --- a/base/tcpclient.h +++ b/base/tcpclient.h @@ -35,7 +35,7 @@ public: virtual bool WantsToRead(void) const; virtual bool WantsToWrite(void) const; - event OnDataAvailable; + Event OnDataAvailable; }; } diff --git a/base/tcpserver.h b/base/tcpserver.h index 44a438d6f..7477837d7 100644 --- a/base/tcpserver.h +++ b/base/tcpserver.h @@ -32,7 +32,7 @@ public: void Listen(void); - event OnNewClient; + Event OnNewClient; virtual bool WantsToRead(void) const; }; diff --git a/base/thread.cpp b/base/thread.cpp index bbf04c5ea..342c91300 100644 --- a/base/thread.cpp +++ b/base/thread.cpp @@ -4,7 +4,7 @@ using namespace icinga; typedef struct threadparam_s { - void (*callback)(void*); + ThreadProc callback; void *param; } threadparam_t; @@ -27,7 +27,7 @@ static void *ThreadStartProc(void *param) #endif /* _WIN32 */ -thread::thread(void (*callback)(void *)) +Thread::Thread(ThreadProc callback) { threadparam_t *tparam = new threadparam_t(); @@ -41,7 +41,7 @@ thread::thread(void (*callback)(void *)) #endif /* _WIN32 */ } -thread::~thread(void) +Thread::~Thread(void) { #ifdef _WIN32 CloseHandle(m_Thread); @@ -49,17 +49,8 @@ thread::~thread(void) /* nothing to do here */ #endif } - -void thread::terminate(void) -{ -#ifdef _WIN32 - TerminateThread(m_Thread, 0); -#else /* _WIN32 */ - /* nothing to do here */ -#endif -} -void thread::join(void) +void Thread::Join(void) { #ifdef _WIN32 WaitForSingleObject(m_Thread, INFINITE); diff --git a/base/thread.h b/base/thread.h index 17a0e993b..58c11aa05 100644 --- a/base/thread.h +++ b/base/thread.h @@ -4,7 +4,9 @@ namespace icinga { -class I2_BASE_API thread +typedef void (*ThreadProc)(void *); + +class I2_BASE_API Thread { private: #ifdef _WIN32 @@ -14,12 +16,11 @@ private: #endif public: - thread(void (*callback)(void *)); - ~thread(void); + Thread(void (*callback)(void *)); + ~Thread(void); - void start(void); - void terminate(void); - void join(void); + void Start(void); + void Join(void); }; } diff --git a/base/timer.h b/base/timer.h index da27900af..4a4e2840b 100644 --- a/base/timer.h +++ b/base/timer.h @@ -49,7 +49,7 @@ public: void Reschedule(time_t next); - event OnTimerExpired; + Event OnTimerExpired; }; } diff --git a/icinga/virtualendpoint.cpp b/icinga/virtualendpoint.cpp index c7146d0fc..081be6869 100644 --- a/icinga/virtualendpoint.cpp +++ b/icinga/virtualendpoint.cpp @@ -30,7 +30,7 @@ void VirtualEndpoint::UnregisterMethodSource(string method) void VirtualEndpoint::SendMessage(Endpoint::Ptr source, JsonRpcMessage::Ptr message) { - map >::iterator i; + map >::iterator i; i = m_MethodHandlers.find(message->GetMethod()); if (i == m_MethodHandlers.end()) { diff --git a/icinga/virtualendpoint.h b/icinga/virtualendpoint.h index 8c94dc92f..18fc3eecb 100644 --- a/icinga/virtualendpoint.h +++ b/icinga/virtualendpoint.h @@ -7,7 +7,7 @@ namespace icinga class I2_ICINGA_API VirtualEndpoint : public Endpoint { private: - map< string, event > m_MethodHandlers; + map< string, Event > m_MethodHandlers; list m_MethodSources; public: diff --git a/jsonrpc/jsonrpcclient.h b/jsonrpc/jsonrpcclient.h index 408248fbf..9e4f7cedb 100644 --- a/jsonrpc/jsonrpcclient.h +++ b/jsonrpc/jsonrpcclient.h @@ -25,7 +25,7 @@ public: virtual void Start(void); - event OnNewMessage; + Event OnNewMessage; }; }