help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] [PATCH] kernel: Check the Semaphore before queuing


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] [PATCH] kernel: Check the Semaphore before queuing the interrupt
Date: Mon, 20 Jan 2014 17:30:52 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130923 Thunderbird/17.0.9

The patch looks good.

Alternatively, what about this?  It is a bit clearer to me, but the
logic is pretty much the same.

Paolo

diff --git a/kernel/Delay.st b/kernel/Delay.st
index 47f40bb..ceeedfd 100644
--- a/kernel/Delay.st
+++ b/kernel/Delay.st
@@ -295,7 +295,7 @@ created.'>
          evaluate aTimeoutBlock."
         <category: 'timeout'>
         | value timeout |
-        timeout := false.
+        timeout := 0.
         value := [ | sem proc |
             "Use the semaphore to signal that we executed everything"
             sem := Semaphore new.
@@ -308,19 +308,20 @@ created.'>
 
                 "Wait and see if it is timed out. If so send a signal."
                 (self timedWaitOn: sem) ifTrue: [
-                   proc signalInterrupt: (Kernel.TimeoutNotification on: self).
+                   timeout = 0 ifTrue: [
+                       proc signalInterrupt: (Kernel.TimeoutNotification on: 
self)].
                 ].
             ] fork.
 
-            aBlock ensure: [sem signal].
+            aBlock ensure: [timeout := timeout bitOr: 1. sem signal].
         ] on: Kernel.TimeoutNotification do: [:e |
             e delay = self
-                ifTrue:  [timeout := true]
+                ifTrue:  [timeout := timeout bitOr: 2]
                 ifFalse: [e pass].
         ].
 
         "Make sure we call the #ensure:/#ifCurtailed: blocks first."
-        ^ timeout
+        ^ (timeout bitAnd: 2) = 2
             ifTrue:  [aTimeoutBlock value]
             ifFalse: [value].
     ]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]