@@ -317,8 +317,8 @@ def test_core_02
317
317
318
318
def test_core_03_notify
319
319
notify1 = @ts . notify ( nil , [ :req , Integer ] )
320
- notify2 = @ts . notify ( nil , [ :ans , Integer ] , 5 )
321
- notify3 = @ts . notify ( nil , { "message" => String , "name" => String } , 5 )
320
+ notify2 = @ts . notify ( nil , [ :ans , Integer ] , 8 )
321
+ notify3 = @ts . notify ( nil , { "message" => String , "name" => String } , 8 )
322
322
323
323
@ts . write ( { "message" => "first" , "name" => "3" } , 3 )
324
324
@ts . write ( { "message" => "second" , "name" => "1" } , 1 )
@@ -347,19 +347,19 @@ def test_core_03_notify
347
347
result = nil
348
348
lv = 0
349
349
n = 0
350
- notify2 . each do |ev |
350
+ notify2 . each do |ev , tuple |
351
351
n += 1
352
- if ev [ 0 ] == 'write'
352
+ if ev == 'write'
353
353
lv = lv + 1
354
- elsif ev [ 0 ] == 'take'
354
+ elsif ev == 'take'
355
355
lv = lv - 1
356
- elsif ev [ 0 ] == 'close'
356
+ elsif ev == 'close'
357
357
result = [ lv , n ]
358
358
else
359
359
break
360
360
end
361
361
assert ( lv >= 0 )
362
- assert_equal ( [ :ans , 10 ] , ev [ 1 ] )
362
+ assert_equal ( [ :ans , 10 ] , tuple )
363
363
end
364
364
result
365
365
end
@@ -386,13 +386,15 @@ def test_core_03_notify
386
386
387
387
sleep ( 4 )
388
388
assert_equal ( 10 , thread_join ( taker ) )
389
+ # notify2 must not expire until this @ts.take.
390
+ # sleep(4) might be short enough for the timeout of notify2 (8 secs)
389
391
tuple = @ts . take ( [ :ans , nil ] )
390
392
assert_equal ( 10 , tuple [ 1 ] )
391
393
assert_equal ( [ ] , @ts . read_all ( [ nil , nil ] ) )
392
-
394
+
393
395
notify1 . cancel
394
- sleep ( 3 ) # notify2 expired
395
-
396
+ sleep ( 7 ) # notify2 expired (sleep(4)+sleep(7) > 8)
397
+
396
398
assert_equal ( [ 0 , 11 ] , thread_join ( listener1 ) )
397
399
assert_equal ( [ 0 , 3 ] , thread_join ( listener2 ) )
398
400
0 commit comments