banshee r4674 - in trunk/banshee: . src/Clients/Beroe/Beroe src/Core/Banshee.Services/Banshee.Collection.Indexer src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper
- From: abock svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4674 - in trunk/banshee: . src/Clients/Beroe/Beroe src/Core/Banshee.Services/Banshee.Collection.Indexer src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper
- Date: Thu, 9 Oct 2008 01:18:02 +0000 (UTC)
Author: abock
Date: Thu Oct 9 01:18:02 2008
New Revision: 4674
URL: http://svn.gnome.org/viewvc/banshee?rev=4674&view=rev
Log:
* banshee/src/Clients/Beroe/Beroe/RemoteClient.cs: Whitespace; stupid MD
* banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/SimpleIndexerClient.cs:
More abstraction to make remote clients easier, but I'm mainly just
playing around and seeing what sticks right now
* banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexer.cs:
Add a lame temporary debug line
* banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/IndexerClient.cs:
Fix some raciness; I completely forgot that the remote Index call was
async
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Clients/Beroe/Beroe/RemoteClient.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/IndexerClient.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/SimpleIndexerClient.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexer.cs
Modified: trunk/banshee/src/Clients/Beroe/Beroe/RemoteClient.cs
==============================================================================
--- trunk/banshee/src/Clients/Beroe/Beroe/RemoteClient.cs (original)
+++ trunk/banshee/src/Clients/Beroe/Beroe/RemoteClient.cs Thu Oct 9 01:18:02 2008
@@ -35,12 +35,12 @@
{
public class RemoteClient : Banshee.Collection.Indexer.RemoteHelper.SimpleIndexerClient
{
- protected override void IndexResult(IDictionary<string, object> result)
+ protected override void IndexResult (IDictionary<string, object> result)
{
Console.WriteLine (result["URI"]);
}
- protected override void OnShutdownWhileIndexing()
+ protected override void OnShutdownWhileIndexing ()
{
}
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/IndexerClient.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/IndexerClient.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/IndexerClient.cs Thu Oct 9 01:18:02 2008
@@ -82,24 +82,33 @@
private void Index ()
{
if (HasCollectionChanged) {
- ThreadPool.QueueUserWorkItem (delegate {
- Debug ("Running indexer");
-
- try {
- UpdateIndex ();
- } catch (Exception e) {
- Console.Error.WriteLine (e);
- }
-
- Debug ("Indexer finished");
-
- if (!ApplicationAvailable || !listening) {
- DisconnectFromIndexerService ();
- }
- });
+ ICollectionIndexer indexer = CreateIndexer ();
+ indexer.IndexingFinished += delegate { _UpdateIndex (indexer); };
+ indexer.Index ();
}
}
+ private void _UpdateIndex (ICollectionIndexer indexer)
+ {
+ ThreadPool.QueueUserWorkItem (delegate {
+ Debug ("Running indexer");
+
+ try {
+ UpdateIndex (indexer);
+ } catch (Exception e) {
+ Console.Error.WriteLine (e);
+ }
+
+ Debug ("Indexer finished");
+
+ indexer.Dispose ();
+
+ if (!ApplicationAvailable || !listening) {
+ DisconnectFromIndexerService ();
+ }
+ });
+ }
+
private void ConnectToIndexerService ()
{
DisconnectFromIndexerService ();
@@ -188,7 +197,7 @@
protected abstract bool HasCollectionChanged { get; }
- protected abstract void UpdateIndex ();
+ protected abstract void UpdateIndex (ICollectionIndexer indexer);
protected abstract void ResetState ();
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/SimpleIndexerClient.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/SimpleIndexerClient.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/SimpleIndexerClient.cs Thu Oct 9 01:18:02 2008
@@ -31,63 +31,87 @@
namespace Banshee.Collection.Indexer.RemoteHelper
{
- public abstract class SimpleIndexerClient : IndexerClient
+ public abstract class SimpleIndexerClient
{
- private object shutdown_mutex = new object ();
- private bool indexer_running;
- private bool shutdown_requested;
-
- protected override void ResetState ()
+ private _SimpleIndexerClient client;
+
+ public SimpleIndexerClient ()
{
- lock (shutdown_mutex) {
- if (indexer_running) {
- shutdown_requested = true;
- }
- }
+ client = new _SimpleIndexerClient (this);
}
- protected override void UpdateIndex ()
+ public void Start ()
{
- lock (shutdown_mutex) {
- indexer_running = true;
- shutdown_requested = false;
- }
+ client.Start ();
+ }
+
+ protected abstract void IndexResult (IDictionary<string, object> result);
+
+ protected abstract void OnShutdownWhileIndexing ();
+
+ protected abstract bool HasCollectionChanged { get; }
- bool shutdown_while_indexing = false;;
- ICollectionIndexer indexer = CreateIndexer ();
- indexer.Index ();
+ private class _SimpleIndexerClient : IndexerClient
+ {
+ private object shutdown_mutex = new object ();
+ private bool indexer_running;
+ private bool shutdown_requested;
- for (int i = 0, models = indexer.GetModelCounts (); i < models; i++) {
- for (int j = 0, items = indexer.GetModelResultsCount (i); j < items; j++) {
- if (Shutdown) {
- shutdown_while_indexing = true;
- break;
+ private SimpleIndexerClient parent;
+
+ public _SimpleIndexerClient (SimpleIndexerClient parent)
+ {
+ this.parent = parent;
+ }
+
+ protected override void ResetState ()
+ {
+ lock (shutdown_mutex) {
+ if (indexer_running) {
+ shutdown_requested = true;
+ }
+ }
+ }
+
+ protected override void UpdateIndex (ICollectionIndexer indexer)
+ {
+ lock (shutdown_mutex) {
+ indexer_running = true;
+ shutdown_requested = false;
+ }
+
+ bool shutdown_while_indexing = false;
+
+ for (int i = 0, models = indexer.GetModelCounts (); i < models; i++) {
+ for (int j = 0, items = indexer.GetModelResultsCount (i); j < items; j++) {
+ if (Shutdown) {
+ shutdown_while_indexing = true;
+ break;
+ }
+
+ parent.IndexResult (indexer.GetResult (i, j));
}
- IndexResult (indexer.GetResult (i, j));
+ if (shutdown_while_indexing) {
+ break;
+ }
}
- if (shutdown_while_indexing) {
- break;
+ lock (shutdown_mutex) {
+ indexer_running = false;
+ shutdown_requested = false;
}
+
+ parent.OnShutdownWhileIndexing ();
}
- indexer.Dispose ();
-
- lock (shutdown_mutex) {
- indexer_running = false;
- shutdown_requested = false;
+ protected override bool HasCollectionChanged {
+ get { return parent.HasCollectionChanged; }
+ }
+
+ private bool Shutdown {
+ get { lock (shutdown_mutex) { return shutdown_requested || CleanupAndShutdown; } }
}
-
- OnShutdownWhileIndexing ();
- }
-
- protected abstract void OnShutdownWhileIndexing ();
-
- protected abstract void IndexResult (IDictionary<string, object> result);
-
- private bool Shutdown {
- get { lock (shutdown_mutex) { return shutdown_requested || CleanupAndShutdown; } }
}
}
}
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexer.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexer.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexer.cs Thu Oct 9 01:18:02 2008
@@ -213,6 +213,7 @@
throw new IndexOutOfRangeException ("itemIndex");
}
+ Log.DebugFormat ("GETTING ITEM {0} FROM MODEL {1}", itemIndex, modelIndex);
return model[modelIndex].GenerateExportable (export_fields);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]