Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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

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

Akihito Nakano

October 27, 2016
Tweet

More Decks by Akihito Nakano

Other Decks in Programming

Transcript

  1. 1)1

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

    = self.do end # ৭ʑ end def do # ৭ʑ true end end
  3. ςετίʔυ͜͏ʂ 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
  4. ςετίʔυ·ͩ໰୊͸ղܾ͍ͯ͠ͳ͍ʜ 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 ෆ҆ఆ
  5. ϓϩμΫτίʔυ͜ΕΛʜ class Foo def run Thread.new do # ৭ʑ @done

    = self.do end # ৭ʑ end def do # ৭ʑ true end end
  6. ϓϩμΫτίʔυ͜͏ʂ class Foo def initialize @done = SizedQueue.new(1) end def

    run Thread.new do # ৭ʑ @done << self.do end # ৭ʑ end … (ུ) … end
  7. ςετίʔυ͜ΕΛʜ 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
  8. ςετίʔυ͜͏ʂ 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