]> git.ipfire.org Git - thirdparty/pdns.git/blobdiff - pdns/mtasker.hh
builder: avoid config change prompts on each pdns-recursor update
[thirdparty/pdns.git] / pdns / mtasker.hh
index ced18d1b4a942f3524ba45825e3b3ab05bb718c9..bff0eca0ff1c5f77e88b1e4a2a8f1a0cf1214c67 100644 (file)
@@ -19,8 +19,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
-#ifndef MTASKER_HH
-#define MTASKER_HH
+#pragma once
 #include <stdint.h>
 #include <queue>
 #include <vector>
@@ -68,9 +67,10 @@ private:
 
   typedef std::map<int, ThreadInfo> mthreads_t;
   mthreads_t d_threads;
+  size_t d_stacksize;
+  size_t d_threadsCount;
   int d_tid;
   int d_maxtid;
-  size_t d_stacksize;
 
   EventVal d_waitval;
   enum waitstatusenum {Error=-1,TimeOut=0,Answer} d_waitstatus;
@@ -110,9 +110,12 @@ public:
       This limit applies solely to the stack, the heap is not limited in any way. If threads need to allocate a lot of data,
       the use of new/delete is suggested. 
    */
-  MTasker(size_t stacksize=8192) : d_tid(0), d_maxtid(0), d_stacksize(stacksize), d_waitstatus(Error)
+  MTasker(size_t stacksize=16*8192) : d_stacksize(stacksize), d_threadsCount(0), d_tid(0), d_maxtid(0), d_waitstatus(Error)
   {
     initMainStackBounds();
+
+    // make sure our stack is 16-byte aligned to make all the architectures happy
+    d_stacksize = d_stacksize >> 4 << 4;
   }
 
   typedef void tfunc_t(void *); //!< type of the pointer that starts a thread 
@@ -122,9 +125,9 @@ public:
   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();
 
@@ -132,6 +135,3 @@ private:
   EventKey d_eventkey;   // for waitEvent, contains exact key it was awoken for
 };
 #include "mtasker.cc"
-
-#endif // MTASKER_HH
-