42件ヒット
[1-42件を表示]
(0.028秒)
ライブラリ
- forwardable (12)
- monitor (12)
-
mutex
_ m (12) - profiler (6)
キーワード
- Forwardable (12)
- MonitorMixin (12)
-
Mutex
_ m (12) -
Profiler
_ _ (6)
検索結果
-
Mutex
_ m (57.0) -
スレッド同期機構である Mutex のモジュール版です。クラスに Module#include することでそのクラスに Mutex 機能を持たせることができます。 また、普通のオブジェクトを Object#extend により Mutex にする事ができます。
...スレッド同期機構である Mutex のモジュール版です。クラスに
Module#include することでそのクラスに Mutex 機能を持たせることができます。
また、普通のオブジェクトを Object#extend により Mutex にする事ができます。
このモジ......ze,
Mutex_m#locked?, Mutex_m#try_lock, Mutex_m#unlock)
はモジュールにincludeした場合には定義されません。
1991
=== 例
クラスに Module#include する例
require "mutex_m"
class Foo
include Mutex_m
...
end
obj = Foo.new
obj.synchronize do
# 危険領......スレッド同期機構である Thread::Mutex のモジュール版です。クラスに
Module#include することでそのクラスに Mutex 機能を持たせることができます。
また、普通のオブジェクトを Object#extend により Mutex にする事ができます。
この... -
Profiler
_ _ (49.0) -
プロファイラの実装です。 Profiler__.start_profile 実行から、Profiler__.stop_profile までの 区間の実行コードのプロファイルを取得します。
...0.19 514 0.37 0.37 Module#method_added
6.57 1.80 0.14 1 140.00 140.00 Profiler__.start_profile
4.23 1.89 0.09 15 6.00 10.67 Kernel.extend
3.29 1.96 0.07 15 4.67 4.67 Module#extend_object
3.29 2.......0.06 28 2.14 2.86 Module#attr
1.88 2.13 0.04 19 2.11 2.11 Module#private
1.41 2.16 0.03 29 1.03 1.38 Module#include
0.94 2.18 0.02 10 2.00 4.00 Module#module_function
0.94 2.20 0.... -
MonitorMixin (37.0)
-
スレッドの同期機構としてのモニター機能を提供するモジュールです。
...スレッドの同期機構としてのモニター機能を提供するモジュールです。
クラスに Module#include したり、オブジェクトに
Object#extend したりすることでそのクラス/オブジェクトに
モニタ機能を追加します。
=== 例
//emlist[消費......//emlist[extend する例][ruby]{
require 'monitor'
buf = []
buf.extend(MonitorMixin)
//}
しかし、MonitorMixin をクラス定義の際に Module#include を使って
利用する場合は、initialize メソッドで super() か super を呼んで、初期化する必要があります。
ス......tialize は引数を受け付けないので
super ではなく super() を呼ぶ必要があります。
//emlist[include する例][ruby]{
require 'monitor'
class MyObject
include MonitorMixin
def initialize(val)
super()
@value = val
end
def to_s
synchronize {
@value.... -
Forwardable (13.0)
-
クラスに対し、メソッドの委譲機能を定義するモジュールです。
...、メソッドの委譲機能を定義するモジュールです。
=== 使い方
クラスに対して Object#extend して使います。Module#include でないところに注意して下さい。
例:
require 'forwardable'
class Foo
extend Forwardable
def_delegators("@out"...