[Monodevelop-patches-list] r2083 - in trunk/MonoDevelop/Core/src/Main/Base: . Services/DispatchService Services/ParserService
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Wed Dec 15 20:08:09 EST 2004
Author: lluis
Date: 2004-12-15 20:08:09 -0500 (Wed, 15 Dec 2004)
New Revision: 2083
Modified:
trunk/MonoDevelop/Core/src/Main/Base/ChangeLog
trunk/MonoDevelop/Core/src/Main/Base/Services/DispatchService/DispatchService.cs
trunk/MonoDevelop/Core/src/Main/Base/Services/ParserService/DefaultParserService.cs
Log:
2004-12-16 Lluis Sanchez Gual <lluis at novell.com>
* Services/DispatchService/DispatchService.cs: added a locks for accessing
the message queue. In synchronous calls, don't use gui dispatch if the
calling thread is already the gui thread.
* Services/ParserService/DefaultParserService.cs: Removed unneeded lock
that was causing deadlocks.
Modified: trunk/MonoDevelop/Core/src/Main/Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/Main/Base/ChangeLog 2004-12-16 00:01:45 UTC (rev 2082)
+++ trunk/MonoDevelop/Core/src/Main/Base/ChangeLog 2004-12-16 01:08:09 UTC (rev 2083)
@@ -1,3 +1,11 @@
+2004-12-16 Lluis Sanchez Gual <lluis at novell.com>
+
+ * Services/DispatchService/DispatchService.cs: added a locks for accessing
+ the message queue. In synchronous calls, don't use gui dispatch if the
+ calling thread is already the gui thread.
+ * Services/ParserService/DefaultParserService.cs: Removed unneeded lock
+ that was causing deadlocks.
+
2004-12-15 Sander Rijken <sr+ximianbugs at d-90.nl>
* Commands/CustomStringTagProvider.cs: Patch to have COMBINEDIR return
Modified: trunk/MonoDevelop/Core/src/Main/Base/Services/DispatchService/DispatchService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/Main/Base/Services/DispatchService/DispatchService.cs 2004-12-16 00:01:45 UTC (rev 2082)
+++ trunk/MonoDevelop/Core/src/Main/Base/Services/DispatchService/DispatchService.cs 2004-12-16 01:08:09 UTC (rev 2083)
@@ -38,22 +38,24 @@
public void GuiDispatch (MessageHandler cb)
{
- arrGuiQueue.Add (new GenericMessageContainer (cb, false));
- UpdateIdle ();
+ QueueMessage (new GenericMessageContainer (cb, false));
}
public void GuiDispatch (StatefulMessageHandler cb, object state)
{
- arrGuiQueue.Add (new StatefulMessageContainer (cb, state, false));
- UpdateIdle ();
+ QueueMessage (new StatefulMessageContainer (cb, state, false));
}
public void GuiSyncDispatch (MessageHandler cb)
{
+ if (IsGuiThread) {
+ cb ();
+ return;
+ }
+
GenericMessageContainer mc = new GenericMessageContainer (cb, true);
lock (mc) {
- arrGuiQueue.Add (mc);
- UpdateIdle ();
+ QueueMessage (mc);
Monitor.Wait (mc);
}
if (mc.Exception != null)
@@ -62,28 +64,35 @@
public void GuiSyncDispatch (StatefulMessageHandler cb, object state)
{
+ if (IsGuiThread) {
+ cb (state);
+ return;
+ }
+
StatefulMessageContainer mc = new StatefulMessageContainer (cb, state, true);
lock (mc) {
- arrGuiQueue.Add (mc);
- UpdateIdle ();
+ QueueMessage (mc);
Monitor.Wait (mc);
}
if (mc.Exception != null)
throw new Exception (errormsg, mc.Exception);
}
- void UpdateIdle ()
+ void QueueMessage (object msg)
{
- if (iIdle == 0) {
- iIdle = GLib.Idle.Add (handler);
- /* This code is required because for some
- * reason the idle handler is run once
- * before being set, so you get a idle
- * handler that isnt running, but our code
- * thinks that it is.
- */
- if (arrGuiQueue.Count == 0 && iIdle != 0)
- iIdle = 0;
+ lock (arrGuiQueue) {
+ arrGuiQueue.Add (msg);
+ if (iIdle == 0) {
+ iIdle = GLib.Idle.Add (handler);
+ /* This code is required because for some
+ * reason the idle handler is run once
+ * before being set, so you get a idle
+ * handler that isnt running, but our code
+ * thinks that it is.
+ */
+ if (arrGuiQueue.Count == 0 && iIdle != 0)
+ iIdle = 0;
+ }
}
}
@@ -116,12 +125,13 @@
private bool guiDispatcher ()
{
- if (arrGuiQueue.Count == 0) {
- iIdle = 0;
- return false;
- }
- GenericMessageContainer msg = null;
+ GenericMessageContainer msg;
+
lock (arrGuiQueue) {
+ if (arrGuiQueue.Count == 0) {
+ iIdle = 0;
+ return false;
+ }
msg = (GenericMessageContainer)arrGuiQueue[0];
arrGuiQueue.RemoveAt (0);
}
@@ -132,11 +142,13 @@
else if (msg.Exception != null)
HandlerError (msg);
}
-
- if (arrGuiQueue.Count == 0) {
- iIdle = 0;
- return false;
+ lock (arrGuiQueue) {
+ if (arrGuiQueue.Count == 0) {
+ iIdle = 0;
+ return false;
+ }
}
+
return true;
}
Modified: trunk/MonoDevelop/Core/src/Main/Base/Services/ParserService/DefaultParserService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/Main/Base/Services/ParserService/DefaultParserService.cs 2004-12-16 00:01:45 UTC (rev 2082)
+++ trunk/MonoDevelop/Core/src/Main/Base/Services/ParserService/DefaultParserService.cs 2004-12-16 01:08:09 UTC (rev 2083)
@@ -653,25 +653,23 @@
IParseInformation parseInformation = null;
bool updated = false;
- lock (parsings) {
-
- if (lastUpdateSize[fileName] == null || (int)lastUpdateSize[fileName] != text.GetHashCode()) {
- parseInformation = DoParseFile(fileName, text);
- if (parseInformation == null) return;
-
- if (viewContent.Project != null) {
- ProjectCodeCompletionDatabase db = GetProjectDatabase (viewContent.Project);
- ClassUpdateInformation res = db.UpdateFromParseInfo (parseInformation, fileName);
- if (res != null) NotifyParseInfoChange (fileName, res);
- }
- else {
- SimpleCodeCompletionDatabase db = GetSingleFileDatabase (fileName);
- db.UpdateFromParseInfo (parseInformation);
- }
-
- lastUpdateSize[fileName] = text.GetHashCode();
- updated = true;
+
+ if (lastUpdateSize[fileName] == null || (int)lastUpdateSize[fileName] != text.GetHashCode()) {
+ parseInformation = DoParseFile(fileName, text);
+ if (parseInformation == null) return;
+
+ if (viewContent.Project != null) {
+ ProjectCodeCompletionDatabase db = GetProjectDatabase (viewContent.Project);
+ ClassUpdateInformation res = db.UpdateFromParseInfo (parseInformation, fileName);
+ if (res != null) NotifyParseInfoChange (fileName, res);
}
+ else {
+ SimpleCodeCompletionDatabase db = GetSingleFileDatabase (fileName);
+ db.UpdateFromParseInfo (parseInformation);
+ }
+
+ lastUpdateSize[fileName] = text.GetHashCode();
+ updated = true;
}
if (updated && parseInformation != null && editable is IParseInformationListener) {
((IParseInformationListener)editable).ParseInformationUpdated(parseInformation);
More information about the Monodevelop-patches-list
mailing list