[tracker/direct-access: 71/85] libtracker-sparql: Only create single PluginLoader
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/direct-access: 71/85] libtracker-sparql: Only create single PluginLoader
- Date: Tue, 20 Jul 2010 14:10:35 +0000 (UTC)
commit d640b47f8865e35ba628f39f33d78157aafeebc5
Author: Jürg Billeter <j bitron ch>
Date: Mon Jul 19 13:38:32 2010 +0200
libtracker-sparql: Only create single PluginLoader
src/libtracker-sparql/tracker-connection.vala | 24 ++++++++++++++++++++++--
1 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-sparql/tracker-connection.vala b/src/libtracker-sparql/tracker-connection.vala
index 7bdd902..606b30b 100644
--- a/src/libtracker-sparql/tracker-connection.vala
+++ b/src/libtracker-sparql/tracker-connection.vala
@@ -18,12 +18,32 @@
*/
public abstract class Tracker.Sparql.Connection : Object {
+ static bool direct_only;
+ static weak Connection? singleton;
+
public static Connection get () throws GLib.Error {
- return new PluginLoader ();
+ if (singleton != null) {
+ assert (!direct_only);
+ return singleton;
+ } else {
+ var result = new PluginLoader ();
+ singleton = result;
+ result.add_weak_pointer ((void**) (&singleton));
+ return result;
+ }
}
public static Connection get_direct () throws GLib.Error {
- return new PluginLoader (true /* direct_only */);
+ if (singleton != null) {
+ assert (direct_only);
+ return singleton;
+ } else {
+ var result = new PluginLoader (true /* direct_only */);
+ direct_only = true;
+ singleton = result;
+ result.add_weak_pointer ((void**) (&singleton));
+ return result;
+ }
}
// Query
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]