[Monodevelop-patches-list] r2498 - in trunk/MonoDevelop/Extras/BooBinding: . BooShell Gui
Peter Johanson <latexer@gentoo.org>
pjohanson at mono-cvs.ximian.com
Mon May 2 10:30:20 EDT 2005
Author: pjohanson
Date: 2005-05-02 10:30:20 -0400 (Mon, 02 May 2005)
New Revision: 2498
Modified:
trunk/MonoDevelop/Extras/BooBinding/BooShell/BooShell.boo
trunk/MonoDevelop/Extras/BooBinding/ChangeLog
trunk/MonoDevelop/Extras/BooBinding/Gui/BooShellModel.boo
Log:
Fixes to locking mechanism, and a small GUI fix for multi-line entries pasted to the shell.
Modified: trunk/MonoDevelop/Extras/BooBinding/BooShell/BooShell.boo
===================================================================
--- trunk/MonoDevelop/Extras/BooBinding/BooShell/BooShell.boo 2005-04-30 14:23:31 UTC (rev 2497)
+++ trunk/MonoDevelop/Extras/BooBinding/BooShell/BooShell.boo 2005-05-02 14:30:20 UTC (rev 2498)
@@ -22,6 +22,7 @@
import System
import System.Collections
import System.IO
+import System.Threading
import Boo.Lang.Interpreter
import Boo.Lang.Compiler
@@ -47,22 +48,20 @@
return true
def GetOutput() as (string):
- _tmp as string
- lock _processing:
- _tmp = _processing
+ ret as (string)
+ try:
+ Monitor.Enter (_outputQueue)
- while _tmp == "true":
- lock _processing:
- _tmp = _processing
- // Sleep to let other thread process (and grab lock)
- System.Threading.Thread.Sleep (10)
+ if _processing == "true":
+ Monitor.Wait (_outputQueue)
- ret as (string)
- lock _outputQueue:
if _outputQueue.Count > 0:
ret = array (string, _outputQueue.Count)
_outputQueue.CopyTo (ret, 0)
_outputQueue.Clear()
+ ensure:
+ Monitor.Pulse (_outputQueue)
+ Monitor.Exit (_outputQueue)
return ret
@@ -76,40 +75,65 @@
def ProcessCommands() as bool:
com as ShellCommand
- lock _commandQueue:
- if _commandQueue.Count > 0:
- com = _commandQueue.Dequeue()
- if com.Type == ShellCommandType.Eval:
- if com.Data is not null:
- lock _outputQueue:
- _interpreter.LoopEval(com.Data)
- elif com.Type == ShellCommandType.Reset:
- _interpreter.Reset()
- elif com.Type == ShellCommandType.Load:
- if com.Data is not null:
- _interpreter.load(com.Data)
+ try:
+ Monitor.Enter (_commandQueue)
+ if _commandQueue.Count == 0:
+ Monitor.Exit (_commandQueue)
+ System.Threading.Thread.Sleep (100)
+ return true
- com.Type = ShellCommandType.NoOp
+ com = _commandQueue.Dequeue()
- lock _commandQueue:
+ if com.Type == ShellCommandType.Eval:
+ if com.Data is not null:
+ _interpreter.LoopEval(com.Data)
+ elif com.Type == ShellCommandType.Reset:
+ _interpreter.Reset()
+ elif com.Type == ShellCommandType.Load:
+ if com.Data is not null:
+ _interpreter.load(com.Data)
+
+ com.Type = ShellCommandType.NoOp
+
if _commandQueue.Count == 0:
- lock _processing:
- _processing = "false"
+ Monitor.Enter (_outputQueue)
+ _processing = "false"
+ Monitor.Pulse (_outputQueue)
+ Monitor.Exit (_outputQueue)
+ ensure:
+ Monitor.Exit (_commandQueue)
return true
def Run():
+ kickOffGuiThread()
+
+
+ private def kickOffGuiThread():
_thread = System.Threading.Thread(ThreadRun)
_thread.Start()
def print(obj):
+ Monitor.Enter (_outputQueue)
_outputQueue.Enqueue(obj)
+ Monitor.Exit (_outputQueue)
def EnqueueCommand (command as ShellCommand):
- lock _commandQueue:
+ if not _thread.IsAlive:
+ kickOffGuiThread()
+
+ try:
+ Monitor.Enter (_commandQueue)
+
_commandQueue.Enqueue (command)
- lock _processing:
- _processing = "true"
+
+ Monitor.Enter (_outputQueue)
+ _processing = "true"
+ Monitor.Pulse (_outputQueue)
+ Monitor.Exit (_outputQueue)
+ ensure:
+ Monitor.Pulse (_commandQueue)
+ Monitor.Exit (_commandQueue)
public enum ShellCommandType:
Modified: trunk/MonoDevelop/Extras/BooBinding/ChangeLog
===================================================================
--- trunk/MonoDevelop/Extras/BooBinding/ChangeLog 2005-04-30 14:23:31 UTC (rev 2497)
+++ trunk/MonoDevelop/Extras/BooBinding/ChangeLog 2005-05-02 14:30:20 UTC (rev 2498)
@@ -1,6 +1,16 @@
+2005-05-02 Peter Johanson <latexer at gentoo.org>
+
+ * BooShell/BooShell.boo: Convert to using Monitor instead
+ of just lock(), prevents the 100% utilization by mono
+ as reported by several folks.
+ * Gui/BooShellModel.boo: Some Monitor fixes, and a small
+ fix to make pasted input with multiple lines get processed
+ properly.
+
2005-04-28 Rafael Monoman Teixeira <rafaelteixeirabr at hotmail.com>
- * Makefile.am: added missing dependency for target $(ASSEMBLY)
-
+
+ * Makefile.am: added missing dependency for target $(ASSEMBLY)
+
2005-04-25 Peter Johanson <latexer at gentoo.org>
* BooShellServer/BooShellServer.boo:
Modified: trunk/MonoDevelop/Extras/BooBinding/Gui/BooShellModel.boo
===================================================================
--- trunk/MonoDevelop/Extras/BooBinding/Gui/BooShellModel.boo 2005-04-30 14:23:31 UTC (rev 2497)
+++ trunk/MonoDevelop/Extras/BooBinding/Gui/BooShellModel.boo 2005-05-02 14:30:20 UTC (rev 2498)
@@ -23,6 +23,7 @@
import System.Diagnostics
import System.Collections
import System.IO
+import System.Threading
import BooBinding.Properties
import BooBinding.BooShell
@@ -92,25 +93,40 @@
def QueueInput (line as string):
- lock _commandQueue:
+ try:
+ Monitor.Enter (_commandQueue)
_commandQueue.Enqueue (line)
+ Monitor.Pulse (_commandQueue)
+ ensure:
+ Monitor.Exit (_commandQueue)
def ThreadRun():
while true:
com as string
- lock _commandQueue:
- if _commandQueue.Count > 0:
- com = _commandQueue.Dequeue()
- if com is not null:
- _booShell.QueueInput (com)
- lines = _booShell.GetOutput()
- if lines is not null:
- EnqueueOutput(lines)
- com = null
- lock _outputQueue:
- if _outputHandler is not null:
- _outputHandler()
+ try:
+ Monitor.Enter (_commandQueue)
+ if _commandQueue.Count == 0:
+ Monitor.Wait (_commandQueue)
+ com = _commandQueue.Dequeue()
+
+
+ if com is not null:
+ print "Sending out command '${com}'"
+ _booShell.QueueInput (com)
+ print "trying to get the output!"
+ lines = _booShell.GetOutput()
+ print "got the output!"
+ if lines is not null:
+ EnqueueOutput(lines)
+ com = null
+ lock _outputQueue:
+ if _outputHandler is not null:
+ _outputHandler()
+
+ ensure:
+ Monitor.Exit (_commandQueue)
+
def Run():
_thread = System.Threading.Thread(ThreadRun)
More information about the Monodevelop-patches-list
mailing list