Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reenable Java implementations #717

Closed
pitr-ch opened this issue May 23, 2018 · 7 comments
Closed

Reenable Java implementations #717

pitr-ch opened this issue May 23, 2018 · 7 comments
Assignees
Labels
bug A bug in the library or documentation. high-priority Should be done ASAP.

Comments

@pitr-ch
Copy link
Member

pitr-ch commented May 23, 2018

All the Java blocking abstraction implementations had to be rolled back because the java threading is not compatible with ruby threading. E.g. a thread blocked by java CountDownLatch implementation cannot be killed from Ruby.

Note: Anything that uses Concurrent::Synchronization layer is fine since it's hooks into JRuby's internal mechanism for threads, but naked Java implementations are a problem.

Disabled in a6fc08f, 1e51d2c

@pitr-ch pitr-ch added this to the 1.1.0 milestone May 23, 2018
@pitr-ch pitr-ch self-assigned this May 23, 2018
@pitr-ch pitr-ch added the bug A bug in the library or documentation. label May 23, 2018
@pitr-ch
Copy link
Member Author

pitr-ch commented May 23, 2018

cc @enebo @headius could JRuby's thread kill and other operations be made compatible with java interrupt mechanism to unblock Ruby threads blocked by Java blocking classes like CountDownLatch, Exchanger, etc. So far I think this needs a fix from JRuby side, the Thread's kill, wakup etc. methods would need to interrupt.

@pitr-ch pitr-ch mentioned this issue May 24, 2018
@headius
Copy link
Contributor

headius commented May 24, 2018

JRuby can't violate anything about Java's threads, so we won't forcibly kill a target thread. We do have mechanisms to allow you to block with a wakeup mechanism, however, which is how we do locking and sleeps and selects interruptibly. See how sleep works in JRuby for an example.

@pitr-ch
Copy link
Member Author

pitr-ch commented May 24, 2018

yeah, I use the JRuby's interruptible in https://github.com/ruby-concurrency/concurrent-ruby/blob/master/ext/com/concurrent_ruby/ext/SynchronizationLibrary.java#L244 however that does not work afaik with java.util.concurrent.CountDownLatch which can be only interrupted with https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.html#interrupt-- which is not used by JRuby. So either 1) c-r needs to write another CountDownLatch java implementation which would be compatible with JRuby's interuptible thread waiting or 2) JRuby has to call interupt, which I have no idea if that could be done. Therefore my question is about 2) if it would be feasible. Sorry for unclarity.

@headius
Copy link
Contributor

headius commented May 24, 2018

@pitr-ch I believe you want to use this method: https://github.com/jruby/jruby/blob/1e235478afd39f5b62dd26dd3b8677fbc7582011/core/src/main/java/org/jruby/RubyThread.java#L1530

RubyThread.executeTask allows you to register an "unblocker" implementation that can be used to do that thread interrupt. I use the same mechanism here: https://github.com/jruby/jruby/blob/807900a0478fd4d9a5509eb4ad1172a1a89a2c1e/core/src/main/java/org/jruby/ext/thread/Queue.java#L581-L588

@pitr-ch
Copy link
Member Author

pitr-ch commented May 25, 2018

Ah great that looks simpler that I thought. I may be able to fix this without rollbacking the Java implementations for the upcoming patch release. Thanks.

@pitr-ch pitr-ch modified the milestones: 1.1.0, 1.0.6 May 25, 2018
@enebo
Copy link

enebo commented May 25, 2018

@pitr-ch hey is there still a Fixnum type check in concurrent-ruby? We have a 2.5 implementation now and we see:

/home/enebo/work/jruby/lib/ruby/gems/shared/gems/concurrent-ruby-1.0.5-java/lib/concurrent/atomic/java_count_down_latch.rb:12: warning: constant ::Fixnum is deprecated

(Sorry for not just PRing or opening an issue :) ).

@pitr-ch
Copy link
Member Author

pitr-ch commented May 29, 2018

@enebo thanks, fixed

@pitr-ch pitr-ch added the patch label Jun 18, 2018
@pitr-ch pitr-ch added high-priority Should be done ASAP. and removed patch labels Jun 29, 2018
@pitr-ch pitr-ch removed this from the 1.0.6 milestone Jul 6, 2018
pitr-ch added a commit that referenced this issue Jul 7, 2018
Fix #717: Reenable java implementations, fix global IO executor on JRuby, bunch of other bug fixes
@ghost ghost removed the in progress label Jul 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug in the library or documentation. high-priority Should be done ASAP.
Projects
None yet
Development

No branches or pull requests

3 participants