-
-
Notifications
You must be signed in to change notification settings - Fork 789
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
Replace thread_safe with concurrent-ruby #2822
Replace thread_safe with concurrent-ruby #2822
Conversation
The Travis test was failed for only Ruby 1.8. Because To run How do you think to implement to fix it? |
Thanks for raising this issue. Since we're not technically supporting Ruby 1.8.7 anymore, and this is just for tests, you can add an exception in the Gemfile. Find:
and add:
|
Can you also add an entry to the CHANGELOG.adoc when you update the PR? Please use the category "Build / Infrastructure". Thanks! |
lib/asciidoctor/converter/factory.rb
Outdated
require 'thread_safe'.to_s unless defined? ::ThreadSafe | ||
new ::ThreadSafe::Cache.new | ||
require 'concurrent'.to_s unless defined? ::Concurrent | ||
new ::Concurrent::Hash.new | ||
rescue ::LoadError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is just for tests
thread_safe
is not only for test. It is implemented.
Adding gem 'thread_safe', '~> 0.3.0'
to Gemfile
is meaningless, if we do not implement the conditional requiring thread_safe
logic here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha! I see what you are saying. Let me think about it. We might be able to put stubs in place for Ruby 1.8.7 or we can just make this part of the 2.0.0 release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I will wait you :)
Possible solution 1:Add only
Possible solution 2:Add both In this solution, we need implementation to use Possible solution 3:Just remove Ruby 1.8 test case from Travis, keeping |
209d29c
to
996608b
Compare
I can update the |
By the way, though it's not related to this PR, seeing current
This kind of brackets style
Just I would share you the information :) |
I'm very strongly in favor of lisp-style brackets when writing Ruby. I use it everywhere. I've documented this as part of the style for Asciidoctor projects here: https://github.com/asciidoctor/jekyll-asciidoc/blob/master/coding-style-guide.adoc. That will get moved into the documentation once we roll out 2.0. |
Okay, it is great for this project to have a coding style guide. |
4cc9f30
to
c3970de
Compare
I've proposed a revision which maps Concurrent::Hash to ThreadSafe::Cache in Ruby 1.8.7 so tests will pass. We really aren't worrying about Ruby 1.8.7 at this point, so as long as the CI job runs, it's fine. |
d5f3133
to
e6d2d7a
Compare
I recognize this solution is not pretty, but it's just temporary until Asciidoctor 2.0.0, when we'll be dropping support for all these old Ruby versions. |
All right. I like the solution. The effort to support Ruby 1.8 until Asciidoctor 2.0.0. By the way, you pushed your commit to my repository to add your commit in this PR. Anyway, thank you for the working. |
Build / Infrastructure:: | ||
|
||
* replace thread_safe with concurrent-ruby (PR #2822) (*@junaruga*) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part should be changed? This PR is not only for Build / Infrastructure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it changes the APIs used by this project, you're right. It's not just a dependency change. Therefore, it should now be under Improvements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I moved it to Improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Should I move my comment to another category in |
It's a rather recent feature of GitHub and it's the default setting when contributing to this project. This workflow makes it easier to collaborate on changes as you can communicate via code instead of words. It's also very helpful in cases when the contributor is not familiar with git (obviously not the case here). |
It's not so much of an effort as just something that was never clearly defined. By moving to semantic versioning, we can do it (meaning drop it). |
That's great feature for the collaboration. I did not know that.
I agree. This is really helpful. |
Looks good! I'll get this merged tonight. |
We might need to patch Asciidoctor.js and more specifically: https://github.com/asciidoctor/asciidoctor.js/blob/master/lib/asciidoctor/js/opal_ext/thread_safe.rb I need to check but since we are now using |
lib/asciidoctor/converter/factory.rb
Outdated
@@ -44,14 +44,14 @@ class << self | |||
# Returns the default [Factory] singleton instance | |||
def default initialize_singleton = true | |||
return @__default__ || new unless initialize_singleton | |||
# FIXME this assignment is not thread_safe, may need to use a ::Threadsafe helper here | |||
# FIXME this assignment is not concurrent-ruby, may need to use a ::Threadsafe helper here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we really want to say that the assignment is not "thread safe" right ?
And we may need to use a ::Concurrent
(Ruby) helper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right you are!
@Mogztter yes, we'll need something mapped in Opal. Something like:
That will replace the existing patch, though it doesn't hurt to keep both for now. |
thread_safe is deprecated and has been merged into concurrent-ruby
5c1811d
to
1685c24
Compare
I made some updates. It should be sound now. I had forgotten about the case in factory.rb. (I am so looking forwarded to be rid of Ruby 1.8.7 from this code base). |
@Mogztter thanks for the checking! @mojavelinux thanks for the updates! I checked it. |
Thanks again! We can use this opportunity to test on AsciidoctorJ and Asciidoctor.js. cc: @robertpanzer |
@mojavelinux We may have a missing test case because I didn't patch Asciidoctor.js and the build is still green... |
Keep in mind this is only hit when registering a custom converter class or using the template converter. And Asciidoctor.js may already hit the fallback. But that's just a guess. |
I removed Asciidoctor template.js from the test suite a while back I think that's why. I will add a test with a dummy custom converter. EDIT: When I register a custom converter, the following warning is thrown |
Because thread_safe is deprecated, as it was merged to concurrent-ruby.