|
15 | 15 | end
|
16 | 16 |
|
17 | 17 | specify '#receive' do
|
18 |
| - id = -> v { v } |
19 | 18 | succ = -> v { v.succ }
|
20 | 19 |
|
21 | 20 | [[[:v], -> { receive }, :v],
|
22 |
| - [[:v], -> { receive on(ANY, &id) }, :v], |
| 21 | + [[:v], -> { receive on(ANY, &identity) }, :v], |
23 | 22 | [[:v, 1], -> { receive Numeric }, 1],
|
24 | 23 | [[:v, 1], -> { receive(Numeric, &succ) }, 2],
|
25 | 24 |
|
|
33 | 32 | [[:v, 1], -> { receive Numeric, timeout: 1, timeout_value: :timeout }, 1],
|
34 | 33 | [[:v, 1], -> { receive(Numeric, timeout: 1, timeout_value: :timeout, &succ) }, 2],
|
35 | 34 |
|
36 |
| - [[:v], -> { receive on(Numeric, &id), on(TIMEOUT, nil), timeout: 0 }, nil], |
| 35 | + [[:v], -> { receive on(Numeric, &identity), on(TIMEOUT, nil), timeout: 0 }, nil], |
37 | 36 | [[:v], -> { receive on(Numeric, &succ), on(TIMEOUT, nil), timeout: 0 }, nil],
|
38 |
| - [[:v], -> { receive on(Numeric, &id), on(TIMEOUT, :timeout), timeout: 0 }, :timeout], |
| 37 | + [[:v], -> { receive on(Numeric, &identity), on(TIMEOUT, :timeout), timeout: 0 }, :timeout], |
39 | 38 | [[:v], -> { receive on(Numeric, &succ), on(TIMEOUT, :timeout), timeout: 0 }, :timeout],
|
40 | 39 |
|
41 |
| - [[:v, 1], -> { receive on(Numeric, &id), on(TIMEOUT, nil), timeout: 1 }, 1], |
| 40 | + [[:v, 1], -> { receive on(Numeric, &identity), on(TIMEOUT, nil), timeout: 1 }, 1], |
42 | 41 | [[:v, 1], -> { receive on(Numeric, &succ), on(TIMEOUT, nil), timeout: 1 }, 2],
|
43 |
| - [[:v, 1], -> { receive on(Numeric, &id), on(TIMEOUT, :timeout), timeout: 1 }, 1], |
| 42 | + [[:v, 1], -> { receive on(Numeric, &identity), on(TIMEOUT, :timeout), timeout: 1 }, 1], |
44 | 43 | [[:v, 1], -> { receive on(Numeric, &succ), on(TIMEOUT, :timeout), timeout: 1 }, 2],
|
45 | 44 | ].each_with_index do |(messages, body, result), i|
|
46 | 45 | a = Concurrent::ErlangActor.spawn(type, &body)
|
|
229 | 228 | b = spawn { :done }
|
230 | 229 | b.terminated.wait
|
231 | 230 | ref = monitor b
|
232 |
| - [b, ref, receive(timeout: 0.01, timeout_value: :timeout)] |
| 231 | + [b, ref, receive(timeout: 1, timeout_value: :timeout)] |
233 | 232 | end,
|
234 | 233 | on_pool:
|
235 | 234 | -> do
|
236 | 235 | b = spawn { :done }
|
237 | 236 | b.terminated.wait
|
238 | 237 | ref = monitor b
|
239 |
| - receive(timeout: 0.01) { |v| [b, ref, v] } |
| 238 | + receive(timeout: 1) { |v| [b, ref, v] } |
240 | 239 | end }
|
241 | 240 |
|
242 | 241 | a = Concurrent::ErlangActor.spawn(type, &body.fetch(type))
|
|
324 | 323 | -> do
|
325 | 324 | b = spawn { :done }
|
326 | 325 | b.terminated.wait
|
327 |
| - sleep 0.01 |
| 326 | + sleep 0.1 |
328 | 327 | trap
|
329 | 328 | link b
|
330 | 329 | [b, receive]
|
|
333 | 332 | -> do
|
334 | 333 | b = spawn { :done }
|
335 | 334 | b.terminated.wait
|
336 |
| - sleep 0.01 |
| 335 | + sleep 0.1 |
337 | 336 | trap
|
338 | 337 | link b
|
339 | 338 | receive { |v| [b, v] }
|
|
374 | 373 | -> do
|
375 | 374 | b = spawn(link: true) { :ok }
|
376 | 375 | trap
|
377 |
| - [receive, b] |
| 376 | + [receive(timeout: 1), b] |
378 | 377 | end,
|
379 | 378 | on_pool:
|
380 | 379 | -> do
|
381 | 380 | b = spawn(link: true) { :ok }
|
382 | 381 | trap
|
383 | 382 | receive(on(ANY) { |v| [v, b] },
|
384 | 383 | on(TIMEOUT) { |v| [nil, b] },
|
385 |
| - timeout: 0.01) |
| 384 | + timeout: 1) |
386 | 385 | end }
|
387 | 386 |
|
388 | 387 | a = Concurrent::ErlangActor.spawn(type, &body.fetch(type))
|
|
396 | 395 | body = { on_thread:
|
397 | 396 | -> do
|
398 | 397 | spawn(link: true) { terminate :boom }
|
399 |
| - receive(timeout: 0.01) |
| 398 | + receive(timeout: 1) |
400 | 399 | end,
|
401 | 400 | on_pool:
|
402 | 401 | -> do
|
403 | 402 | spawn(link: true) { terminate :boom }
|
404 | 403 | receive(on(ANY) { |v| [v, b] },
|
405 | 404 | on(TIMEOUT) { |v| [nil, b] },
|
406 |
| - timeout: 0.01) |
| 405 | + timeout: 1) |
407 | 406 | end }
|
408 | 407 |
|
409 | 408 | a = Concurrent::ErlangActor.spawn(type, &body.fetch(type))
|
|
416 | 415 | -> do
|
417 | 416 | b = spawn(link: true) { terminate :boom }
|
418 | 417 | trap
|
419 |
| - [receive(timeout: 0.01), b] |
| 418 | + [receive(timeout: 1), b] |
420 | 419 | end,
|
421 | 420 | on_pool:
|
422 | 421 | -> do
|
423 | 422 | b = spawn(link: true) { terminate :boom }
|
424 | 423 | trap
|
425 | 424 | receive(on(ANY) { |v| [v, b] },
|
426 | 425 | on(TIMEOUT) { |v| [nil, b] },
|
427 |
| - timeout: 0.01) |
| 426 | + timeout: 1) |
428 | 427 | end }
|
429 | 428 |
|
430 | 429 | a = Concurrent::ErlangActor.spawn(type, &body.fetch(type))
|
|
460 | 459 | -> do
|
461 | 460 | b = spawn(link: true) { terminate :normal, value: :ok }
|
462 | 461 | trap
|
463 |
| - [receive, b] |
| 462 | + [receive(timeout: 1), b] |
464 | 463 | end,
|
465 | 464 | on_pool:
|
466 | 465 | -> do
|
467 | 466 | b = spawn(link: true) { terminate :normal, value: :ok }
|
468 | 467 | trap
|
469 | 468 | receive(on(ANY) { |v| [v, b] },
|
470 | 469 | on(TIMEOUT) { |v| [nil, b] },
|
471 |
| - timeout: 0.01) |
| 470 | + timeout: 1) |
472 | 471 | end }
|
473 | 472 |
|
474 | 473 | a = Concurrent::ErlangActor.spawn(type, &body.fetch(type))
|
|
565 | 564 | terminate pid, :normal # sends the signal to mailbox
|
566 | 565 | receive(on(ANY, :continued),
|
567 | 566 | on(TIMEOUT, :timeout),
|
568 |
| - timeout: 1) |
| 567 | + timeout: 0.01) |
569 | 568 | end }
|
570 | 569 |
|
571 | 570 | a = Concurrent::ErlangActor.spawn(type, &body.fetch(type))
|
|
578 | 577 | -> do
|
579 | 578 | terminate pid, :normal
|
580 | 579 | trap
|
581 |
| - receive(timeout: 0.01) |
| 580 | + receive(timeout: 0) |
582 | 581 | end,
|
583 | 582 | on_pool:
|
584 | 583 | -> do
|
585 | 584 | terminate pid, :normal
|
586 | 585 | trap
|
587 |
| - receive(on(ANY, &identity), on(TIMEOUT, nil), timeout: 0.01) |
| 586 | + receive(on(ANY, &identity), on(TIMEOUT, nil), timeout: 0) |
588 | 587 | end }
|
589 | 588 |
|
590 | 589 | a = Concurrent::ErlangActor.spawn(type, &body.fetch(type))
|
|
620 | 619 | specify 4 do
|
621 | 620 | body = { on_thread:
|
622 | 621 | -> do
|
623 |
| - b = spawn(link: true) { trap; receive timeout: 0.01, timeout_value: :timeout } |
| 622 | + b = spawn(link: true) { trap; receive timeout: 1, timeout_value: :timeout } |
624 | 623 | terminate b, :normal
|
625 | 624 | b
|
626 | 625 | end,
|
|
630 | 629 | trap
|
631 | 630 | receive(on(ANY, &identity),
|
632 | 631 | on(TIMEOUT, :timeout),
|
633 |
| - timeout: 0.01) |
| 632 | + timeout: 1) |
634 | 633 | end
|
635 | 634 |
|
636 | 635 | terminate b, :normal
|
|
648 | 647 | b = spawn(link: true) { receive timeout: 0.01; terminate :continued }
|
649 | 648 | terminate b, :normal
|
650 | 649 | trap
|
651 |
| - [b, receive(timeout: 0.02)] |
| 650 | + [b, receive(timeout: 1)] |
652 | 651 | end,
|
653 | 652 | on_pool:
|
654 | 653 | -> do
|
|
739 | 738 | specify 9 do
|
740 | 739 | body = { on_thread:
|
741 | 740 | -> do
|
742 |
| - b = spawn(link: true) { receive timeout: 0.01; :done } |
| 741 | + b = spawn(link: true) { receive timeout: 1; :done } |
743 | 742 | terminate b, :kill
|
744 | 743 | trap
|
745 |
| - [b, receive(timeout: 0.01)] |
| 744 | + [b, receive(timeout: 1)] |
746 | 745 | end,
|
747 | 746 | on_pool:
|
748 | 747 | -> do
|
|
762 | 761 | body = { on_thread:
|
763 | 762 | -> do
|
764 | 763 | terminate pid, :kill
|
765 |
| - receive timeout: 0.01 |
| 764 | + receive timeout: 0 |
766 | 765 | end,
|
767 | 766 | on_pool:
|
768 | 767 | -> do
|
769 | 768 | terminate pid, :kill
|
770 |
| - receive(on(ANY, :continued), on(TIMEOUT, :timeout), timeout: 1) |
| 769 | + receive(on(ANY, :continued), on(TIMEOUT, :timeout), timeout: 0) |
771 | 770 | end }
|
772 | 771 |
|
773 | 772 | a = Concurrent::ErlangActor.spawn(type, &body.fetch(type))
|
|
780 | 779 | -> do
|
781 | 780 | terminate pid, :kill
|
782 | 781 | trap
|
783 |
| - receive timeout: 0.01 |
| 782 | + receive timeout: 0 |
784 | 783 | end,
|
785 | 784 | on_pool:
|
786 | 785 | -> do
|
787 | 786 | terminate pid, :kill
|
788 | 787 | trap
|
789 |
| - receive(on(ANY, &identity), on(TIMEOUT, :timeout), timeout: 1) |
| 788 | + receive(on(ANY, &identity), on(TIMEOUT, :timeout), timeout: 0) |
790 | 789 | end }
|
791 | 790 |
|
792 | 791 | a = Concurrent::ErlangActor.spawn(type, &body.fetch(type))
|
|
922 | 921 | let(:type) { :on_pool }
|
923 | 922 | it_behaves_like 'erlang actor'
|
924 | 923 |
|
| 924 | + include Concurrent::ErlangActor::EnvironmentConstants |
| 925 | + |
925 | 926 | specify "receives message repeatedly with keep" do
|
926 | 927 | actor = Concurrent::ErlangActor.spawn(:on_pool) do
|
927 | 928 | receive on(ANY) { |v| v == :done ? terminate(:normal, value: 42) : reply(v) },
|
|
0 commit comments