Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
1bf3cecf
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
1bf3cecf
编写于
9月 19, 2015
作者:
K
Kasper Timm Hansen
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21679 from jdantonio/replace-thread-safe
Replaced `ThreadSafe::Map` with successor `Concurrent::Map`.
上级
dcc94138
56ac6e47
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
45 addition
and
43 deletion
+45
-43
Gemfile.lock
Gemfile.lock
+2
-3
actionview/lib/action_view/dependency_tracker.rb
actionview/lib/action_view/dependency_tracker.rb
+2
-2
actionview/lib/action_view/digestor.rb
actionview/lib/action_view/digestor.rb
+3
-3
actionview/lib/action_view/lookup_context.rb
actionview/lib/action_view/lookup_context.rb
+2
-2
actionview/lib/action_view/renderer/partial_renderer.rb
actionview/lib/action_view/renderer/partial_renderer.rb
+3
-3
actionview/lib/action_view/template/resolver.rb
actionview/lib/action_view/template/resolver.rb
+2
-2
activejob/lib/active_job/async_job.rb
activejob/lib/active_job/async_job.rb
+1
-2
activemodel/lib/active_model/attribute_methods.rb
activemodel/lib/active_model/attribute_methods.rb
+2
-2
activerecord/lib/active_record/attribute_methods.rb
activerecord/lib/active_record/attribute_methods.rb
+2
-2
activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
...ve_record/connection_adapters/abstract/connection_pool.rb
+6
-6
activerecord/lib/active_record/type/type_map.rb
activerecord/lib/active_record/type/type_map.rb
+3
-3
activesupport/CHANGELOG.md
activesupport/CHANGELOG.md
+5
-0
activesupport/activesupport.gemspec
activesupport/activesupport.gemspec
+1
-2
activesupport/lib/active_support/dependencies.rb
activesupport/lib/active_support/dependencies.rb
+2
-2
activesupport/lib/active_support/inflector/inflections.rb
activesupport/lib/active_support/inflector/inflections.rb
+2
-2
activesupport/lib/active_support/key_generator.rb
activesupport/lib/active_support/key_generator.rb
+2
-2
activesupport/lib/active_support/notifications/fanout.rb
activesupport/lib/active_support/notifications/fanout.rb
+3
-3
activesupport/lib/active_support/values/time_zone.rb
activesupport/lib/active_support/values/time_zone.rb
+2
-2
未找到文件。
Gemfile.lock
浏览文件 @
1bf3cecf
...
...
@@ -122,12 +122,11 @@ PATH
activesupport (= 5.0.0.alpha)
arel (= 7.0.0.alpha)
activesupport (5.0.0.alpha)
concurrent-ruby (~>
0.9.1
)
concurrent-ruby (~>
1.0.0.pre2, < 2.0.0
)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
method_source
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
rails (5.0.0.alpha)
actionmailer (= 5.0.0.alpha)
...
...
@@ -172,7 +171,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.9.1.1)
concurrent-ruby (
0.9.1
)
concurrent-ruby (
1.0.0.pre2
)
connection_pool (2.2.0)
dalli (2.7.4)
dante (0.2.0)
...
...
actionview/lib/action_view/dependency_tracker.rb
浏览文件 @
1bf3cecf
require
'
thread_safe
'
require
'
concurrent
'
require
'action_view/path_set'
module
ActionView
class
DependencyTracker
# :nodoc:
@trackers
=
ThreadSafe
::
Cache
.
new
@trackers
=
Concurrent
::
Map
.
new
def
self
.
find_dependencies
(
name
,
template
,
view_paths
=
nil
)
tracker
=
@trackers
[
template
.
handler
]
...
...
actionview/lib/action_view/digestor.rb
浏览文件 @
1bf3cecf
require
'
thread_safe
'
require
'
concurrent
'
require
'action_view/dependency_tracker'
require
'monitor'
module
ActionView
class
Digestor
cattr_reader
(
:cache
)
@@cache
=
ThreadSafe
::
Cache
.
new
@@cache
=
Concurrent
::
Map
.
new
@@digest_monitor
=
Monitor
.
new
class
PerRequestDigestCacheExpiry
<
Struct
.
new
(
:app
)
# :nodoc:
...
...
@@ -28,7 +28,7 @@ def digest(options)
cache_key
=
([
options
[
:name
],
options
[
:finder
].
details_key
.
hash
].
compact
+
Array
.
wrap
(
options
[
:dependencies
])).
join
(
'.'
)
# this is a correctly done double-checked locking idiom
# (
ThreadSafe::Cache
's lookups have volatile semantics)
# (
Concurrent::Map
's lookups have volatile semantics)
@@cache
[
cache_key
]
||
@@digest_monitor
.
synchronize
do
@@cache
.
fetch
(
cache_key
)
do
# re-check under lock
compute_and_store_digest
(
cache_key
,
options
)
...
...
actionview/lib/action_view/lookup_context.rb
浏览文件 @
1bf3cecf
require
'
thread_safe
'
require
'
concurrent
'
require
'active_support/core_ext/module/remove_method'
require
'active_support/core_ext/module/attribute_accessors'
require
'action_view/template/resolver'
...
...
@@ -62,7 +62,7 @@ class DetailsKey #:nodoc:
alias
:object_hash
:hash
attr_reader
:hash
@details_keys
=
ThreadSafe
::
Cache
.
new
@details_keys
=
Concurrent
::
Map
.
new
def
self
.
get
(
details
)
if
details
[
:formats
]
...
...
actionview/lib/action_view/renderer/partial_renderer.rb
浏览文件 @
1bf3cecf
require
'action_view/renderer/partial_renderer/collection_caching'
require
'
thread_safe
'
require
'
concurrent
'
module
ActionView
class
PartialIteration
...
...
@@ -283,8 +283,8 @@ def iterate! # :nodoc:
class
PartialRenderer
<
AbstractRenderer
include
CollectionCaching
PREFIXED_PARTIAL_NAMES
=
ThreadSafe
::
Cache
.
new
do
|
h
,
k
|
h
[
k
]
=
ThreadSafe
::
Cache
.
new
PREFIXED_PARTIAL_NAMES
=
Concurrent
::
Map
.
new
do
|
h
,
k
|
h
[
k
]
=
Concurrent
::
Map
.
new
end
def
initialize
(
*
)
...
...
actionview/lib/action_view/template/resolver.rb
浏览文件 @
1bf3cecf
...
...
@@ -3,7 +3,7 @@
require
"active_support/core_ext/module/attribute_accessors"
require
"action_view/template"
require
"thread"
require
"
thread_safe
"
require
"
concurrent
"
module
ActionView
# = Action View Resolver
...
...
@@ -35,7 +35,7 @@ def to_str
# Threadsafe template cache
class
Cache
#:nodoc:
class
SmallCache
<
ThreadSafe
::
Cache
class
SmallCache
<
Concurrent
::
Map
def
initialize
(
options
=
{})
super
(
options
.
merge
(
:initial_capacity
=>
2
))
end
...
...
activejob/lib/active_job/async_job.rb
浏览文件 @
1bf3cecf
require
'concurrent'
require
'thread_safe'
module
ActiveJob
# == Active Job Async Job
...
...
@@ -31,7 +30,7 @@ class AsyncJob
fallback_policy: :caller_runs
# shouldn't matter -- 0 max queue
}.
freeze
QUEUES
=
ThreadSafe
::
Cache
.
new
do
|
hash
,
queue_name
|
#:nodoc:
QUEUES
=
Concurrent
::
Map
.
new
do
|
hash
,
queue_name
|
#:nodoc:
hash
.
compute_if_absent
(
queue_name
)
{
ActiveJob
::
AsyncJob
.
create_thread_pool
}
end
...
...
activemodel/lib/active_model/attribute_methods.rb
浏览文件 @
1bf3cecf
require
'
thread_safe
'
require
'
concurrent
'
require
'mutex_m'
module
ActiveModel
...
...
@@ -350,7 +350,7 @@ def instance_method_already_implemented?(method_name) #:nodoc:
# significantly (in our case our test suite finishes 10% faster with
# this cache).
def
attribute_method_matchers_cache
#:nodoc:
@attribute_method_matchers_cache
||=
ThreadSafe
::
Cache
.
new
(
initial_capacity:
4
)
@attribute_method_matchers_cache
||=
Concurrent
::
Map
.
new
(
initial_capacity:
4
)
end
def
attribute_method_matchers_matching
(
method_name
)
#:nodoc:
...
...
activerecord/lib/active_record/attribute_methods.rb
浏览文件 @
1bf3cecf
require
'active_support/core_ext/enumerable'
require
'active_support/core_ext/string/filters'
require
'mutex_m'
require
'
thread_safe
'
require
'
concurrent
'
module
ActiveRecord
# = Active Record Attribute Methods
...
...
@@ -37,7 +37,7 @@ def self.set_name_cache(name, value)
class
AttributeMethodCache
def
initialize
@module
=
Module
.
new
@method_cache
=
ThreadSafe
::
Cache
.
new
@method_cache
=
Concurrent
::
Map
.
new
end
def
[]
(
name
)
...
...
activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
浏览文件 @
1bf3cecf
require
'thread'
require
'
thread_safe
'
require
'
concurrent
'
require
'monitor'
module
ActiveRecord
...
...
@@ -337,7 +337,7 @@ def initialize(spec)
# that case +conn.owner+ attr should be consulted.
# Access and modification of +@thread_cached_conns+ does not require
# synchronization.
@thread_cached_conns
=
ThreadSafe
::
Cache
.
new
(
:initial_capacity
=>
@size
)
@thread_cached_conns
=
Concurrent
::
Map
.
new
(
:initial_capacity
=>
@size
)
@connections
=
[]
@automatic_reconnect
=
true
...
...
@@ -824,11 +824,11 @@ def initialize
# These caches are keyed by klass.name, NOT klass. Keying them by klass
# alone would lead to memory leaks in development mode as all previous
# instances of the class would stay in memory.
@owner_to_pool
=
ThreadSafe
::
Cache
.
new
(
:initial_capacity
=>
2
)
do
|
h
,
k
|
h
[
k
]
=
ThreadSafe
::
Cache
.
new
(
:initial_capacity
=>
2
)
@owner_to_pool
=
Concurrent
::
Map
.
new
(
:initial_capacity
=>
2
)
do
|
h
,
k
|
h
[
k
]
=
Concurrent
::
Map
.
new
(
:initial_capacity
=>
2
)
end
@class_to_pool
=
ThreadSafe
::
Cache
.
new
(
:initial_capacity
=>
2
)
do
|
h
,
k
|
h
[
k
]
=
ThreadSafe
::
Cache
.
new
@class_to_pool
=
Concurrent
::
Map
.
new
(
:initial_capacity
=>
2
)
do
|
h
,
k
|
h
[
k
]
=
Concurrent
::
Map
.
new
end
end
...
...
activerecord/lib/active_record/type/type_map.rb
浏览文件 @
1bf3cecf
require
'
thread_safe
'
require
'
concurrent
'
module
ActiveRecord
module
Type
class
TypeMap
# :nodoc:
def
initialize
@mapping
=
{}
@cache
=
ThreadSafe
::
Cache
.
new
do
|
h
,
key
|
h
.
fetch_or_store
(
key
,
ThreadSafe
::
Cache
.
new
)
@cache
=
Concurrent
::
Map
.
new
do
|
h
,
key
|
h
.
fetch_or_store
(
key
,
Concurrent
::
Map
.
new
)
end
end
...
...
activesupport/CHANGELOG.md
浏览文件 @
1bf3cecf
*
Replaced deprecated
`ThreadSafe::Cache`
with its successor
`Concurrent::Map`
now that
the thread_safe gem has been merged into concurrent-ruby.
*Jerry D'Antonio*
*
Updated Unicode version to 8.0.0
*Anshul Sharma*
...
...
activesupport/activesupport.gemspec
浏览文件 @
1bf3cecf
...
...
@@ -24,7 +24,6 @@
s
.
add_dependency
'json'
,
'~> 1.7'
,
'>= 1.7.7'
s
.
add_dependency
'tzinfo'
,
'~> 1.1'
s
.
add_dependency
'minitest'
,
'~> 5.1'
s
.
add_dependency
'thread_safe'
,
'~> 0.3'
,
'>= 0.3.4'
s
.
add_dependency
'concurrent-ruby'
,
'~> 0.9.1'
s
.
add_dependency
'concurrent-ruby'
,
'~> 1.0.0.pre2'
,
'< 2.0.0'
s
.
add_dependency
'method_source'
end
activesupport/lib/active_support/dependencies.rb
浏览文件 @
1bf3cecf
require
'set'
require
'thread'
require
'
thread_safe
'
require
'
concurrent
'
require
'pathname'
require
'active_support/core_ext/module/aliasing'
require
'active_support/core_ext/module/attribute_accessors'
...
...
@@ -585,7 +585,7 @@ def remove_unloadable_constants!
class
ClassCache
def
initialize
@store
=
ThreadSafe
::
Cache
.
new
@store
=
Concurrent
::
Map
.
new
end
def
empty?
...
...
activesupport/lib/active_support/inflector/inflections.rb
浏览文件 @
1bf3cecf
require
'
thread_safe
'
require
'
concurrent
'
require
'active_support/core_ext/array/prepend_and_append'
require
'active_support/i18n'
...
...
@@ -25,7 +25,7 @@ module Inflector
# singularization rules that is runs. This guarantees that your rules run
# before any of the rules that may already have been loaded.
class
Inflections
@__instance__
=
ThreadSafe
::
Cache
.
new
@__instance__
=
Concurrent
::
Map
.
new
class
Uncountables
<
Array
def
initialize
...
...
activesupport/lib/active_support/key_generator.rb
浏览文件 @
1bf3cecf
require
'
thread_safe
'
require
'
concurrent
'
require
'openssl'
module
ActiveSupport
...
...
@@ -28,7 +28,7 @@ def generate_key(salt, key_size=64)
class
CachingKeyGenerator
def
initialize
(
key_generator
)
@key_generator
=
key_generator
@cache_keys
=
ThreadSafe
::
Cache
.
new
@cache_keys
=
Concurrent
::
Map
.
new
end
# Returns a derived key suitable for use. The default key_size is chosen
...
...
activesupport/lib/active_support/notifications/fanout.rb
浏览文件 @
1bf3cecf
require
'mutex_m'
require
'
thread_safe
'
require
'
concurrent
'
module
ActiveSupport
module
Notifications
...
...
@@ -12,7 +12,7 @@ class Fanout
def
initialize
@subscribers
=
[]
@listeners_for
=
ThreadSafe
::
Cache
.
new
@listeners_for
=
Concurrent
::
Map
.
new
super
end
...
...
@@ -51,7 +51,7 @@ def publish(name, *args)
end
def
listeners_for
(
name
)
# this is correctly done double-checked locking (
ThreadSafe::Cache
's lookups have volatile semantics)
# this is correctly done double-checked locking (
Concurrent::Map
's lookups have volatile semantics)
@listeners_for
[
name
]
||
synchronize
do
# use synchronisation when accessing @subscribers
@listeners_for
[
name
]
||=
@subscribers
.
select
{
|
s
|
s
.
subscribed_to?
(
name
)
}
...
...
activesupport/lib/active_support/values/time_zone.rb
浏览文件 @
1bf3cecf
require
'tzinfo'
require
'
thread_safe
'
require
'
concurrent
'
require
'active_support/core_ext/object/blank'
require
'active_support/core_ext/object/try'
...
...
@@ -189,7 +189,7 @@ class TimeZone
UTC_OFFSET_WITH_COLON
=
'%s%02d:%02d'
UTC_OFFSET_WITHOUT_COLON
=
UTC_OFFSET_WITH_COLON
.
tr
(
':'
,
''
)
@lazy_zones_map
=
ThreadSafe
::
Cache
.
new
@lazy_zones_map
=
Concurrent
::
Map
.
new
class
<<
self
# Assumes self represents an offset from UTC in seconds (as returned from
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录