summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-08 09:19:36 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-08 09:19:36 -0400
commit8a46452a700fa5a8d6fc3bd9308bf483cd715de1 (patch)
treeef548e9fb3b2f715fed9f765120a4cc00c0a7abb /node
parent20f8668c286b2991f5eb1984dde6a8a76434d12d (diff)
downloadinfinitytier-8a46452a700fa5a8d6fc3bd9308bf483cd715de1.tar.gz
infinitytier-8a46452a700fa5a8d6fc3bd9308bf483cd715de1.zip
Move template parameter in Thread to a more logical scope location.
Diffstat (limited to 'node')
-rw-r--r--node/EthernetTap.cpp6
-rw-r--r--node/EthernetTap.hpp2
-rw-r--r--node/Node.cpp2
-rw-r--r--node/Service.cpp10
-rw-r--r--node/Service.hpp2
-rw-r--r--node/Thread.hpp7
-rw-r--r--node/Topology.cpp4
-rw-r--r--node/Topology.hpp2
-rw-r--r--node/UdpSocket.cpp4
-rw-r--r--node/UdpSocket.hpp2
10 files changed, 20 insertions, 21 deletions
diff --git a/node/EthernetTap.cpp b/node/EthernetTap.cpp
index b2682006..4c300d0b 100644
--- a/node/EthernetTap.cpp
+++ b/node/EthernetTap.cpp
@@ -187,7 +187,7 @@ EthernetTap::EthernetTap(
TRACE("tap %s created",_dev);
- _thread = Thread<EthernetTap>::start(this);
+ _thread = Thread::start(this);
}
#endif // __LINUX__
@@ -271,14 +271,14 @@ EthernetTap::EthernetTap(
::pipe(_shutdownSignalPipe);
- _thread = Thread<EthernetTap>::start(this);
+ _thread = Thread::start(this);
}
#endif // __APPLE__
EthernetTap::~EthernetTap()
{
::write(_shutdownSignalPipe[1],"\0",1); // causes thread to exit
- Thread<EthernetTap>::join(_thread);
+ Thread::join(_thread);
::close(_fd);
}
diff --git a/node/EthernetTap.hpp b/node/EthernetTap.hpp
index 6fb4c134..292146bc 100644
--- a/node/EthernetTap.hpp
+++ b/node/EthernetTap.hpp
@@ -180,7 +180,7 @@ private:
const unsigned int _mtu;
const RuntimeEnvironment *_r;
- Thread<EthernetTap> _thread;
+ Thread _thread;
std::set<InetAddress> _ips;
Mutex _ips_m;
diff --git a/node/Node.cpp b/node/Node.cpp
index e5332480..92d8a75c 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -431,7 +431,7 @@ Node::ReasonForTermination Node::run()
if (lastDelayDelta >= ZT_SLEEP_WAKE_DETECTION_THRESHOLD) {
resynchronize = true;
LOG("probable suspend/resume detected, pausing a moment for things to settle...");
- Thread<Node>::sleep(ZT_SLEEP_WAKE_SETTLE_TIME);
+ Thread::sleep(ZT_SLEEP_WAKE_SETTLE_TIME);
}
// Periodically check our network environment, sending pings out to all
diff --git a/node/Service.cpp b/node/Service.cpp
index 0d4702f8..5806db13 100644
--- a/node/Service.cpp
+++ b/node/Service.cpp
@@ -62,7 +62,7 @@ Service::Service(const RuntimeEnvironment *renv,const char *name,const char *pat
_childStderr(0),
_run(true)
{
- _thread = Thread<Service>::start(this);
+ _thread = Thread::start(this);
}
Service::~Service()
@@ -77,14 +77,14 @@ Service::~Service()
pid = 0;
break;
}
- Thread<Service>::sleep(100);
+ Thread::sleep(100);
}
if (pid > 0) {
::kill(pid,SIGKILL);
waitpid(pid,&st,0);
}
}
- Thread<Service>::join(_thread);
+ Thread::join(_thread);
}
bool Service::send(const Dictionary &msg)
@@ -136,7 +136,7 @@ void Service::threadMain()
close(in[0]);
close(out[1]);
close(err[1]);
- Thread<Service>::sleep(500); // give child time to start
+ Thread::sleep(500); // give child time to start
_childStdin = in[1];
_childStdout = out[0];
_childStderr = err[0];
@@ -168,7 +168,7 @@ void Service::threadMain()
LOG("service %s exited with exit code: %d, delaying 1s to attempt relaunch",_name.c_str(),st);
- Thread<Service>::sleep(1000); // wait to relaunch
+ Thread::sleep(1000); // wait to relaunch
continue;
}
}
diff --git a/node/Service.hpp b/node/Service.hpp
index 0b00d81d..d8467cd1 100644
--- a/node/Service.hpp
+++ b/node/Service.hpp
@@ -114,7 +114,7 @@ public:
private:
const RuntimeEnvironment *_r;
- Thread<Service> _thread;
+ Thread _thread;
std::string _path;
std::string _name;
void *_arg;
diff --git a/node/Thread.hpp b/node/Thread.hpp
index 444da2be..ea75297a 100644
--- a/node/Thread.hpp
+++ b/node/Thread.hpp
@@ -57,11 +57,8 @@ static void *___zt_threadMain(void *instance)
}
/**
- * A thread of a given class type
- *
- * @tparam C Class using Thread
+ * A thread identifier, and static methods to start and join threads
*/
-template<typename C>
class Thread
{
public:
@@ -90,7 +87,9 @@ public:
* @param instance Instance whose threadMain() method gets called by new thread
* @return Thread identifier
* @throws std::runtime_error Unable to create thread
+ * @tparam C Class containing threadMain()
*/
+ template<typename C>
static inline Thread start(C *instance)
throw(std::runtime_error)
{
diff --git a/node/Topology.cpp b/node/Topology.cpp
index ff012eaa..0745c8f6 100644
--- a/node/Topology.cpp
+++ b/node/Topology.cpp
@@ -54,7 +54,7 @@ Topology::Topology(const RuntimeEnvironment *renv,const char *dbpath)
Utils::lockDownFile(dbpath,false); // node.db caches secrets
- _thread = Thread<Topology>::start(this);
+ _thread = Thread::start(this);
}
Topology::~Topology()
@@ -67,7 +67,7 @@ Topology::~Topology()
_peerDeepVerifyJobs.back().type = _PeerDeepVerifyJob::EXIT_THREAD;
}
_peerDeepVerifyJobs_c.signal();
- Thread<Topology>::join(_thread);
+ Thread::join(_thread);
KISSDB_close(&_dbm);
}
diff --git a/node/Topology.hpp b/node/Topology.hpp
index dbccff80..3c504218 100644
--- a/node/Topology.hpp
+++ b/node/Topology.hpp
@@ -299,7 +299,7 @@ private:
};
const RuntimeEnvironment *const _r;
- Thread<Topology> _thread;
+ Thread _thread;
std::map< Address,SharedPtr<Peer> > _activePeers;
Mutex _activePeers_m;
diff --git a/node/UdpSocket.cpp b/node/UdpSocket.cpp
index 12a0a989..d1eb87d6 100644
--- a/node/UdpSocket.cpp
+++ b/node/UdpSocket.cpp
@@ -120,7 +120,7 @@ UdpSocket::UdpSocket(
}
}
- _thread = Thread<UdpSocket>::start(this);
+ _thread = Thread::start(this);
}
UdpSocket::~UdpSocket()
@@ -131,7 +131,7 @@ UdpSocket::~UdpSocket()
::shutdown(s,SHUT_RDWR);
::close(s);
}
- Thread<UdpSocket>::join(_thread);
+ Thread::join(_thread);
}
bool UdpSocket::send(const InetAddress &to,const void *data,unsigned int len,int hopLimit)
diff --git a/node/UdpSocket.hpp b/node/UdpSocket.hpp
index fcf13e24..c6200eac 100644
--- a/node/UdpSocket.hpp
+++ b/node/UdpSocket.hpp
@@ -94,7 +94,7 @@ public:
throw();
private:
- Thread<UdpSocket> _thread;
+ Thread _thread;
void (*_packetHandler)(UdpSocket *,void *,const InetAddress &,const void *,unsigned int);
void *_arg;
int _localPort;