Re: GMutex vs GStaticMutex



On Tue, 2007-02-06 at 00:18 +0100, Tomasz Jankowski wrote:
:( I still don't know understand...

1. GStaticMutex are cheaper in use, am I right?

They are allocated on the stack and can be initialized at compile time.
there is also a little blurb here [1] about some technical details 
about not having to call g_thread_init() from a program or library
that might or might not be included in a threaded program.

2. What's the main advantages of GStaticMutex
3. Where I should use GMutex instead of GStaticMutex

A GMutex is allocated on the heap, so it doesnt need to be a global
or static variable.

Cheers,
                 -Tristan

[1]http://developer.gnome.org/doc/API/2.0/glib/glib-Threads.html#GStaticMutex

PS: if you didnt get it, you need to learn your C, not
your glib/gtk+, so since I'm still idly typing here this
morning so far:

aw_hell_heres_a_quick_lesson_in_c_programming()
{
   /* in this example:
    * 'a' is allocated on the stack
    * '*b' is allocated on the heap
    * 'b' is allocated on the stack
    *
    * the value of 'b' is the memory address on the heap
    * where the value of '*b' is stored.
    */
   int  a;
   int *b = malloc (sizeof (int));
}






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]