Re: GMutex vs GStaticMutex
- From: Tristan Van Berkom <tvb gnome org>
- To: Tomasz Jankowski <tomcioj gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: GMutex vs GStaticMutex
- Date: Mon, 05 Feb 2007 13:53:28 -0500
On Mon, 2007-02-05 at 19:33 +0100, Tomasz Jankowski wrote:
Hi!
I'm not sure if I understood difference between these two types of mutexes.
Can someone explain it for me more clearly, that it is in GLib's
documentation ;) Next thing, I have program, which will run few threads (one
thread - one object), so each object need to have it's own mutex, which will
be better for me GMutex or GStatisMutex?
Hi.
A mutex requires some memory space to function, that memory can be
allocated on the heap or on the stack, if its on the stack then
you'll use a static mutex and initialize it to the right value.
Typically you'll use a static mutex in a reentrant function that has
a critical section to protect, a mutex on the heap on the other hand
is usually used to protext a specific resource that is shared and
accessible throughout program execution (in which case you need
to expose and share the mutex object allocated on the heap as well).
Cheers,
-Tristan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]