Re: Allocate/free in main thread, or just the same thread?
- From: Tristan Van Berkom <tvb gnome org>
- To: Reed Hedges <reed interreality org>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Allocate/free in main thread, or just the same thread?
- Date: Tue, 12 Sep 2006 10:57:46 -0400
Reed Hedges wrote:
[...]
My question is: should glib objects only be allocated/freed in the main
program thread; or, do they just have to be freed by the same thread
that allocated them; or, are there ways to access glib from multiple
threads that I don't yet know about?
It is safe to access a glib object (i.e. GObject) or data structure from
multiple threads the same way its safe to access/modify an integer or string -
as long as you protect the data from yourself simultainiously accessing it
from another thread (i.e. use GMutex and GCond).
If you are accessing data that belongs to GTK+ (i.e. widgets), then
you must share the gdk_threads_mutex with GTK+ (i.e. gdk_threads_enter/leave).
Cheers,
-Tristan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]