Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
31248fe3
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,发现更多精彩内容 >>
提交
31248fe3
编写于
2月 04, 2010
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove instrument! and require thread from AS::Notifications.
上级
efa85055
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
3 addition
and
30 deletion
+3
-30
activesupport/lib/active_support/notifications.rb
activesupport/lib/active_support/notifications.rb
+1
-1
activesupport/lib/active_support/notifications/fanout.rb
activesupport/lib/active_support/notifications/fanout.rb
+1
-3
activesupport/lib/active_support/notifications/instrumenter.rb
...esupport/lib/active_support/notifications/instrumenter.rb
+0
-9
activesupport/test/notifications_test.rb
activesupport/test/notifications_test.rb
+1
-17
未找到文件。
activesupport/lib/active_support/notifications.rb
浏览文件 @
31248fe3
...
...
@@ -45,7 +45,7 @@ module Notifications
class
<<
self
attr_writer
:notifier
delegate
:publish
,
:subscribe
,
:to
=>
:notifier
delegate
:instrument
,
:
instrument!
,
:
to
=>
:instrumenter
delegate
:instrument
,
:to
=>
:instrumenter
def
notifier
@notifier
||=
Notifier
.
new
...
...
activesupport/lib/active_support/notifications/fanout.rb
浏览文件 @
31248fe3
require
'thread'
module
ActiveSupport
module
Notifications
# This is a default queue implementation that ships with Notifications. It
...
...
@@ -21,8 +19,8 @@ def publish(*args)
@subscribers
.
each
{
|
s
|
s
.
publish
(
*
args
)
}
end
# This is a sync queue, so there is not waiting.
def
wait
sleep
(
0.05
)
until
@subscribers
.
all?
(
&
:drained?
)
end
# Used for internal implementation only.
...
...
activesupport/lib/active_support/notifications/instrumenter.rb
浏览文件 @
31248fe3
...
...
@@ -20,15 +20,6 @@ def instrument(name, payload={})
result
end
# The same as instrument, but sends the notification even if the yielded
# block raises an error.
def
instrument!
(
name
,
payload
=
{})
time
=
Time
.
now
yield
(
payload
)
if
block_given?
ensure
@notifier
.
publish
(
name
,
time
,
Time
.
now
,
@id
,
payload
)
end
private
def
unique_id
SecureRandom
.
hex
(
10
)
...
...
activesupport/test/notifications_test.rb
浏览文件 @
31248fe3
...
...
@@ -67,29 +67,13 @@ def event(*args)
end
class
InstrumentationTest
<
TestCase
delegate
:instrument
,
:
instrument!
,
:
to
=>
ActiveSupport
::
Notifications
delegate
:instrument
,
:to
=>
ActiveSupport
::
Notifications
def
test_instrument_returns_block_result
assert_equal
2
,
instrument
(
:awesome
)
{
1
+
1
}
drain
end
def
test_instrument_with_bang_returns_result_even_on_failure
begin
instrument!
(
:awesome
,
:payload
=>
"notifications"
)
do
raise
"FAIL"
end
flunk
rescue
end
drain
assert_equal
1
,
@events
.
size
assert_equal
:awesome
,
@events
.
last
.
name
assert_equal
Hash
[
:payload
=>
"notifications"
],
@events
.
last
.
payload
end
def
test_instrument_yields_the_paylod_for_further_modification
assert_equal
2
,
instrument
(
:awesome
)
{
|
p
|
p
[
:result
]
=
1
+
1
}
drain
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录