summaryrefslogtreecommitdiff
path: root/test.c
blob: 668ba1fffa14f30af9405176e3cddf32edcb9ba3 (plain)
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
53
54
55
56
57
58
59
60
#include <glib.h>
#include "jobqueue.h"

G_LOCK_DEFINE (blah);

GList *list;

static void
the_job (gpointer data)
{
    int i;
    
#if 0
    G_LOCK (blah);
#endif
    
    for (i = 0; i < 34540; ++i)
	;
    
#if 0
    g_print ("%d he string is: %p\n",
	     (GPOINTER_TO_INT (data)), g_thread_self());
#endif
    
#if 0
    list = g_list_prepend (list, data);
    
    G_UNLOCK (blah);
#endif
}

int
main ()
{
    Executor *exe = executor_new (10);
    int i;
    
    for (i = 0; i < 2000; ++i)
    {
	JobQueue *queue = job_queue_new (exe);

	job_queue_add (queue, the_job, GINT_TO_POINTER (i * 10 + 0));
	job_queue_add (queue, the_job, GINT_TO_POINTER (i * 10 + 1));
	job_queue_add (queue, the_job, GINT_TO_POINTER (i * 10 + 2));
	job_queue_add (queue, the_job, GINT_TO_POINTER (i * 10 + 3));
	job_queue_add (queue, the_job, GINT_TO_POINTER (i * 10 + 4));
	job_queue_add (queue, the_job, GINT_TO_POINTER (i * 10 + 5));
	job_queue_add (queue, the_job, GINT_TO_POINTER (i * 10 + 6));
	job_queue_add (queue, the_job, GINT_TO_POINTER (i * 10 + 7));
	job_queue_add (queue, the_job, GINT_TO_POINTER (i * 10 + 8));
	job_queue_add (queue, the_job, GINT_TO_POINTER (i * 10 + 9));
    }

    executor_sync (exe);
    executor_free (exe);
    
    g_print ("%d\n", g_list_length (list));

    return 0;
}