Skip to content

Commit

Permalink
Split the execution context into two: one for exceptions and for norm…
Browse files Browse the repository at this point in the history
…al executions [feenkcom/gtoolkit#3942]
  • Loading branch information
chisandrei committed Aug 6, 2024
1 parent 2dff535 commit 553d866
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ Class {
#category : 'GToolkit-GemStone-GemStone'
}

{ #category : 'instance creation' }
GtGemStoneEvaluationContext class >> fromContext: aGtGemStoneEvaluationContext [
^ self new
initializeFromContext: aGtGemStoneEvaluationContext
]

{ #category : 'copying' }
GtGemStoneEvaluationContext >> asGtEvaluationExceptionContext [
^ GtGemStoneEvaluationExceptionContext fromContext: self
]

{ #category : 'private' }
GtGemStoneEvaluationContext >> assertNotSignalled [

Expand Down Expand Up @@ -117,6 +128,7 @@ GtGemStoneEvaluationContext >> evaluateBlock: aBlock from: anEvaluationServer [
priority: Processor activeProcess priority + 1;
breakpointLevel: 1;
resume.

^ self
]

Expand Down Expand Up @@ -169,14 +181,30 @@ GtGemStoneEvaluationContext >> handlerBlock: anObject [
If the user resumes the process it will then resume from where the exception was originally raised."

^ [ :ex |
result := self asGtRsrProxyObjectForConnection: evalServer _connection.
result := self asGtEvaluationExceptionContext asGtRsrProxyObjectForConnection: evalServer _connection.
exception := ex.
devMessage := anObject.
semaphore signal.
process suspend.
ex resume ]
]

{ #category : 'initialization' }
GtGemStoneEvaluationContext >> initializeFromContext: aGtGemStoneEvaluationContext [
exception := aGtGemStoneEvaluationContext exception.
process := aGtGemStoneEvaluationContext process.
serializationStrategy :=aGtGemStoneEvaluationContext serializationStrategy.
result := aGtGemStoneEvaluationContext result.
completed := aGtGemStoneEvaluationContext completed.
devMessage :=aGtGemStoneEvaluationContext devMessage.
evalServer := aGtGemStoneEvaluationContext evalServer.
block :=aGtGemStoneEvaluationContext block.
callStack := aGtGemStoneEvaluationContext callStack.

"We just signal it in the initial context. Normally should not be needed anymore"
"semaphore :=aGtGemStoneEvaluationContext semaphore."
]

{ #category : 'testing' }
GtGemStoneEvaluationContext >> isCompleted [
"Answer a boolean indicating whether the receiver's process has completed and successfully answered a result"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : 'GtGemStoneEvaluationExceptionContext',
#superclass : 'GtGemStoneEvaluationContext',
#category : 'GToolkit-GemStone-GemStone'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : 'GtGemStoneEvaluationExecutionContext',
#superclass : 'GtGemStoneEvaluationContext',
#category : 'GToolkit-GemStone-GemStone'
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ GtRsrEvaluatorServiceServer >> gsEvaluate: aString for: anObject bindings: aDict
symbolDictionary at: key put: value asGtGsArgument ].
bindings := GsCurrentSession currentSession symbolList, (Array with: symbolDictionary).

^ GtGemStoneEvaluationContext new
^ GtGemStoneEvaluationExecutionContext new
serializationStrategy: aSymbol;
evaluateAndWaitBlock:
[ | method |
Expand All @@ -68,7 +68,7 @@ GtRsrEvaluatorServiceServer >> gsStartEvaluate: aString for: anObject bindings:
symbolDictionary at: key put: value asGtGsArgument ].
bindings := GsCurrentSession currentSession symbolList, (Array with: symbolDictionary).

^ GtGemStoneEvaluationContext new
^ GtGemStoneEvaluationExecutionContext new
serializationStrategy: aSymbol;
evaluateBlock:
[ | method |
Expand Down
28 changes: 14 additions & 14 deletions src/GToolkit-GemStone-GemStone/GtRsrProxyServiceServer.class.st
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
Class {
#name : #GtRsrProxyServiceServer,
#superclass : #GtRsrProxyService,
#name : 'GtRsrProxyServiceServer',
#superclass : 'GtRsrProxyService',
#instVars : [
'object'
],
#category : 'GToolkit-GemStone-GemStone'
}

{ #category : #other }
{ #category : 'other' }
GtRsrProxyServiceServer class >> object: anObject [

^ self new object: anObject
]

{ #category : #accessing }
{ #category : 'accessing' }
GtRsrProxyServiceServer >> asGtGsArgument [
"Answer the the local object of the receiver"

^ object
]

{ #category : #private }
{ #category : 'private' }
GtRsrProxyServiceServer >> basicPerform: aSymbol withArguments: anArray [
"Perform the requested operation, catching errors and returning exception information"

^ GtGemStoneEvaluationContext new
^ GtGemStoneEvaluationExecutionContext new
evaluateAndWaitBlock: [ object perform: aSymbol withArguments: anArray asGtGsArgument ]
from: self.
]

{ #category : #accessing }
{ #category : 'accessing' }
GtRsrProxyServiceServer >> object [
"Answer the object being proxied"

^ object
]

{ #category : #accessing }
{ #category : 'accessing' }
GtRsrProxyServiceServer >> object: anObject [
"Set the object being proxied"

object := anObject.
remoteClass := anObject class name.
]

{ #category : #performing }
{ #category : 'performing' }
GtRsrProxyServiceServer >> proxyPerform: aSymbol [

^ (self basicPerform: aSymbol withArguments: #()) asGtRsrProxyObjectForConnection: _connection
]

{ #category : #performing }
{ #category : 'performing' }
GtRsrProxyServiceServer >> proxyPerform: aSymbol serializationStrategy: serializationSymbol [

^ (Globals at: serializationSymbol) new serialize: (self basicPerform: aSymbol withArguments: #())
]

{ #category : #performing }
{ #category : 'performing' }
GtRsrProxyServiceServer >> proxyPerform: aSymbol withArguments: anArray [

^ (self basicPerform: aSymbol withArguments: anArray) asGtRsrProxyObjectForConnection: _connection
]

{ #category : #performing }
{ #category : 'performing' }
GtRsrProxyServiceServer >> proxyPerform: aSymbol withArguments: anArray serializationStrategy: serializationSymbol [

^ (Globals at: serializationSymbol) new serialize:
(self basicPerform: aSymbol withArguments: anArray)
]

{ #category : #performing }
{ #category : 'performing' }
GtRsrProxyServiceServer >> proxyPerformReturnProxy: aSymbol [
| result |

Expand All @@ -78,7 +78,7 @@ GtRsrProxyServiceServer >> proxyPerformReturnProxy: aSymbol [
^ self class object: result.
]

{ #category : #performing }
{ #category : 'performing' }
GtRsrProxyServiceServer >> proxyPerformReturnProxy: aSymbol withArguments: anArray [
| result |

Expand Down

0 comments on commit 553d866

Please sign in to comment.