Author: lluis Date: 2008-01-18 09:04:36 -0500 (Fri, 18 Jan 2008) New Revision: 93252
Modified: trunk/monodevelop/main/src/core/MonoDevelop.Ide/ChangeLog trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/DefaultMonitorPad.cs trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/OutputProgressMonitor.cs Log: * MonoDevelop.Ide.Gui.Pads/DefaultMonitorPad.cs: Queue.Peek returns the head of the queue, not the tail. Use a field to store the last text write request. Made buffer bigger and reduced timeout for updating the textview. * MonoDevelop.Ide.Gui/OutputProgressMonitor.cs: Make it subclass NullProgessMonitor since this class is now gui thread safe. Modified: trunk/monodevelop/main/src/core/MonoDevelop.Ide/ChangeLog =================================================================== --- trunk/monodevelop/main/src/core/MonoDevelop.Ide/ChangeLog 2008-01-18 13:58:32 UTC (rev 93251) +++ trunk/monodevelop/main/src/core/MonoDevelop.Ide/ChangeLog 2008-01-18 14:04:36 UTC (rev 93252) @@ -1,3 +1,12 @@ +2008-01-18 Lluis Sanchez Gual <[EMAIL PROTECTED]> + + * MonoDevelop.Ide.Gui.Pads/DefaultMonitorPad.cs: Queue.Peek returns the head + of the queue, not the tail. Use a field to store the last text write + request. Made buffer bigger and reduced timeout for updating the + textview. + * MonoDevelop.Ide.Gui/OutputProgressMonitor.cs: Make it subclass + NullProgessMonitor since this class is now gui thread safe. + 2008-01-17 Lluis Sanchez Gual <[EMAIL PROTECTED]> * MonoDevelop.Ide.Gui/OutputProgressMonitor.cs: Avoid going through the gui Modified: trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/OutputProgressMonitor.cs =================================================================== --- trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/OutputProgressMonitor.cs 2008-01-18 13:58:32 UTC (rev 93251) +++ trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/OutputProgressMonitor.cs 2008-01-18 14:04:36 UTC (rev 93252) @@ -45,7 +45,7 @@ namespace MonoDevelop.Ide.Gui { - internal class OutputProgressMonitor : BaseProgressMonitor, IConsole + internal class OutputProgressMonitor : NullProgressMonitor, IConsole { DefaultMonitorPad outputPad; event EventHandler stopRequested; @@ -57,17 +57,9 @@ pad.AsyncOperation = this.AsyncOperation; outputPad = pad; outputPad.BeginProgress (title); - - //using the DefaultMonitorPad's method here to make sure we don't mess with the remoted dispatch - //mechanisms *at all* (even just accessing a field from an anon delegate invokes remoting) - //We're hooking up our own logger to avoid cost of context switching via remoting through the - //AsyncDispatch of base class's WriteLogInternal - //HORRIBLE HACK:To get it properly deteched, we have to replace the actual logger. logger.TextWritten += outputPad.WriteText; - ((LogTextWriter) base.Log).TextWritten += outputPad.WriteText; } - [FreeDispatch] public override void BeginTask (string name, int totalWork) { if (outputPad == null) throw GetDisposedException (); @@ -75,7 +67,6 @@ base.BeginTask (name, totalWork); } - [FreeDispatch] public override void EndTask () { if (outputPad == null) throw GetDisposedException (); @@ -88,14 +79,14 @@ if (outputPad == null) throw GetDisposedException (); outputPad.WriteText ("\n"); - foreach (string msg in SuccessMessages) + foreach (string msg in Messages) outputPad.WriteText (msg + "\n"); foreach (string msg in Warnings) outputPad.WriteText (msg + "\n"); - foreach (string msg in Errors) - outputPad.WriteError (msg + "\n"); + foreach (ProgressError msg in Errors) + outputPad.WriteError (msg.Message + "\n"); outputPad.EndProgress (); base.OnCompleted (); @@ -115,30 +106,28 @@ stopRequested (this, null); } + public override TextWriter Log { + get { return logger; } + } + TextReader IConsole.In { - [FreeDispatch] get { return new StringReader (""); } } TextWriter IConsole.Out { - [FreeDispatch] get { return logger; } } TextWriter IConsole.Error { - [FreeDispatch] get { return logger; } } bool IConsole.CloseOnDispose { - [FreeDispatch] get { return false; } } event EventHandler IConsole.CancelRequested { - [FreeDispatch] add { stopRequested += value; } - [FreeDispatch] remove { stopRequested -= value; } } } Modified: trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/DefaultMonitorPad.cs =================================================================== --- trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/DefaultMonitorPad.cs 2008-01-18 13:58:32 UTC (rev 93251) +++ trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/DefaultMonitorPad.cs 2008-01-18 14:04:36 UTC (rev 93252) @@ -71,10 +71,11 @@ private IAsyncOperation asyncOperation; Queue updates = new Queue (); + QueuedTextWrite lastTextWrite; GLib.TimeoutHandler outputDispatcher; bool outputDispatcherRunning = false; - const int MAX_BUFFER_LENGTH = 20 * 1024; + const int MAX_BUFFER_LENGTH = 200 * 1024; public DefaultMonitorPad (string typeTag, string icon, int instanceNum) { @@ -143,6 +144,7 @@ bool outputDispatchHandler () { lock (updates.SyncRoot) { + lastTextWrite = null; if (updates.Count == 0) { outputDispatcherRunning = false; return false; @@ -214,18 +216,26 @@ lock (updates.SyncRoot) { updates.Enqueue (update); if (!outputDispatcherRunning) { - GLib.Timeout.Add (500, outputDispatcher); + GLib.Timeout.Add (50, outputDispatcher); outputDispatcherRunning = true; } + lastTextWrite = update as QueuedTextWrite; } } public void BeginProgress (string title) { - originalTitle = window.Title; - buffer.Clear (); - window.Title = "<span foreground=\"blue\">" + originalTitle + "</span>"; - buttonStop.Sensitive = true; + lock (updates.SyncRoot) { + updates.Clear (); + lastTextWrite = null; + } + + Gtk.Application.Invoke (delegate { + originalTitle = window.Title; + buffer.Clear (); + window.Title = "<span foreground=\"blue\">" + originalTitle + "</span>"; + buttonStop.Sensitive = true; + }); } protected void UnsafeBeginTask (string name, int totalWork) @@ -263,10 +273,9 @@ { //raw text has an extra optimisation here, as we can append it to existing updates lock (updates.SyncRoot) { - if (updates.Count > 0) { - QueuedTextWrite w = updates.Peek () as QueuedTextWrite; - if (w != null && w.Tag == null) { - w.Write (text); + if (lastTextWrite != null) { + if (lastTextWrite.Tag == null) { + lastTextWrite.Write (text); return; } } @@ -314,8 +323,10 @@ public void EndProgress () { - window.Title = originalTitle; - buttonStop.Sensitive = false; + Gtk.Application.Invoke (delegate { + window.Title = originalTitle; + buttonStop.Sensitive = false; + }); } protected void UnsafeAddText (string text, TextTag extraTag) @@ -369,6 +380,10 @@ public virtual void Dispose () { + lock (updates.SyncRoot) { + updates.Clear (); + lastTextWrite = null; + } } public void RedrawContent() _______________________________________________ Mono-patches maillist - Mono-patches@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-patches