2 * Copyright (C) <2009> Wim Taymans <wim taymans at gmail dot com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
23 #include <gst/glib-compat-private.h>
25 #define MAX_THREADS 100
27 static gboolean running = TRUE;
28 static gint count = 0;
31 run_test (void *user_data)
34 GstClock *sysclock = GST_CLOCK_CAST (user_data);
37 gst_clock_get_time (sysclock);
38 prev = G_ATOMIC_INT_ADD (&count, 1);
40 g_warning ("overflow");
47 main (gint argc, gchar * argv[])
49 GThread *threads[MAX_THREADS];
54 gst_init (&argc, &argv);
57 g_print ("usage: %s <num_threads>\n", argv[0]);
61 num_threads = atoi (argv[1]);
63 sysclock = gst_system_clock_obtain ();
65 for (t = 0; t < num_threads; t++) {
68 threads[t] = g_thread_create (run_test, sysclock, TRUE, &error);
70 printf ("ERROR: g_thread_create() %s\n", error->message);
74 printf ("main(): Created %d threads.\n", t);
76 /* run for 5 seconds */
77 g_usleep (G_USEC_PER_SEC * 5);
79 printf ("main(): Stopping threads...\n");
83 for (t = 0; t < num_threads; t++) {
84 g_thread_join (threads[t]);
87 g_print ("performed %d get_time operations\n", count);
89 gst_object_unref (sysclock);