|
a/libupnpp/workqueue.hxx |
|
b/libupnpp/workqueue.hxx |
|
... |
|
... |
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
*/
|
16 |
*/
|
17 |
#ifndef _WORKQUEUE_H_INCLUDED_
|
17 |
#ifndef _WORKQUEUE_H_INCLUDED_
|
18 |
#define _WORKQUEUE_H_INCLUDED_
|
18 |
#define _WORKQUEUE_H_INCLUDED_
|
19 |
|
19 |
|
|
|
20 |
#include "libupnpp/config.h"
|
|
|
21 |
|
20 |
#include <pthread.h>
|
22 |
#include <pthread.h>
|
21 |
#include <time.h>
|
23 |
#include <time.h>
|
22 |
|
24 |
|
23 |
#include <string>
|
25 |
#include <string>
|
24 |
#include <queue>
|
26 |
#include <queue>
|
25 |
#include <unordered_map>
|
|
|
26 |
|
27 |
|
27 |
#include "ptmutex.hxx"
|
28 |
#include "ptmutex.hxx"
|
28 |
|
29 |
|
29 |
namespace UPnPP {
|
30 |
namespace UPnPP {
|
30 |
|
31 |
|
|
... |
|
... |
198 |
}
|
199 |
}
|
199 |
|
200 |
|
200 |
// Perform the thread joins and compute overall status
|
201 |
// Perform the thread joins and compute overall status
|
201 |
// Workers return (void*)1 if ok
|
202 |
// Workers return (void*)1 if ok
|
202 |
void *statusall = (void*)1;
|
203 |
void *statusall = (void*)1;
|
203 |
std::unordered_map<pthread_t, WQTData>::iterator it;
|
204 |
STD_UNORDERED_MAP<pthread_t, WQTData>::iterator it;
|
204 |
while (!m_worker_threads.empty()) {
|
205 |
while (!m_worker_threads.empty()) {
|
205 |
void *status;
|
206 |
void *status;
|
206 |
it = m_worker_threads.begin();
|
207 |
it = m_worker_threads.begin();
|
207 |
pthread_join(it->first, &status);
|
208 |
pthread_join(it->first, &status);
|
208 |
if (status == (void *)0)
|
209 |
if (status == (void *)0)
|
|
... |
|
... |
303 |
unsigned int m_workers_exited;
|
304 |
unsigned int m_workers_exited;
|
304 |
bool m_ok;
|
305 |
bool m_ok;
|
305 |
|
306 |
|
306 |
// Per-thread data. The data is not used currently, this could be
|
307 |
// Per-thread data. The data is not used currently, this could be
|
307 |
// a set<pthread_t>
|
308 |
// a set<pthread_t>
|
308 |
std::unordered_map<pthread_t, WQTData> m_worker_threads;
|
309 |
STD_UNORDERED_MAP<pthread_t, WQTData> m_worker_threads;
|
309 |
|
310 |
|
310 |
// Synchronization
|
311 |
// Synchronization
|
311 |
std::queue<T> m_queue;
|
312 |
std::queue<T> m_queue;
|
312 |
pthread_cond_t m_ccond;
|
313 |
pthread_cond_t m_ccond;
|
313 |
pthread_cond_t m_wcond;
|
314 |
pthread_cond_t m_wcond;
|