~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to lib/mutex_m.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2011-09-24 19:16:17 UTC
  • mfrom: (1.1.8 upstream) (13.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20110924191617-o1qz4rcmqjot8zuy
Tags: 1.9.3~rc1-1
* New upstream release: 1.9.3 RC1.
  + Includes load.c fixes. Closes: #639959.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#
2
2
#   mutex_m.rb -
3
 
#       $Release Version: 3.0$
4
 
#       $Revision: 1.7 $
 
3
#       $Release Version: 3.0$
 
4
#       $Revision: 1.7 $
5
5
#       Original from mutex.rb
6
 
#       by Keiju ISHITSUKA(keiju@ishitsuka.com)
 
6
#       by Keiju ISHITSUKA(keiju@ishitsuka.com)
7
7
#       modified by matz
8
8
#       patched by akira yamada
9
9
#
10
10
# --
11
11
#   Usage:
12
 
#       require "mutex_m.rb"
13
 
#       obj = Object.new
14
 
#       obj.extend Mutex_m
15
 
#       ...
16
 
#       extended object can be handled like Mutex
 
12
#       require "mutex_m.rb"
 
13
#       obj = Object.new
 
14
#       obj.extend Mutex_m
 
15
#       ...
 
16
#       extended object can be handled like Mutex
17
17
#       or
18
 
#       class Foo
19
 
#         include Mutex_m
20
 
#         ...
21
 
#       end
22
 
#       obj = Foo.new
23
 
#       this obj can be handled like Mutex
 
18
#       class Foo
 
19
#         include Mutex_m
 
20
#         ...
 
21
#       end
 
22
#       obj = Foo.new
 
23
#       this obj can be handled like Mutex
24
24
#
25
25
 
26
26
require 'thread'
48
48
 
49
49
  def mu_extended
50
50
    unless (defined? locked? and
51
 
            defined? lock and
52
 
            defined? unlock and
53
 
            defined? try_lock and
54
 
            defined? synchronize)
 
51
            defined? lock and
 
52
            defined? unlock and
 
53
            defined? try_lock and
 
54
            defined? synchronize)
55
55
      Mutex_m.define_aliases(singleton_class)
56
56
    end
57
57
    mu_initialize
78
78
    @_mutex.unlock
79
79
  end
80
80
 
 
81
  def sleep(timeout = nil)
 
82
    @_mutex.sleep(timeout)
 
83
  end
 
84
 
81
85
  private
82
86
 
83
87
  def mu_initialize