aboutsummaryrefslogtreecommitdiffstats
path: root/core/plugin.rb
diff options
context:
space:
mode:
authortoshi <toshi@03aab468-d3d2-4883-8b12-f661bbf03fa8>2012-03-20 16:26:00 +0000
committertoshi <toshi@03aab468-d3d2-4883-8b12-f661bbf03fa8>2012-03-20 16:26:00 +0000
commit4676aecf38532483ecc33ac5180d63b5042097f8 (patch)
tree07c34dca135fa82d725101ee9bb376808cd6706d /core/plugin.rb
parentae993e14d8a46bb93f1ae26d2ae574d85ab0fed0 (diff)
downloadmikutter-4676aecf38532483ecc33ac5180d63b5042097f8.tar.gz
処理を適当に切り分けて少しづつループする Enumerable#deach を追加。長時間UIスレッドを使ってしまうループでこれを使うようにした
git-svn-id: svn://toshia.dip.jp/mikutter/trunk@715 03aab468-d3d2-4883-8b12-f661bbf03fa8
Diffstat (limited to 'core/plugin.rb')
-rw-r--r--core/plugin.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/core/plugin.rb b/core/plugin.rb
index b595bd95..c5fb2dc0 100644
--- a/core/plugin.rb
+++ b/core/plugin.rb
@@ -258,7 +258,16 @@ class Plugin
# plugin_loopの簡略化版。プラグインに引数 _args_ をそのまま渡して呼び出す
def plugin_callback_loop(ary, event_name, kind, *args)
plugin_loop(ary, event_name, kind){ |tag, proc|
- proc.call(*args){ throw(:plugin_exit) } } end
+ if Mopt.debug
+ r_start = Process.times.utime
+ result = proc.call(*args){ throw(:plugin_exit) }
+ if (r_end = Process.times.utime - r_start) > 0.1
+ open(File.expand_path(File.join(Environment::LOGDIR, "plugin.late.log")), "a"){ |io|
+ notice "#{r_end},#{tag.name},#{event_name},#{kind}"
+ io.puts("#{r_end},#{tag.name},#{event_name},#{kind}") } end
+ result
+ else
+ proc.call(*args){ throw(:plugin_exit) } end } end
# _ary_ [ _event\_name_ ] に登録されているプラグイン一つひとつを引数に _proc_ を繰り返し呼ぶ。
# _proc_ のシグニチャは以下の通り。
@@ -285,7 +294,8 @@ class Plugin
# ブロックの実行時間を記録しながら実行
def call_routine(plugintag, event_name, kind)
- catch(:plugin_exit){ yield } end
+ catch(:plugin_exit){ yield }
+ end
# 登録済みプラグインの一覧を返す。
# 返すHashは以下のような構造。