#include #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; }