Move template parameter in Thread to a more logical scope location.

This commit is contained in:
Adam Ierymenko 2013-08-08 09:19:36 -04:00
parent 20f8668c28
commit 8a46452a70
10 changed files with 20 additions and 21 deletions

View File

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

View File

@ -180,7 +180,7 @@ private:
const unsigned int _mtu;
const RuntimeEnvironment *_r;
Thread<EthernetTap> _thread;
Thread _thread;
std::set<InetAddress> _ips;
Mutex _ips_m;

View File

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

View File

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

View File

@ -114,7 +114,7 @@ public:
private:
const RuntimeEnvironment *_r;
Thread<Service> _thread;
Thread _thread;
std::string _path;
std::string _name;
void *_arg;

View File

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

View File

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

View File

@ -299,7 +299,7 @@ private:
};
const RuntimeEnvironment *const _r;
Thread<Topology> _thread;
Thread _thread;
std::map< Address,SharedPtr<Peer> > _activePeers;
Mutex _activePeers_m;

View File

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

View File

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