The Trunk: Kernel-ar.415.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Kernel-ar.415.mcz

commits-2
Andreas Raab uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ar.415.mcz

==================== Summary ====================

Name: Kernel-ar.415
Author: ar
Time: 3 March 2010, 9:42:13.86 pm
UUID: dc49d9cd-b446-8747-8337-1712a9d0258f
Ancestors: Kernel-dtl.414

Attempt to complete ensure blocks that are currently under execution when terminating a process.

=============== Diff against Kernel-dtl.414 ===============

Item was changed:
  ----- Method: Process>>terminate (in category 'changing process state') -----
  terminate
  "Stop the process that the receiver represents forever.  Unwind to execute pending ensure:/ifCurtailed: blocks before terminating."
 
  | ctxt unwindBlock oldList |
  self isActiveProcess ifTrue: [
  ctxt := thisContext.
  [ ctxt := ctxt findNextUnwindContextUpTo: nil.
  ctxt isNil
  ] whileFalse: [
  (ctxt tempAt: 2) ifNil:[
  ctxt tempAt: 2 put: nil.
  unwindBlock := ctxt tempAt: 1.
  thisContext terminateTo: ctxt.
  unwindBlock value].
  ].
  thisContext terminateTo: nil.
  self suspend.
  ] ifFalse:[
  "Always suspend the process first so it doesn't accidentally get woken up"
  oldList := self suspend.
  suspendedContext ifNotNil:[
  "Figure out if we are terminating the process while waiting in Semaphore>>critical:
  In this case, pop the suspendedContext so that we leave the ensure: block inside
  Semaphore>>critical: without signaling the semaphore."
  (oldList class == Semaphore and:[
  suspendedContext method == (Semaphore compiledMethodAt: #critical:)]) ifTrue:[
  suspendedContext := suspendedContext home.
  ].
+
+ "If we are terminating a process halfways through an unwind, try
+ to complete that unwind block first."
+ (suspendedContext findNextUnwindContextUpTo: nil) ifNotNil:[:outer|
+ (suspendedContext findContextSuchThat:[:c| c closure == (outer tempAt: 1)]) ifNotNil:[:inner|
+ "This is an unwind block currently under evaluation"
+ suspendedContext runUntilErrorOrReturnFrom: inner.
+ ].
+ ].
+
  ctxt := self popTo: suspendedContext bottomContext.
  ctxt == suspendedContext bottomContext ifFalse: [
  self debug: ctxt title: 'Unwind error during termination']].
  ].
  !