2 #include "gstmemchunk.h"
3 #include <string.h> /* strerror */
5 #define MAX_THREADS 100
7 static GstMemChunk *_chunks;
9 static gint num_allocs;
10 static gint num_threads;
16 ret = gst_mem_chunk_alloc (_chunks);
22 free_chunk (gpointer chunk)
24 gst_mem_chunk_free (_chunks, chunk);
29 run_test (void *threadid)
35 for (i = 0; i<num_allocs; i++) {
36 chunk = alloc_chunk ();
46 main (gint argc, gchar *argv[])
48 GThread * threads[MAX_THREADS];
52 gst_init (&argc, &argv);
55 g_print ("usage: %s <num_threads> <num_allocs>\n", argv[0]);
59 num_threads = atoi (argv[1]);
60 num_allocs = atoi (argv[2]);
62 _chunks = gst_mem_chunk_new ("test", 32, 32 * 16, G_ALLOC_AND_FREE);
64 for(t=0; t < num_threads; t++) {
66 threads[t] = g_thread_create (run_test, (void *)t, TRUE, &error);
68 printf ("ERROR: g_thread_create() %s\n", error->message);
72 printf ("main(): Created %d threads.\n", t);
74 for(t=0; t < num_threads; t++) {
75 g_thread_join (threads[t]);
79 gst_mem_chunk_destroy (_chunks);