Renamed event/condvar/mutex/thread classes to match other class names.

This commit is contained in:
Gunnar Beutner 2012-04-16 08:36:50 +02:00
parent 8f7fb9699d
commit 40b45c3d91
16 changed files with 67 additions and 75 deletions

View File

@ -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;

View File

@ -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 */
};

View File

@ -27,9 +27,9 @@ public:
void ForEachObject(function<int (ConfigObjectEventArgs::Ptr)> callback);
event<ConfigObjectEventArgs::Ptr> OnObjectCreated;
event<ConfigObjectEventArgs::Ptr> OnObjectRemoved;
event<ConfigObjectEventArgs::Ptr> OnPropertyChanged;
Event<ConfigObjectEventArgs::Ptr> OnObjectCreated;
Event<ConfigObjectEventArgs::Ptr> OnObjectRemoved;
Event<ConfigObjectEventArgs::Ptr> OnPropertyChanged;
};
}

View File

@ -20,9 +20,9 @@ public:
void ForEachObject(const string& type, function<int (ConfigObjectEventArgs::Ptr)> callback);
event<ConfigObjectEventArgs::Ptr> OnObjectCreated;
event<ConfigObjectEventArgs::Ptr> OnObjectRemoved;
event<ConfigObjectEventArgs::Ptr> OnPropertyChanged;
Event<ConfigObjectEventArgs::Ptr> OnObjectCreated;
Event<ConfigObjectEventArgs::Ptr> OnObjectRemoved;
Event<ConfigObjectEventArgs::Ptr> OnPropertyChanged;
};
}

View File

@ -13,7 +13,7 @@ struct I2_BASE_API EventArgs : public Object
};
template<class TArgs>
class event
class Event
{
public:
typedef function<int (TArgs)> DelegateType;
@ -22,25 +22,25 @@ private:
list<DelegateType> 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<TArgs>& operator +=(const DelegateType& rhs)
Event<TArgs>& operator +=(const DelegateType& rhs)
{
hook(rhs);
Hook(rhs);
return *this;
}
event<TArgs>& operator -=(const DelegateType& rhs)
Event<TArgs>& operator -=(const DelegateType& rhs)
{
unhook(rhs);
Unhook(rhs);
return *this;
}

View File

@ -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;

View File

@ -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 */
};

View File

@ -40,12 +40,12 @@ public:
static void CloseAllSockets(void);
event<EventArgs::Ptr> OnReadable;
event<EventArgs::Ptr> OnWritable;
event<EventArgs::Ptr> OnException;
Event<EventArgs::Ptr> OnReadable;
Event<EventArgs::Ptr> OnWritable;
Event<EventArgs::Ptr> OnException;
event<SocketErrorEventArgs::Ptr> OnError;
event<EventArgs::Ptr> OnClosed;
Event<SocketErrorEventArgs::Ptr> OnError;
Event<EventArgs::Ptr> OnClosed;
virtual bool WantsToRead(void) const;
virtual bool WantsToWrite(void) const;

View File

@ -35,7 +35,7 @@ public:
virtual bool WantsToRead(void) const;
virtual bool WantsToWrite(void) const;
event<EventArgs::Ptr> OnDataAvailable;
Event<EventArgs::Ptr> OnDataAvailable;
};
}

View File

@ -32,7 +32,7 @@ public:
void Listen(void);
event<NewClientEventArgs::Ptr> OnNewClient;
Event<NewClientEventArgs::Ptr> OnNewClient;
virtual bool WantsToRead(void) const;
};

View File

@ -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);

View File

@ -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);
};
}

View File

@ -49,7 +49,7 @@ public:
void Reschedule(time_t next);
event<TimerEventArgs::Ptr> OnTimerExpired;
Event<TimerEventArgs::Ptr> OnTimerExpired;
};
}

View File

@ -30,7 +30,7 @@ void VirtualEndpoint::UnregisterMethodSource(string method)
void VirtualEndpoint::SendMessage(Endpoint::Ptr source, JsonRpcMessage::Ptr message)
{
map<string, event<NewMessageEventArgs::Ptr> >::iterator i;
map<string, Event<NewMessageEventArgs::Ptr> >::iterator i;
i = m_MethodHandlers.find(message->GetMethod());
if (i == m_MethodHandlers.end()) {

View File

@ -7,7 +7,7 @@ namespace icinga
class I2_ICINGA_API VirtualEndpoint : public Endpoint
{
private:
map< string, event<NewMessageEventArgs::Ptr> > m_MethodHandlers;
map< string, Event<NewMessageEventArgs::Ptr> > m_MethodHandlers;
list<string> m_MethodSources;
public:

View File

@ -25,7 +25,7 @@ public:
virtual void Start(void);
event<NewMessageEventArgs::Ptr> OnNewMessage;
Event<NewMessageEventArgs::Ptr> OnNewMessage;
};
}