Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DoIt in background and a toolbar button to cancel the current exe… #672

Merged
merged 2 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ StPlaygroundPageTestMockedWaitable >> initialize [
StPlaygroundPageTestMockedWaitable >> resume [

sem signal.
^ sem2 wait: (Duration milliSeconds: timeout)
^ sem2 waitTimeoutMilliseconds: timeout
]

{ #category : 'accessing' }
Expand All @@ -41,7 +41,7 @@ StPlaygroundPageTestMockedWaitable >> timeout: aNumberMiliseconds [
StPlaygroundPageTestMockedWaitable >> wait [

| semRes |
semRes := sem wait: (Duration milliSeconds: timeout).
semRes := sem waitTimeoutMilliseconds: timeout.
sem2 signal.
^ semRes
]
49 changes: 49 additions & 0 deletions src/NewTools-Playground/StPlaygroundCancelItCommand.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"
I'm a """"cancel of do it and inspect"""" command.
I will cancel current playground execution when possible...
"
Class {
#name : 'StPlaygroundCancelItCommand',
#superclass : 'StPlaygroundCommand',
#category : 'NewTools-Playground-Command',
#package : 'NewTools-Playground',
#tag : 'Command'
}

{ #category : 'default' }
StPlaygroundCancelItCommand class >> defaultDescription [

^ 'Cancel current do it'
]

{ #category : 'accessing' }
StPlaygroundCancelItCommand class >> defaultIconName [

^ #glamorousCancel
]

{ #category : 'default' }
StPlaygroundCancelItCommand class >> defaultName [

^ 'Cancel it'
]

{ #category : 'accessing' }
StPlaygroundCancelItCommand class >> order [

^ 1
]

{ #category : 'executing' }
StPlaygroundCancelItCommand >> execute [

| tmp |
(context application propertyAt: #executionThread ifAbsent:[ nil ])
ifNil: [ self inform: 'No pending "Do it" !' ]
ifNotNil: [ :e |
e terminate.
self inform: 'Previous Do-It Cancelled !'.
context application propertyAt: #executionThread put: nil ].

self context withWindowDo: [ :w | tmp := w title: 'Playground - stopped' ].
]
19 changes: 17 additions & 2 deletions src/NewTools-Playground/StPlaygroundDoItCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,23 @@ StPlaygroundDoItCommand class >> order [
^ 0
]

{ #category : 'execution' }
{ #category : 'executing' }
StPlaygroundDoItCommand >> execute [

context doEvaluateAllAndGo
| thrd |
thrd := context application
propertyAt: #executionThread
ifAbsent: [ nil ].
thrd ifNotNil: [ :e |
self inform: 'Terminating previous Do-It !'.
e terminate ].
thrd := [
self context withWindowDo: [ :w |
w title: 'Playground - running' ].
context doEvaluateAllAndGo.
context application propertyAt: #executionThread put: nil.
self context withWindowDo: [ :w |
w title: 'Playground - finished' ] ] forkAt:
Processor userBackgroundPriority.
context application propertyAt: #executionThread put: thrd
]
1 change: 1 addition & 0 deletions src/NewTools-Playground/StPlaygroundPagePresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ StPlaygroundPagePresenter class >> baseToolbarCommands [

^ {
StPlaygroundDoItCommand.
StPlaygroundCancelItCommand .
StPlaygroundPublishCommand.
StPlaygroundBindingsCommand.
StPlaygroundVersionsCommand.
Expand Down
Loading