]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
add comments 7647/head
authorbert hubert <bert.hubert@netherlabs.nl>
Mon, 1 Apr 2019 13:48:55 +0000 (15:48 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Mon, 1 Apr 2019 13:48:55 +0000 (15:48 +0200)
pdns/rec_channel_rec.cc

index e130ec58b51f7b2e3adb02674bcee7364b50333e..a16b4362298d7b844e2aa1794299c7183b67fb0f 100644 (file)
@@ -657,6 +657,14 @@ static uint64_t getUserTimeMsec()
   return (ru.ru_utime.tv_sec*1000ULL + ru.ru_utime.tv_usec/1000);
 }
 
+/* This is a pretty weird set of functions. To get per-thread cpu usage numbers,
+   we have to ask a thread over a pipe. We could do so surgically, so if you want to know about
+   thread 3, we pick pipe 3, but we lack that infrastructure.
+
+   We can however ask "execute this function on all threads and add up the results".
+   This is what the first function does using a custom object ThreadTimes, which if you add
+   to each other keeps filling the first one with CPU usage numbers
+*/
 
 ThreadTimes* pleaseGetThreadCPUMsec()
 {
@@ -670,6 +678,12 @@ ThreadTimes* pleaseGetThreadCPUMsec()
   return new ThreadTimes{ret};
 }
 
+/* Next up, when you want msec data for a specific thread, we check
+   if we recently executed pleaseGetThreadCPUMsec. If we didn't we do so
+   now and consult all threads.
+
+   We then answer you from the (re)fresh(ed) ThreadTimes.
+*/
 uint64_t doGetThreadCPUMsec(int n)
 {
   static std::mutex s_mut;