/** Call this to check if no processes are running anymore
\return true if no processes are left
*/
-template<class Key, class Val>bool MTasker<Key,Val>::noProcesses()
+template<class Key, class Val>bool MTasker<Key,Val>::noProcesses() const
{
return d_threads.empty();
}
/** Call this to perhaps limit activities if too many threads are running
\return number of processes running
*/
-template<class Key, class Val>unsigned int MTasker<Key,Val>::numProcesses()
+template<class Key, class Val>unsigned int MTasker<Key,Val>::numProcesses() const
{
return d_threads.size();
}
/** Processes can call this to get a numerical representation of their current thread ID.
This can be useful for logging purposes.
*/
-template<class Key, class Val>int MTasker<Key,Val>::getTid()
+template<class Key, class Val>int MTasker<Key,Val>::getTid() const
{
return d_tid;
}
void getEvents(std::vector<EventKey>& events);
void makeThread(tfunc_t *start, void* val);
bool schedule(struct timeval* now=0);
- bool noProcesses();
- unsigned int numProcesses();
- int getTid();
+ bool noProcesses() const;
+ unsigned int numProcesses() const;
+ int getTid() const;
unsigned int getMaxStackUsage();
unsigned int getUsec();
static thread_local std::unique_ptr<tcpClientCounts_t> t_tcpClientCounts;
thread_local std::unique_ptr<MT_t> MT; // the big MTasker
-MT_t* getMT()
-{
- return MT ? MT.get() : 0;
-}
-
-
thread_local std::unique_ptr<MemRecursorCache> t_RC;
thread_local std::unique_ptr<RecursorPacketCache> t_packetCache;
thread_local FDMultiplexer* t_fdm{nullptr};
LuaContext::LuaObject d_data;
};
+MT_t* getMT()
+{
+ return MT ? MT.get() : nullptr;
+}
ArgvMap &arg()
{
boost::format fmt("%1% %|40t|%2% %|47t|%3% %|63t|%4% %|68t|%5%\n");
ostr << (fmt % "qname" % "qtype" % "remote" % "tcp" % "chained");
- int n=0;
- for(MT_t::waiters_t::iterator mthread=getMT()->d_waiters.begin(); mthread!=getMT()->d_waiters.end() && n < 100; ++mthread, ++n) {
- const PacketID& pident = mthread->key;
+ unsigned int n=0;
+ for(const auto& mthread : getMT()->d_waiters) {
+ const PacketID& pident = mthread.key;
ostr << (fmt
% pident.domain.toLogString() /* ?? */ % DNSRecordContent::NumberToType(pident.type)
% pident.remote.toString() % (pident.sock ? 'Y' : 'n')
% (pident.fd == -1 ? 'Y' : 'n')
);
+ ++n;
+ if (n >= 100)
+ break;
}
ostr <<" - done\n";
return new string(ostr.str());