scheduling_policies.hpp
Go to the documentation of this file.
1 
22 #ifndef THREADPOOL_SCHEDULING_POLICIES_HPP_INCLUDED
23 #define THREADPOOL_SCHEDULING_POLICIES_HPP_INCLUDED
24 
25 
26 #include <queue>
27 #include <deque>
28 
29 #include "task_adaptors.hpp"
30 
31 namespace boost { namespace threadpool
32 {
33 
44  template <typename Task = task_func>
46  {
47  public:
48  typedef Task task_type;
49 
50  protected:
51  std::deque<task_type> m_container;
52 
53 
54  public:
59  bool push(task_type const & task)
60  {
61  m_container.push_back(task);
62  return true;
63  }
64 
67  void pop()
68  {
69  m_container.pop_front();
70  }
71 
75  task_type const & top() const
76  {
77  return m_container.front();
78  }
79 
84  size_t size() const
85  {
86  return m_container.size();
87  }
88 
93  bool empty() const
94  {
95  return m_container.empty();
96  }
97 
100  void clear()
101  {
102  m_container.clear();
103  }
104  };
105 
106 
107 
117  template <typename Task = task_func>
119  {
120  public:
121  typedef Task task_type;
122 
123  protected:
124  std::deque<task_type> m_container;
125 
126  public:
131  bool push(task_type const & task)
132  {
133  m_container.push_front(task);
134  return true;
135  }
136 
139  void pop()
140  {
141  m_container.pop_front();
142  }
143 
147  task_type const & top() const
148  {
149  return m_container.front();
150  }
151 
156  size_t size() const
157  {
158  return m_container.size();
159  }
160 
165  bool empty() const
166  {
167  return m_container.empty();
168  }
169 
172  void clear()
173  {
174  m_container.clear();
175  }
176 
177  };
178 
179 
180 
192  template <typename Task = prio_task_func>
194  {
195  public:
196  typedef Task task_type;
197 
198  protected:
199  std::priority_queue<task_type> m_container;
200 
201 
202  public:
207  bool push(task_type const & task)
208  {
209  m_container.push(task);
210  return true;
211  }
212 
215  void pop()
216  {
217  m_container.pop();
218  }
219 
223  task_type const & top() const
224  {
225  return m_container.top();
226  }
227 
232  size_t size() const
233  {
234  return m_container.size();
235  }
236 
241  bool empty() const
242  {
243  return m_container.empty();
244  }
245 
248  void clear()
249  {
250  while(!m_container.empty())
251  {
252  m_container.pop();
253  }
254  }
255  };
256 
257 
258 } } // namespace boost::threadpool
259 
260 
261 #endif // THREADPOOL_SCHEDULING_POLICIES_HPP_INCLUDED
262 
The namespace threadpool contains a thread pool and related utility classes.
Task adaptors.
SchedulingPolicy which implements prioritized ordering.
bool push(task_type const &task)
Task task_type
Indicates the scheduler&#39;s task type.
std::priority_queue< task_type > m_container
Internal task container.
std::deque< task_type > m_container
Internal task container.
bool push(task_type const &task)
std::deque< task_type > m_container
Internal task container.
Task task_type
Indicates the scheduler&#39;s task type.
Task task_type
Indicates the scheduler&#39;s task type.
SchedulingPolicy which implements FIFO ordering.
bool push(task_type const &task)
SchedulingPolicy which implements LIFO ordering.


asr_descriptor_surface_based_recognition
Author(s): Allgeyer Tobias, Hutmacher Robin, Meißner Pascal
autogenerated on Mon Dec 16 2019 03:31:15