|
a/src/utils/workqueue.cpp |
|
b/src/utils/workqueue.cpp |
|
|
1 |
/* Copyright (C) 2014 J.F.Dockes
|
|
|
2 |
* This program is free software; you can redistribute it and/or modify
|
|
|
3 |
* it under the terms of the GNU General Public License as published by
|
|
|
4 |
* the Free Software Foundation; either version 2 of the License, or
|
|
|
5 |
* (at your option) any later version.
|
|
|
6 |
*
|
|
|
7 |
* This program is distributed in the hope that it will be useful,
|
|
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
10 |
* GNU General Public License for more details.
|
|
|
11 |
*
|
|
|
12 |
* You should have received a copy of the GNU General Public License
|
|
|
13 |
* along with this program; if not, write to the
|
|
|
14 |
* Free Software Foundation, Inc.,
|
|
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
16 |
*/
|
|
|
17 |
// Test program for the workqueue module
|
|
|
18 |
|
1 |
#include <stdio.h>
|
19 |
#include <stdio.h>
|
2 |
#include <stdlib.h>
|
20 |
#include <stdlib.h>
|
3 |
#include <unistd.h>
|
|
|
4 |
#include <errno.h>
|
21 |
#include <errno.h>
|
5 |
#include <string.h>
|
22 |
#include <string.h>
|
|
|
23 |
|
|
|
24 |
#ifdef _WIN32
|
|
|
25 |
#include <windows.h>
|
|
|
26 |
static inline unsigned int sleep(unsigned int s) {Sleep(s * 1000); return 0;}
|
|
|
27 |
#else
|
|
|
28 |
#include <unistd.h>
|
|
|
29 |
#endif
|
6 |
|
30 |
|
7 |
#include "workqueue.h"
|
31 |
#include "workqueue.h"
|
8 |
|
32 |
|
9 |
static char *thisprog;
|
33 |
static char *thisprog;
|
10 |
|
34 |
|
|
... |
|
... |
78 |
}
|
102 |
}
|
79 |
|
103 |
|
80 |
if (argc != 0)
|
104 |
if (argc != 0)
|
81 |
Usage();
|
105 |
Usage();
|
82 |
|
106 |
|
83 |
WorkQueue<Task> wq(10);
|
107 |
WorkQueue<Task> wq("testwq", 10);
|
84 |
|
108 |
|
85 |
if (!wq.start(&worker, &wq)) {
|
109 |
if (!wq.start(2, &worker, &wq)) {
|
86 |
fprintf(stderr, "Start failed\n");
|
110 |
fprintf(stderr, "Start failed\n");
|
87 |
exit(1);
|
111 |
exit(1);
|
88 |
}
|
112 |
}
|
89 |
|
113 |
|
90 |
for (;;) {
|
114 |
for (;;) {
|