how to make a function thread safe?
- From: Felix Kater <f kater2 gmx net>
- To: GTK Mailing List <gtk-app-devel-list gnome org>
- Subject: how to make a function thread safe?
- Date: Fri, 28 Jan 2005 00:18:53 +0100
Hi,
is a function thread save when all inside code is wrapped into a static
mutex?
What is with this function: Could a second thread influence the first
thread while it is looping (because of the pointer argument)?
void f(gint* my_gint){
static GStaticMutex my_mutex = G_STATIC_MUTEX_INIT;
g_static_mutex_lock(&my_mutex);
while(TRUE)
{
g_printf("value: %d\n", *my_gint);
/* ... */
}
g_static_mutex_unlock(&my_mutex);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]