Exporting shared data in C
Brian J. Tarricone
bjt23 at cornell.edu
Fri Jul 28 02:56:48 CEST 2006
-----BEGIN PGP SIGNED MESSAGE-----
On 7/27/2006 5:45 PM, Jannis Pohlmann wrote:
> Hi all,
> as we were just talking about libfrapmenu/libxfce4menu, I'd like to ask
> the more experienced people how I can export global data which should
> be shared between client applications.
> E.g., we have the root menu (/etc/xdg/menus/applications.menu) which -
> once it's loaded - should be shared among all other applications (e.g.
> a menu panel plugin and the appfinder). Currently, the root menu is
> defined static inside the function frap_menu_get_root:
> static FrapMenu* root = NULL;
> if (G_UNLIKELY (root == NULL))
> ... load menu ...
> return root;
> Free'ing works by calling g_object_unref() on the returned object - the
> last caller destroys the menu -, but at the moment all clients perform
> the "... load menu ..." part. How can I avoid this?
What do you mean by "clients"? Do you mean apps running in different
processes? If so, there isn't really any good way of doing this, aside
from using sysv shared memory, or the X servers Xshm extension, or
something like that. Not sure why you need to do this...
Otherwise, you could do something like write a 'menu daemon' which is a
DBUS service, and applications who want to access the menu can request a
tree from the daemon. Sounds like pushing way too much data over DBUS,
though. And that doesn't seem to solve any problems - it makes it so
the menu parsing only needs to be done once, but then you end up with a
bunch of copies anyway.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v22.214.171.124 (MingW32)
-----END PGP SIGNATURE-----
More information about the Xfce4-dev