Skip to content

Commit

Permalink
Improve the canceling of a remote execution [feenkcom/gtoolkit#3942]
Browse files Browse the repository at this point in the history
  • Loading branch information
chisandrei committed Sep 2, 2024
1 parent 27490c3 commit a888d23
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ GtGemStoneAsyncEvaluationElement >> buildStartTimeRow [
yourself)
]

{ #category : #'building widgets' }
GtGemStoneAsyncEvaluationElement >> buildToolbar [
^ BrToolbar new
aptitude: BrGlamorousToolbarAptitude new;
alignCenterLeft;
fitContent.
]

{ #category : #'building widgets' }
GtGemStoneAsyncEvaluationElement >> buildToolLabel [
^(BrLabel new)
Expand All @@ -146,14 +154,6 @@ GtGemStoneAsyncEvaluationElement >> buildToolLabel [
background: Color white
]

{ #category : #'building widgets' }
GtGemStoneAsyncEvaluationElement >> buildToolbar [
^ BrToolbar new
aptitude: BrGlamorousToolbarAptitude new;
alignCenterLeft;
fitContent.
]

{ #category : #'building widgets' }
GtGemStoneAsyncEvaluationElement >> buildUnknownValueLabel [
^ (BrLabel new)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ GtGemStoneAsyncPromiseResolution >> announcer [

{ #category : #testing }
GtGemStoneAsyncPromiseResolution >> canStopExecution [
^ self isResolvingRunning and: [
snippetPromise canStopExecution ]
"For now allow the execution to be stopped even if we do not have an evaluation context"
^ self isResolvingRunning "and: [
snippetPromise canStopExecution ]"
]

{ #category : #accessing }
Expand Down
12 changes: 6 additions & 6 deletions src/GToolkit-GemStone-Pharo/GtGemStoneDebugger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ Class {
#category : #'GToolkit-GemStone-Pharo-Debugger'
}

{ #category : #announcer }
GtGemStoneDebugger >> announcer [
<return: #Announcer>
^ announcer
]

{ #category : #private }
GtGemStoneDebugger >> announceStateChange [
"Announce that the receiver's state has changed"

self announcer announce: (GtGemStoneDebuggerStateChanged new debugger: self)
]

{ #category : #announcer }
GtGemStoneDebugger >> announcer [
<return: #Announcer>
^ announcer
]

{ #category : #accessing }
GtGemStoneDebugger >> debuggerProxy [

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ GtGemStoneExpandableDebuggerElement class >> sessionClass [
^ GtGemStoneDebuggerSession
]

{ #category : #callbacks }
GtGemStoneExpandableDebuggerElement >> actOnDebuggerStateChanged [

self debugSession synchronizeCallStack.
self currentCallFrame resetState.
self scheduleUpdateUI.
]

{ #category : #callbacks }
GtGemStoneExpandableDebuggerElement >> actOnDebugSessionChanged [

Expand All @@ -67,14 +75,6 @@ GtGemStoneExpandableDebuggerElement >> actOnDebugSessionChanged [
self scheduleUpdateUI.
]

{ #category : #callbacks }
GtGemStoneExpandableDebuggerElement >> actOnDebuggerStateChanged [

self debugSession synchronizeCallStack.
self currentCallFrame resetState.
self scheduleUpdateUI.
]

{ #category : #callbacks }
GtGemStoneExpandableDebuggerElement >> actOnSelectedContextChangedFor: aContext [
self updateVariables.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ Class {
#category : #'GToolkit-GemStone-Pharo-Notifications'
}

{ #category : #accessing }
GtGemStoneKeepAliveNotificationElement >> actOnElementDetached [
self clearNotification.
self clearContent.
]

{ #category : #'private - accessing' }
GtGemStoneKeepAliveNotificationElement >> activeMark [

Expand All @@ -28,6 +22,12 @@ GtGemStoneKeepAliveNotificationElement >> activeMark [
addChild: (BrGlamorousVectorIcons accept asElement)
]

{ #category : #accessing }
GtGemStoneKeepAliveNotificationElement >> actOnElementDetached [
self clearNotification.
self clearContent.
]

{ #category : #'private - accessing' }
GtGemStoneKeepAliveNotificationElement >> borderElement [
<return: #GtNotificationBorderElement>
Expand Down
12 changes: 6 additions & 6 deletions src/GToolkit-GemStone-Pharo/GtGemStoneSessionRegistry.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,12 @@ GtGemStoneSessionRegistry >> sessionNamed: aString ifAbsent: absentBlock [
^ sessions at: aString ifAbsent: absentBlock
]

{ #category : #private }
GtGemStoneSessionRegistry >> sessions [

^ sessions
]

{ #category : #accessing }
GtGemStoneSessionRegistry >> sessionWithConnection: aRsrConnection [
<return: #GtGemStoneSession>
Expand Down Expand Up @@ -765,12 +771,6 @@ GtGemStoneSessionRegistry >> sessionWithConnectorNamed: aString ifAbsent: absent
(sessionCollection sorted: #sessionId ascending) first ].
]

{ #category : #private }
GtGemStoneSessionRegistry >> sessions [

^ sessions
]

{ #category : #initialization }
GtGemStoneSessionRegistry >> shutdown [

Expand Down
20 changes: 10 additions & 10 deletions src/GToolkit-GemStone-Pharo/GtRsrEvaluationException.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ GtRsrEvaluationException >> currentDebuggerState [
^ debuggerState
]

{ #category : #accessing }
GtRsrEvaluationException >> debugResult [
^ debugResult
]

{ #category : #accessing }
GtRsrEvaluationException >> debugResult: anObject [
debugResult := anObject
]

{ #category : #accessing }
GtRsrEvaluationException >> debuggerClient [

Expand All @@ -53,6 +43,16 @@ GtRsrEvaluationException >> debuggerState [
debuggerState := self getDebuggerState ]
]

{ #category : #accessing }
GtRsrEvaluationException >> debugResult [
^ debugResult
]

{ #category : #accessing }
GtRsrEvaluationException >> debugResult: anObject [
debugResult := anObject
]

{ #category : #accessing }
GtRsrEvaluationException >> evaluator [

Expand Down
34 changes: 22 additions & 12 deletions src/GToolkit-GemStone-Pharo/GtRsrEvaluatorAsyncPromise.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Class {
'gtRsrEvaluatorPromise',
'value',
'executionContext',
'mutex',
'state',
'gemStoneSession',
'serializationStrategy'
'serializationStrategy',
'evaluationMutex'
],
#category : #'GToolkit-GemStone-Pharo-Promises'
}
Expand Down Expand Up @@ -105,7 +105,7 @@ GtRsrEvaluatorAsyncPromise >> initialize [
super initialize.

value := self.
mutex := Mutex new.
evaluationMutex := Mutex new.
state := #PendingResolution.
]

Expand Down Expand Up @@ -142,20 +142,20 @@ GtRsrEvaluatorAsyncPromise >> isResolved [
^self isFulfilled or: [self isBroken]
]

{ #category : #resolving }
GtRsrEvaluatorAsyncPromise >> resolveWithEvaluationResult: evaluationResult [
evaluationResult isEvaluationCancelledResult
ifTrue: [ self breakWithEvaluationResult: evaluationResult ]
ifFalse: [ self fulfillWithEvaluationResult: evaluationResult ]
]

{ #category : #accessing }
GtRsrEvaluatorAsyncPromise >> resolvedValue [
self assert: [ value ~~ self ].

^ value
]

{ #category : #resolving }
GtRsrEvaluatorAsyncPromise >> resolveWithEvaluationResult: evaluationResult [
evaluationResult isEvaluationCancelledResult
ifTrue: [ self breakWithEvaluationResult: evaluationResult ]
ifFalse: [ self fulfillWithEvaluationResult: evaluationResult ]
]

{ #category : #actions }
GtRsrEvaluatorAsyncPromise >> resumeEvaluation [
| resumedEvaluationResultData |
Expand Down Expand Up @@ -202,7 +202,17 @@ GtRsrEvaluatorAsyncPromise >> sessionDescription [

{ #category : #actions }
GtRsrEvaluatorAsyncPromise >> stopEvaluation [
self assert: [ executionContext notNil ].
| retryCount |

"If the user attempts to stop execution while we are waiting for the execution context, wait a bit ang give the remote execution a chance to start. We cannot stop the remote execution unless we have a proxy to the execution context."
retryCount := 5.
[ executionContext isNil and: [ retryCount > 0 ] ] whileTrue: [
100 milliseconds wait.
retryCount := retryCount -1.
].

executionContext ifNil: [
Error signal: 'Failed to stop the remote execution. Could not get a proxy to the evaluation context for the remote execution. Try and stop the execution again' ].

^ executionContext terminateAsyncComputation
]
Expand All @@ -211,7 +221,7 @@ GtRsrEvaluatorAsyncPromise >> stopEvaluation [
GtRsrEvaluatorAsyncPromise >> value [

value == self ifTrue: [
mutex critical: [ self wait ] ].
evaluationMutex critical: [ self wait ] ].
^ value
]

Expand Down
18 changes: 9 additions & 9 deletions src/GToolkit-GemStone-Pharo/GtRsrProxyServiceClient.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@ GtRsrProxyServiceClient class >> subclassForRemoteClass: aSymbol [

]

{ #category : #private }
GtRsrProxyServiceClient >> _id: id connection: connection remoteSelf: anObject remoteClass: aString [

_id := id.
_connection := connection.
remoteSelf := anObject.
remoteClass := aString.
]

{ #category : #converting }
GtRsrProxyServiceClient >> asGtpoLocalObject [
"Answer a local copy of the receiver"
Expand Down Expand Up @@ -698,3 +689,12 @@ GtRsrProxyServiceClient >> scriptEvaluation [
receiver: self;
gtSession: self gtSession
]

{ #category : #private }
GtRsrProxyServiceClient >> _id: id connection: connection remoteSelf: anObject remoteClass: aString [

_id := id.
_connection := connection.
remoteSelf := anObject.
remoteClass := aString.
]
14 changes: 7 additions & 7 deletions src/GToolkit-GemStone-Pharo/GtpoMetaclass3.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ GtpoMetaclass3 class >> remoteClassName [
^ #Metaclass3
]

{ #category : #accessing }
GtpoMetaclass3 >> compiledMethodAt: selector [

^ self proxyPerform: #compiledMethodAt:
withArguments: { selector }.
]

{ #category : #private }
GtpoMetaclass3 >> compileFromTab: aTab [
"Update the receiver's definition based on the current editor contents"
Expand All @@ -60,13 +67,6 @@ GtpoMetaclass3 >> compileFromTab: aTab [
GtpoMetaclass3 >> compileMethod: source category: categoryName [
]

{ #category : #accessing }
GtpoMetaclass3 >> compiledMethodAt: selector [

^ self proxyPerform: #compiledMethodAt:
withArguments: { selector }.
]

{ #category : #accessing }
GtpoMetaclass3 >> definitionString [
^ definitionString ifNil: [ definitionString := self proxyPerform: #definition ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ Trait {
#category : 'GToolkit-GemStone-Pharo-Support'
}

{ #category : #'api - activated session view model' }
TGtWithActivatedSessionViewModel >> activatedSessionViewModel [
<return: #GtGemStoneSessionViewModel>
<propertyGetter: #activatedSessionViewModel>
<generatedFrom: #'TGtRobocoderWithPropertyTraitTemplate>>#propertyGetterTemplate'>

^ activatedSessionViewModel
]

{ #category : #'api - activated session view model' }
TGtWithActivatedSessionViewModel >> activateSessionViewModel: aNewActivatedSessionViewModel [
<propertySetter: #activatedSessionViewModel>
Expand All @@ -26,15 +35,6 @@ TGtWithActivatedSessionViewModel >> activateSessionViewModel: aNewActivatedSessi
self notifyActivatedSessionViewModelChanged
]

{ #category : #'api - activated session view model' }
TGtWithActivatedSessionViewModel >> activatedSessionViewModel [
<return: #GtGemStoneSessionViewModel>
<propertyGetter: #activatedSessionViewModel>
<generatedFrom: #'TGtRobocoderWithPropertyTraitTemplate>>#propertyGetterTemplate'>

^ activatedSessionViewModel
]

{ #category : #'api - activated session view model' }
TGtWithActivatedSessionViewModel >> deactivateSessionViewModel [
<propertyUnsetter: #activatedSessionViewModel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ TGtWithSelectedSessionViewModel >> onPreviousSelectedSessionViewModelUnset: aPre
<generatedFrom: #'TGtRobocoderWithPropertyTraitTemplate>>#onPreviousPropertyUnsetHookTemplate'>
]

{ #category : #'api - selected session view model' }
TGtWithSelectedSessionViewModel >> selectedSessionViewModel [
<return: #GtGemStoneSessionViewModel>
<propertyGetter: #selectedSessionViewModel>
<generatedFrom: #'TGtRobocoderWithPropertyTraitTemplate>>#propertyGetterTemplate'>

^ selectedSessionViewModel
]

{ #category : #'api - selected session view model' }
TGtWithSelectedSessionViewModel >> selectSessionViewModel: aNewSelectedSessionViewModel [
<propertySetter: #selectedSessionViewModel>
Expand All @@ -70,12 +79,3 @@ TGtWithSelectedSessionViewModel >> selectSessionViewModel: aNewSelectedSessionVi
self onNewSelectedSessionViewModelSet: aNewSelectedSessionViewModel.
self notifySelectedSessionViewModelChanged
]

{ #category : #'api - selected session view model' }
TGtWithSelectedSessionViewModel >> selectedSessionViewModel [
<return: #GtGemStoneSessionViewModel>
<propertyGetter: #selectedSessionViewModel>
<generatedFrom: #'TGtRobocoderWithPropertyTraitTemplate>>#propertyGetterTemplate'>

^ selectedSessionViewModel
]

0 comments on commit a888d23

Please sign in to comment.