Commit f069320c authored by legoc's avatar legoc
Browse files

changed TimeCondition member to auto ptr

parent e7b5fecc
......@@ -15,6 +15,7 @@
*/
#include "ConnectionChecker.h"
#include "impl/TimeCondition.h"
#include "Server.h"
using namespace std;
......@@ -22,6 +23,7 @@ using namespace std;
namespace cameo {
ConnectionChecker::ConnectionChecker(Server * server, ConnectionChecker::FunctionType handler) : m_server(server), m_function(handler) {
m_waitCondition.reset(new TimeCondition());
}
ConnectionChecker::~ConnectionChecker() {
......@@ -32,7 +34,7 @@ void ConnectionChecker::loop(int timeoutMs, int pollingTimeMs) {
// Loop until the condition is notified.
while (true) {
bool stopped = m_waitCondition.wait(pollingTimeMs);
bool stopped = m_waitCondition->wait(pollingTimeMs);
if (stopped) {
return;
}
......@@ -57,7 +59,7 @@ void ConnectionChecker::startThread(int timeoutMs, int pollingTimeMs) {
void ConnectionChecker::stopThread() {
if (m_thread.get() != 0) {
m_waitCondition.notify();
m_waitCondition->notify();
m_thread->join();
}
}
......
......@@ -17,7 +17,6 @@
#ifndef CAMEO_CONNECTIONCHECKER_H_
#define CAMEO_CONNECTIONCHECKER_H_
#include "impl/TimeCondition.h"
#include <boost/function.hpp>
#include <boost/thread.hpp>
#include <boost/bind.hpp>
......@@ -28,6 +27,7 @@
namespace cameo {
class Server;
class TimeCondition;
/**
* Class providing a simple connection checker.
......@@ -49,7 +49,7 @@ private:
void loop(int timeoutMs, int pollingTimeMs);
Server * m_server;
TimeCondition m_waitCondition;
std::auto_ptr<TimeCondition> m_waitCondition;
FunctionType m_function;
std::auto_ptr<boost::thread> m_thread;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment