>From b242dc66c3b85ed5ccdb6367bbd30f61e4a29673 Mon Sep 17 00:00:00 2001
From: Gwenael Casaccio
Date: Mon, 21 Oct 2013 12:53:34 +0200
Subject: [PATCH] Makes the debugger/text widget non-blocking and fix the
continue back into GTK/Event-Loop/C-code.
---
packages/visualgst/ChangeLog | 6 +++
packages/visualgst/Debugger/GtkDebugger.st | 21 ++++----
packages/visualgst/Misc/TaskQueue.st | 80 ++++++++++++++++++++++++++++++
packages/visualgst/Text/GtkTextWidget.st | 39 +++++++++------
packages/visualgst/package.xml | 4 +-
5 files changed, 124 insertions(+), 26 deletions(-)
create mode 100644 packages/visualgst/Misc/TaskQueue.st
diff --git a/packages/visualgst/ChangeLog b/packages/visualgst/ChangeLog
index 124e0ce..8f34236 100644
--- a/packages/visualgst/ChangeLog
+++ b/packages/visualgst/ChangeLog
@@ -1,5 +1,11 @@
2013-10-21 Gwenael Casaccio
+ * Debugger/GtkDebugger.st: Makes the debugger non-blocking and fix the continue back into GTK/Event-Loop/C-code.
+ * Debugger/GtkTextWidget.st: Makes the debugger non-blocking and fix the continue back into GTK/Event-Loop/C-code.
+ * Misc/TaskQueue.st : Add a queue of tasks.
+
+2013-10-21 Gwenael Casaccio
+
* Debugger/GtkDebugger.st: If stepping while the last context is not selected it finishes the execution
up to the selected context and does the stepping command.
diff --git a/packages/visualgst/Debugger/GtkDebugger.st b/packages/visualgst/Debugger/GtkDebugger.st
index 6420e8d..e93ff5d 100644
--- a/packages/visualgst/Debugger/GtkDebugger.st
+++ b/packages/visualgst/Debugger/GtkDebugger.st
@@ -285,25 +285,28 @@ GtkBrowsingTool subclass: GtkDebugger [
stepInto [
- self isLastContextSelected ifFalse: [ self stepToSelectedContext ].
- debugger step.
- self updateContextWidget
+ TaskQueue uniqueInstance add: [
+ self isLastContextSelected ifFalse: [ self stepToSelectedContext ].
+ debugger step.
+ self updateContextWidget ]
]
stepOver [
- self isLastContextSelected ifFalse: [ self stepToSelectedContext ].
- debugger next.
- self updateContextWidget
+ TaskQueue uniqueInstance add: [
+ self isLastContextSelected ifFalse: [ self stepToSelectedContext ].
+ debugger next.
+ self updateContextWidget ]
]
stepOut [
- self isLastContextSelected ifFalse: [ self stepToSelectedContext ].
- debugger finish.
- self updateContextWidget
+ TaskQueue uniqueInstance add: [
+ self isLastContextSelected ifFalse: [ self stepToSelectedContext ].
+ debugger finish.
+ self updateContextWidget ]
]
continue [
diff --git a/packages/visualgst/Misc/TaskQueue.st b/packages/visualgst/Misc/TaskQueue.st
new file mode 100644
index 0000000..2b18096
--- /dev/null
+++ b/packages/visualgst/Misc/TaskQueue.st
@@ -0,0 +1,80 @@
+"======================================================================
+|
+| TaskQueue class definition
+|
+======================================================================"
+
+"======================================================================
+|
+| Copyright (c) 2013
+| Gwenael Casaccio ,
+|
+|
+| This file is part of VisualGST.
+|
+| Permission is hereby granted, free of charge, to any person obtaining
+| a copy of this software and associated documentation files (the
+| 'Software'), to deal in the Software without restriction, including
+| without limitation the rights to use, copy, modify, merge, publish,
+| distribute, sublicense, and/or sell copies of the Software, and to
+| permit persons to whom the Software is furnished to do so, subject to
+| the following conditions:
+|
+| The above copyright notice and this permission notice shall be
+| included in all copies or substantial portions of the Software.
+|
+| THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+| EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+| CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+| TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+|
+======================================================================"
+
+Object subclass: TaskQueue [
+
+ TaskQueue class [ | uniqueInstance | ]
+
+ | queue |
+
+ TaskQueue class >> new [
+
+
+ ^ super new
+ initialize;
+ yourself
+ ]
+
+ TaskQueue class >> uniqueInstance [
+
+
+ ^ uniqueInstance ifNil: [ uniqueInstance := self new ]
+ ]
+
+ initialize [
+
+
+ queue := SharedQueue new
+ ]
+
+ add: aBlock [
+
+
+ queue nextPut: aBlock
+ ]
+
+ run [
+
+
+ [ | task sem |
+ sem := Semaphore new.
+ [ queue peek.
+ [ queue isEmpty ] whileFalse: [
+ task := queue next.
+ [ task ensure: [ sem signal ] ] fork"At: Processor userBackgroundPriority".
+ sem wait ] ] repeat ] fork
+ ]
+]
+
diff --git a/packages/visualgst/Text/GtkTextWidget.st b/packages/visualgst/Text/GtkTextWidget.st
index 0036562..0008237 100644
--- a/packages/visualgst/Text/GtkTextWidget.st
+++ b/packages/visualgst/Text/GtkTextWidget.st
@@ -381,17 +381,23 @@ GtkConcreteWidget subclass: GtkTextWidget [
]
- doIt: object [
+ doWithoutForkIt: object [
- | result |
+ | result |
self beforeEvaluation.
result := Behavior
- evaluate: self buffer selectedText
- to: object
- ifError: [ :fname :lineNo :errorString | self error: errorString ].
- self afterEvaluation.
- ^ result
+ evaluate: self buffer selectedText
+ to: object
+ ifError: [ :fname :lineNo :errorString | self error: errorString ].
+ self afterEvaluation.
+ ^ result
+ ]
+
+ doIt: object [
+
+
+ TaskQueue uniqueInstance add: [ self doWithoutForkIt: object ]
]
debugIt: object [
@@ -409,19 +415,20 @@ GtkConcreteWidget subclass: GtkTextWidget [
inspectIt: object [
- GtkInspector openOn: (self doIt: object)
+ TaskQueue uniqueInstance add: [ GtkInspector openOn: (self doWithoutForkIt: object) ]
]
printIt: object [
- | iter start end result |
- iter := self buffer iterOfSelectedText second.
- result := ' ', ((self doIt: object) displayString), ' '.
- self buffer insertInteractive: iter text: result len: result size defaultEditable: true.
- start := self buffer getIterAtOffset: (iter getOffset - result size).
- end := self buffer getIterAtOffset: (iter getOffset).
- self buffer selectRange: start bound: end
+ TaskQueue uniqueInstance add:
+ [ | iter start end result |
+ iter := self buffer iterOfSelectedText second.
+ result := ' ', ((self doWithoutForkIt: object) displayString), ' '.
+ self buffer insertInteractive: iter text: result len: result size defaultEditable: true.
+ start := self buffer getIterAtOffset: (iter getOffset - result size).
+ end := self buffer getIterAtOffset: (iter getOffset).
+ self buffer selectRange: start bound: end ]
]
-
]
+
diff --git a/packages/visualgst/package.xml b/packages/visualgst/package.xml
index d21c5e3..52e7a31 100644
--- a/packages/visualgst/package.xml
+++ b/packages/visualgst/package.xml
@@ -71,6 +71,7 @@
Gtk/GtkEntry.st
Gtk/GtkEntryBuffer.st
Extensions.st
+ Misc/TaskQueue.st
Notification/AbstractEvent.st
Notification/AddedEvent.st
Notification/CommentedEvent.st
@@ -556,5 +557,6 @@
Icons/override.png
Icons/visualgst.png
VisualGST.GtkLauncher open.
- GTK.Gtk main
+ VisualGST.TaskQueue uniqueInstance run.
+ GTK.Gtk main.
--
1.8.3.2