Closed aaronjensen closed 2 years ago
A LocalJumpError will cause the synchronize block to break, meaning that result will never be set and success will never be set to true. Furthermore, it is not caught by the rescue so no reason is caught.
I consider it a “success” by setting success to true initially. It will only be considered a failure if an exception is caught.
Even though the synchronize block is short circuited, the return still evaluates, so this completes the promise with a success and nil value.
Note that JRuby has a bug with local jumps in general, which will also impact this functionality.
task = -> { yield 42 }
puts :here
This is fixed in their master branch.
See: https://bugs.ruby-lang.org/issues/18474 And: https://github.com/ruby-concurrency/concurrent-ruby/issues/931