[cp-patches] RFC: GConf updates

Mario Torre neugens at limasoftware.net
Wed Nov 21 13:02:25 UTC 2007


Hello!

On my system (Fedora 8), I've noticed that the GConf backend does not
perform correctly. The problem is that the keys are updated with little
to no caching, while retrieving a key is always cached. In my tests I
had to restart the application (this means get a new GConf client) to
get correct results. Other projects don't cache the GConf client, so
this maybe totally related to the way we handle the clients. It would be
nice to test the old code with older GConf libraries to check if things
have changed or it's just me that never noticed the problem before
(though I did few tests about that).

This patch replaces the use of the client with a GConfEngine. The engine
is cached so there is not much overhead, but this ensure that operation
are performed in almost real time, minimizing data loss. Also, if I've
not understood it wrong, the engine does not require the gdk calls and
g_type_init calls that the client requires. To protect the engine I have
synchronized the method calls.

I remember that we had some threading issues with GConf, that's why we
introduced the gdk_thread* calls. I've tested few applications and all
behave correctly here, I would like some more tests before submitting
the code, though, so if you have a spare minute, help is welcome here.

The backed as is now seems ok for IcedTea also.

Final note on the patch, I've updated AbstractPreferences to perform
event handling using an Executor, instead of the old EventDispatcher. I
needed a similar class for GStreamer, so instead of moving the
dispatcher in a top level package, I followed Mark's suggestion to use
the concurrent API. I've updated the mauve tests to register few more
listeners and the events are dispatched correctly. The threads are
created via a custom ThreadFactory class located in a new package
(gnu/classpath/toolkit/DefaultDaemonThreadFactory). I hope that we can
use this approach for other similar cases instead or rewriting custom
dispatcher classes. As soon as I have some time I'll do an auditing to
see other places where we have duplicated or unused classes.

Thanks,
Mario

2007-11-19  Mario Torre  <neugens at limasoftware.net>

    * gnu/java/util/prefs/EventDispatcher.java: class removed.
    * gnu/classpath/toolkit/DefaultDaemonThreadFactory.java: new file.
    * java/util/prefs/AbstractPreferences.java:
(fire(PreferenceChangeEvent)):
    Use DefaultDaemonThreadFactory and Executors.newSingleThreadExecutor
    instead of EventDispatcher. Import statement refactored accordingly.
    Also refactored to use 1.5 enhanced for loop and generics.
    (fire(NodeChangeEvent, boolean)): likewise.
	* gnu/java/util/prefs/GConfBasedPreferences.java (childSpi):
	removed startWatchingNode call.
	* gnu/java/util/prefs/gconf/GConfNativePeer.java:
	(GConfNativePeer): removed use of semaphore. 
	(gconf_all_nodes): method name shortened, renamed from
	gconf_client_all_nodes (removed client_ from method signature) and
	declared synchronized. 
	(gconf_suggest_sync): likewise.
	(gconf_get_string): likewise.
	(gconf_unescape_key): likewise.
	(gconf_set_string): likewise.
	(gconf_escape_key):  likewise.
	(gconf_all_keys): likewise.
	(gconf_dir_exists): likewise.
	(getKeys): refactored to use new native method name.
	(getKey): likewise.
    (setString): likewise.
	(getChildrenNodes): likewise.
	(unset): likewise.
	(suggestSync): likewise.
	(finalize): likewise.
	(nodeExist): likewise.
    (gconf_client_add_dir): removed, not needed anymore.
    (gconf_client_remove_dir): likewise.
    (startWatchingNode): likewise.
    (stopWatchingNode): likewise.
    * native/jni/conf-peer/GConfNativePeer.c:
    All native methods renamed to match changes in GConfNativePeer.java
    Now use GConfEngine instead of GConfClient.
    Removed gdk_thread_enter/leave locking from all methods.

(Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1add_1dir):
    removed.

(Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1dir_1exists):
    likewise.
    * include/gnu_java_util_prefs_gconf_GConfNativePeer.h: regenerated.

-- 
Lima Software - http://www.limasoftware.net/
GNU Classpath Developer - http://www.classpath.org/
Fedora Ambassador - http://fedoraproject.org/wiki/MarioTorre
Jabber: neugens at jabber.org
pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF
Fingerprint: BA39 9666 94EC 8B73 27FA  FC7C 4086 63E3 80F2 40CF

Please, support open standards:
http://opendocumentfellowship.org/petition/
http://www.nosoftwarepatents.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2007-11-21-gconf.patch
Type: text/x-patch
Size: 30955 bytes
Desc: not available
Url : http://developer.classpath.org/pipermail/classpath-patches/attachments/20071121/03f4cc4b/2007-11-21-gconf-0001.bin


More information about the Classpath-patches mailing list