並行・並列処理のテストは難しい

 並行・並列処理のテストは難しい

B54cc1be9e7ea6e3ff17eaf995fbe35f?s=128

Akihito Nakano

October 27, 2016
Tweet

Transcript

  1. 10.

    1)1

  2. 13.
  3. 18.
  4. 21.

    ϓϩμΫτίʔυ͜͏ʂ class Foo def run Thread.new do # ৭ʑ @done

    = self.do end # ৭ʑ end def do # ৭ʑ true end end
  5. 23.

    ςετίʔυ͜͏ʂ class FooTest < Test::Unit::TestCase def test_run (foo = Foo.new).run

    sleep 1 assert_true foo.done end def test_do assert_true Foo.new.do end end
  6. 27.

    ςετίʔυ·ͩ໰୊͸ղܾ͍ͯ͠ͳ͍ʜ class FooTest < Test::Unit::TestCase def test_run (foo = Foo.new).run

    sleep 1 assert_true foo.done end def test_do assert_true Foo.new.do end end ෆ҆ఆ
  7. 30.

    ϓϩμΫτίʔυ͜ΕΛʜ class Foo def run Thread.new do # ৭ʑ @done

    = self.do end # ৭ʑ end def do # ৭ʑ true end end
  8. 31.

    ϓϩμΫτίʔυ͜͏ʂ class Foo def initialize @done = SizedQueue.new(1) end def

    run Thread.new do # ৭ʑ @done << self.do end # ৭ʑ end … (ུ) … end
  9. 32.

    ςετίʔυ͜ΕΛʜ class FooTest < Test::Unit::TestCase def test_run (foo = Foo.new).run

    sleep 1 assert_true foo.done end def test_do assert_true Foo.new.do end end
  10. 33.

    ςετίʔυ͜͏ʂ class FooTest < Test::Unit::TestCase def test_run (foo = Foo.new).run

    assert_true foo.done.pop end def test_do assert_true Foo.new.do end end
  11. 36.