[Goodies-dev] [Goodies-commits] r1753 - in verve-plugin/trunk: . panel-plugin

Jannis Pohlmann jannis at xfce.org
Thu Jul 13 01:28:45 CEST 2006


On Thu, 13 Jul 2006 01:02:30 +0200, Benedikt Meurer wrote:

> >> G_LOCK_DEFINE_STATIC(your_lock);
> >>
> >>and add
> >>
> >> G_LOCK(your_lock);
> >> ...
> >> G_UNLOCK(your_lock);
> >>
> >>to protect the access to your completion.
> > 
> > Ah, ok. Would this require to make the completion a static variable
> > in verve-plugin.c, where all the panel plugin related stuff is done?
> 
> No you can use one static lock to protect access to "all" completions.
> You could of course also assign a mutex "per" completion.

Oh, I think I finally understand how this mutex locking works. The name
passed to G_LOCK_DEFINE_STATIC, G_LOCK, G_UNLOCK is just an alias to
identify the mutex, right? At first, I thought it has to be named after
the variabe which one wants to lock ... 

Ok, here's what I guess should work.

verve-plugin.c:

  G_LOCK_DEFINE_STATIC (plugin_completion_mutex);

  void
  verve_plugin_load_completion (VerveEnv* env, gpointer user_data)
  {
    VervePlugin *verve = (VervePlugin*) user_data;
    ...
    G_LOCK (plugin_completion_mutex);

    verve->completion = g_completion_new (NULL);

    /* Add command history to completion */
    if (G_LIKELY (history != NULL)) 
      g_completion_add_items (verve->completion, history);
  
    /* Add binaries to completion list */
    if (G_LIKELY (binaries != NULL))
      g_completion_add_items (verve->completion, binaries);

    G_UNLOCK (plugin_completion_mutex);
  }

  ...

    g_signal_connect (G_OBJECT (verve_env_get()), "load-binaries",
      G_CALLBACK (verve_plugin_load_completion), verve);

  ...

verve_plugin_load_completion is a callback for reacting on the
"load-binaries" signal, emitted by the worker thread after it has
loaded all binary files in $PATH into the completion. 

Would this work (which I hope ...)? And do I need to wrap the
signal_emit_by_name (in the worker thread) in gdk_threads_enter/leave
calls?

Regards,
Jannis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.xfce.org/pipermail/goodies-dev/attachments/20060713/597cf6fe/attachment.pgp>


More information about the Goodies-dev mailing list