libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
pool_thread_impl.hpp
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright © 2004 by J.M.McGuiness, coder@hussar.me.uk
3 **
4 ** This library is free software; you can redistribute it and/or
5 ** modify it under the terms of the GNU Lesser General Public
6 ** License as published by the Free Software Foundation; either
7 ** version 2.1 of the License, or (at your option) any later version.
8 **
9 ** This library is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ** Lesser General Public License for more details.
13 **
14 ** You should have received a copy of the GNU Lesser General Public
15 ** License along with this library; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 
19 namespace jmmcg { namespace ppd { namespace pool { namespace thread_types {
20 
21 template<class WQ> inline
25 }
26 
27 template<class WQ> inline
29 ~steal() {
31 }
32 
33 template<class WQ> inline
36 process() noexcept(false) {
37  // Serialize access to the queue by all of the other threads in the pool, this means that only one job can be removed at a time from the work queue.
38  for (;;) {
42  // Ensure the rest of the threads in the pool exit.
44  break;
47  }
48  }
50 }
51 
52 template<class WQ> inline
56 }
57 
58 template<class WQ> inline
60 ~slave() {
62 }
63 
64 template<class WQ> inline
67 process() noexcept(false) {
68  some_work->process();
70 }
71 
72 template<class WQ> inline
76 }
77 
78 template<class WQ> inline
80 ~steal() {
82 }
83 
84 template<class WQ> inline
87 process() noexcept(false) {
88  // Serialize access to the queue by all of the other threads in the pool, this means that only one job can be removed at a time from the work queue.
89  for (;;) {
93  // Ensure the rest of the threads in the pool exit.
95  break;
98  }
99  }
101 }
102 
103 template<class WQ> inline
107 }
108 
109 template<class WQ> inline
111 ~slave() {
113 }
114 
115 template<class WQ> inline
118 process() noexcept(false) {
121  } else {
122  some_work->process();
123  }
125 }
126 
127 } } } }