~ubuntu-branches/ubuntu/trusty/pdns/trusty-backports

« back to all changes in this revision

Viewing changes to pdns/mtasker.hh

  • Committer: Package Import Robot
  • Author(s): Matthijs Möhlmann
  • Date: 2011-11-19 11:58:10 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20111119115810-5u926cmriehkt5j7
Tags: 3.0-1
* New upstream version (Closes: #624330, #626909, #617476, #498918, #500572)
  (Closes: #645539, #623036, #521791, #583161, #590285, #499396)
* Update Standards-Version to 3.9.2
* Add lua backend.
* Use new style dh instead of individual dh_* commands.
* Add Homepage to debian/control (Closes: #634947)
* Add pdnssec and dnsreplay utility.
* Use dbconfig-common to populate / upgrade databases.
* Update patch addconfigdir, do not parse ucf-dist files.
* Update manpage pdns_control and include a list of options (Closes: #621724)
* Add manpage for pdnssec.
* Add prerm scripts to the backends, stop the pdns server.
* Add patch from upstream to properly parse priority. (Closes: #533023)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
    PowerDNS Versatile Database Driven Nameserver
3
 
    Copyright (C) 2002 - 2006  PowerDNS.COM BV
 
3
    Copyright (C) 2002 - 2009  PowerDNS.COM BV
4
4
 
5
5
    This program is free software; you can redistribute it and/or modify
6
6
    it under the terms of the GNU General Public License version 2
32
32
#include <boost/multi_index_container.hpp>
33
33
#include <boost/multi_index/ordered_index.hpp>
34
34
#include <boost/multi_index/key_extractors.hpp>
35
 
using namespace boost;
 
35
#include "namespaces.hh"
36
36
using namespace ::boost::multi_index;
37
37
 
38
38
struct KeyTag {};
50
50
  std::queue<int> d_runQueue;
51
51
  std::queue<int> d_zombiesQueue;
52
52
 
 
53
  struct ThreadInfo
 
54
  {
 
55
        ucontext_t* context;
 
56
        char* startOfStack;
 
57
        char* highestStackSeen;
 
58
  };
53
59
 
54
 
  typedef std::map<int, ucontext_t*> mthreads_t;
 
60
  typedef std::map<int, ThreadInfo> mthreads_t;
55
61
  mthreads_t d_threads;
56
62
  int d_tid;
57
63
  int d_maxtid;
65
71
  {
66
72
    EventKey key;
67
73
    ucontext_t *context;
68
 
    time_t ttd;
69
 
    int tid;
 
74
    struct timeval ttd;
 
75
    int tid;    
70
76
  };
71
77
 
72
78
  typedef multi_index_container<
73
79
    Waiter,
74
80
    indexed_by <
75
81
                ordered_unique<member<Waiter,EventKey,&Waiter::key> >,
76
 
                ordered_non_unique<tag<KeyTag>, member<Waiter,time_t,&Waiter::ttd> >
 
82
                ordered_non_unique<tag<KeyTag>, member<Waiter,struct timeval,&Waiter::ttd> >
77
83
               >
78
84
  > waiters_t;
79
85
 
90
96
  }
91
97
 
92
98
  typedef void tfunc_t(void *); //!< type of the pointer that starts a thread 
93
 
  int waitEvent(EventKey &key, EventVal *val=0, unsigned int timeout=0, unsigned int now=0);
 
99
  int waitEvent(EventKey &key, EventVal *val=0, unsigned int timeoutMsec=0, struct timeval* now=0);
94
100
  void yield();
95
101
  int sendEvent(const EventKey& key, const EventVal* val=0);
96
102
  void getEvents(std::vector<EventKey>& events);
97
103
  void makeThread(tfunc_t *start, void* val);
98
 
  bool schedule(unsigned int now=0);
 
104
  bool schedule(struct timeval* now=0);
99
105
  bool noProcesses();
100
106
  unsigned int numProcesses();
101
107
  int getTid(); 
 
108
  unsigned int getMaxStackUsage();
102
109
 
103
110
private:
104
 
  static void threadWrapper(MTasker *self, tfunc_t *tf, int tid, void* val);
 
111
  static void threadWrapper(uint32_t self1, uint32_t self2, tfunc_t *tf, int tid, uint32_t val1, uint32_t val2);
105
112
  EventKey d_eventkey;   // for waitEvent, contains exact key it was awoken for
106
113
};
107
114
#include "mtasker.cc"