1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#include <glib.h>
#include "executor.h"
G_LOCK_DEFINE (blah);
GList *list;
static void
the_job (gpointer data)
{
int i;
G_LOCK (blah);
for (i = 0; i < 34540; ++i)
;
#if 0
g_print ("%d he string is: %p\n",
(GPOINTER_TO_INT (data)), g_thread_self());
#endif
list = g_list_prepend (list, data);
G_UNLOCK (blah);
}
int
main ()
{
Executor *exe = executor_new (4);
int i;
for (i = 0; i < 200000; ++i)
{
executor_add_job (exe, the_job, i * 10 + 0);
executor_add_job (exe, the_job, i * 10 + 1);
executor_add_job (exe, the_job, i * 10 + 2);
executor_add_job (exe, the_job, i * 10 + 3);
executor_add_job (exe, the_job, i * 10 + 4);
executor_add_job (exe, the_job, i * 10 + 5);
executor_add_job (exe, the_job, i * 10 + 6);
executor_add_job (exe, the_job, i * 10 + 7);
executor_add_job (exe, the_job, i * 10 + 8);
executor_add_job (exe, the_job, i * 10 + 9);
}
executor_sync (exe);
executor_free (exe);
g_print ("%d\n", g_list_length (list));
}
|