[go: up one dir, main page]

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

Replace ActiveSupport::Concurrency::Latch with Concurrent::CountDownLatch from concurrent-ruby. #20866

Merged
merged 1 commit into from
Jul 14, 2015
Merged

Conversation

jdantonio
Copy link
Contributor

This update was suggested by @tenderlove in a discussion on one of his PRs to concurrent-ruby.

The concurrent-ruby gem is a toolset containing many concurrency utilities. Many of these utilities include runtime-specific optimizations when possible. Rather than clutter the Rails codebase with concurrency utilities separate from the core task, such tools can be superseded by similar tools in the more specialized gem. This commit replaces ActiveSupport::Concurrency::Latch with Concurrent::CountDownLatch, which is functionally equivalent.

@tenderlove
Copy link
Member

@jdantonio thanks. I don't think this is enough though. We have runtime requirements for the countdown latch. Can you update the gemspecs that need concurrent-ruby to depend on it? I think only actionpack needs it.

Also we may want to consider adding a deprecation warning for the countdown latch that's in Rails (though since this is Rails 5, and I don't think many people use our latch I'm not sure we need that).

@jdantonio
Copy link
Contributor Author

Sorry I missed the runtime requirement. I thought it was only used in tests. I'll update ASAP.

@tenderlove
Copy link
Member

@jdantonio thanks so much! Also, if you don't mind, could you check our uses of the thread_safe gem? AFAICT, concurrent-ruby supersedes it, and I'd rather just switch thread_safe to concurrent-ruby if that's possible.

@jdantonio
Copy link
Contributor Author

@tenderlove We have not merged thread_safe into concurrent-ruby yet, just ruby-atomic. We want to get c-r 1.0 out before we merge thread_safe.

@tenderlove
Copy link
Member

I see. Nevermind about thread_safe then. :)

The concurrent-ruby gem is a toolset containing many concurrency
utilities. Many of these utilities include runtime-specific
optimizations when possible. Rather than clutter the Rails codebase with
concurrency utilities separate from the core task, such tools can be
superseded by similar tools in the more specialized gem. This commit
replaces `ActiveSupport::Concurrency::Latch` with
`Concurrent::CountDownLatch`, which is functionally equivalent.
@jdantonio
Copy link
Contributor Author

@tenderlove I put ActiveSupport::Concurrency::Latch back but it now extends Concurrent::CountDownLatch and gives a deprecation warning.

I removed c-r from Gemfile and put the c-r dependency in the gemspec for activesupport (since it now uses CountDownLatch directly). Both actionpack and activerecord use CountDownLatch in their tests but both should pick up the dependency through activesupport.

I couldn't find any place in actionpack that used the original Latch and the tests all passed on the original commit. I added c-r to its gemspec anyway, at your suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants