Mantis - Croquet
Viewing Issue Advanced Details
6854 Any minor always 01-14-08 00:31 01-14-08 01:04
georgkoester  
 
normal  
new  
open  
none    
none  
0006854: TPromise>>waitTimeoutMSecs fails to wait at all
This code is not waiting:
waitTimeoutMSecs: msecs
    "Wait for at most the given number of milliseconds for this promise to resolve. Answer true if it is resolved, false otherwise."
    | sema |
    sema := Semaphore new.
    self whenComplete:[sema signal].
    Delay timeoutSemaphore: sema afterMSecs: msecs.
    ^self isResolved

If you look at the implementation of Delay>>timeoutSemaphore:afterMSecs: here:
timeoutSemaphore: aSemaphore afterMSecs: anInteger
 "... cut comment ..."
    anInteger < 0 ifTrue: [self error: 'delay times cannot be negative'].
    ^ (self new setDelay: anInteger forSemaphore: aSemaphore) schedule

you can see that no waiting is actually done and a TestCase attached to this report confirms that.
Fix is provided, too - by using the Semaphore>>waitTimeoutMSecs directly.
 TPromiseTest.st [^] (1,161 bytes) 01-14-08 00:31
 TPromise.st [^] (4,117 bytes) 01-14-08 01:04

There are no notes attached to this issue.