- Small cleanups

Original commit message from CVS:
- Small cleanups
This commit is contained in:
Wim Taymans 2003-01-27 21:38:51 +00:00
parent 1c324a59f0
commit 196ed576e2
2 changed files with 16 additions and 9 deletions

View file

@ -41,7 +41,7 @@ thread_loop (void *arg)
g_print ("thread: wait ACK\n");
g_cond_wait (info->cond, info->mutex);
info->var = 1;
g_print ("thread: signal\n");
g_print ("thread: signal var change\n");
g_cond_signal (info->cond);
g_print ("thread: unlock\n");
g_mutex_unlock (info->mutex);
@ -56,6 +56,7 @@ main (gint argc, gchar *argv[])
ThreadInfo *info;
GThread *thread;
GError *error = NULL;
gint res = 0;
if (!g_thread_supported ())
g_thread_init (NULL);
@ -76,8 +77,8 @@ main (gint argc, gchar *argv[])
if (error != NULL) {
g_print ("Unable to start thread: %s\n", error->message);
g_error_free (error);
g_free (info);
return -1;
res = -1;
goto done;
}
g_print ("main: wait spinup\n");
@ -85,8 +86,10 @@ main (gint argc, gchar *argv[])
g_print ("main: signal ACK\n");
g_cond_signal (info->cond);
g_print ("main: wait\n");
g_print ("main: waiting for thread to change var\n");
g_cond_wait (info->cond, info->mutex);
g_print ("main: var == %d\n", info->var);
if (info->var != 1)
g_print ("main: !!error!! expected var == 1, got %d\n", info->var);
@ -95,10 +98,11 @@ main (gint argc, gchar *argv[])
g_print ("main: join\n");
g_thread_join (thread);
done:
g_mutex_free (info->mutex);
g_cond_free (info->cond);
g_free (info);
return 0;
return res;
}

View file

@ -57,6 +57,7 @@ main (gint argc, gchar *argv[])
ThreadInfo *info;
GThread *thread;
GError *error = NULL;
gint res = 0;
if (!g_thread_supported ())
g_thread_init (NULL);
@ -78,8 +79,8 @@ main (gint argc, gchar *argv[])
if (error != NULL) {
g_print ("Unable to start thread: %s\n", error->message);
g_error_free (error);
g_free (info);
return -1;
res = -1;
goto done;
}
g_print ("main: wait spinup\n");
@ -92,18 +93,20 @@ main (gint argc, gchar *argv[])
g_cond_wait (info->cond_t, info->mutex);
g_print ("main: var == %d\n", info->var);
if (info->var != 1)
if (info->var != 1) {
g_print ("main: !!error!! expected var == 1, got %d\n", info->var);
}
g_mutex_unlock (info->mutex);
g_print ("main: join\n");
g_thread_join (thread);
done:
g_mutex_free (info->mutex);
g_cond_free (info->cond_t);
g_cond_free (info->cond_p);
g_free (info);
return 0;
return res;
}