rubysl-thwait 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 40906ea355b3bfdfa40b94426b8b51aba99e5936
4
- data.tar.gz: 09a29ae3102328fa032ada0cdb9764ee4cf66acc
5
- SHA512:
6
- metadata.gz: 3bd3b46c121211699a4a90738f49d22525eaa11be9cbfcee811ce4c22c339a451a70e447745000ffa0ab76f75ea606851ec56724afb01b90f5b49917ac159011
7
- data.tar.gz: a7e449b7ff975b48e2f8471455090e223ce5bcc3ae4dfd7c475246a24781391061bb9c173c8d51a3bab8fecd7981bfd49b631a23a4dfd679741481ca7e48b35e
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NGU5YmNiNTg3NWZmZjQ0NjE5M2M1M2JkYmQwNjZmMjlkMWIxYmRjOA==
5
+ data.tar.gz: !binary |-
6
+ ZTI4NTE5ODAwMWQ5NTIyYjVhN2U1Mjk4YTQ3ZDljZmJiN2M5Njg3OQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NmI2ZDdlMmY1ZTlmYWMyYmQ3Y2ViNGM3YmFjMjRmZGZlMmRiMjRjMGU3Y2My
10
+ Yjg4YTgzNDNhNzA4ZmE5NzZjNWM4YmE3MzE3MTBkMjQ1MzQ4ZGMwNTkzNGEw
11
+ ZGQ3NzJiYTQwMGJkMWYzNGZkOGU4ZDljN2I0MjYyNzMzYzgwOTU=
12
+ data.tar.gz: !binary |-
13
+ NzZmN2Q1MTBjMTYxMzBlNjdhMGQwNjgzYTg3ODliODZlMTY2ZWQ0MGE0Mjg1
14
+ Y2JkNWFhZmUwOTNmMGZkOWZmYTU2NjM5ZjhiODM1NDY2MGFmM2I3N2MwMjI1
15
+ MTE2M2FiNjY3MjNiNjEwNjkwNjZlYzBhOWY4NTE2Y2RiMzNlNmM=
@@ -1,8 +1,7 @@
1
1
  language: ruby
2
- before_install:
3
- - gem update --system
4
- - gem --version
5
- - gem install rubysl-bundler
6
- script: bundle exec mspec spec
2
+ env:
3
+ - RUBYLIB=lib
4
+ script: bundle exec mspec
7
5
  rvm:
8
- - rbx-nightly-18mode
6
+ - 1.9.3
7
+ - rbx-nightly-19mode
@@ -1,42 +1,11 @@
1
1
  #
2
2
  # thwait.rb - thread synchronization class
3
- # $Release Version: 0.9 $
4
- # $Revision: 1.3 $
5
- # $Date: 1998/06/26 03:19:34 $
6
- # by Keiju ISHITSUKA(Nihpon Rational Software Co.,Ltd.)
7
- # modernized by Evan Phoenix - 2011
8
- # --
9
- # feature:
10
- # provides synchronization for multiple threads.
11
- #
12
- # class methods:
13
- # * ThreadsWait.all_waits(thread1,...)
14
- # waits until all of specified threads are terminated.
15
- # if a block is supplied for the method, evaluates it for
16
- # each thread termination.
17
- # * th = ThreadsWait.new(thread1,...)
18
- # creates synchronization object, specifying thread(s) to wait.
19
- #
20
- # methods:
21
- # * th.threads
22
- # list threads to be synchronized
23
- # * th.empty?
24
- # is there any thread to be synchronized.
25
- # * th.finished?
26
- # is there already terminated thread.
27
- # * th.join(thread1,...)
28
- # wait for specified thread(s).
29
- # * th.join_nowait(threa1,...)
30
- # specifies thread(s) to wait. non-blocking.
31
- # * th.next_wait
32
- # waits until any of specified threads is terminated.
33
- # * th.all_waits
34
- # waits until all of specified threads are terminated.
35
- # if a block is supplied for the method, evaluates it for
36
- # each thread termination.
37
- #
3
+ # $Release Version: 0.9 $
4
+ # $Revision: 1.3 $
5
+ # by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd.)
38
6
 
39
- require "thread"
7
+ require "thread.rb"
8
+ require "e2mmap.rb"
40
9
 
41
10
  #
42
11
  # This class watches for termination of multiple threads. Basic functionality
@@ -46,22 +15,25 @@ require "thread"
46
15
  #
47
16
  # Example:
48
17
  #
49
- # ThreadsWait.all_waits(thr1, thr2, ...) do |t|
18
+ # ThreadsWait.all_wait(thr1, thr2, ...) do |t|
50
19
  # STDERR.puts "Thread #{t} has terminated."
51
20
  # end
52
21
  #
22
+ #
23
+ # th = ThreadsWait.new(thread1,...)
24
+ # th.next_wait # next one to be done
25
+ #
26
+ #
53
27
  class ThreadsWait
54
- RCS_ID='-$Id: thwait.rb:git 1.4 2011/01/24 00:00:00 evan $-'
55
-
56
- class ErrNoWaitingThread < StandardError
57
- end
28
+ RCS_ID='-$Id: thwait.rb,v 1.3 1998/06/26 03:19:34 keiju Exp keiju $-'
58
29
 
59
- class ErrNoFinishedThread < StandardError
60
- end
30
+ extend Exception2MessageMapper
31
+ def_exception("ErrNoWaitingThread", "No threads for waiting.")
32
+ def_exception("ErrNoFinishedThread", "No finished threads.")
61
33
 
62
34
  #
63
35
  # Waits until all specified threads have terminated. If a block is provided,
64
- # it is executed for each thread termination.
36
+ # it is executed for each thread as they terminate.
65
37
  #
66
38
  def ThreadsWait.all_waits(*threads) # :yield: thread
67
39
  tw = ThreadsWait.new(*threads)
@@ -73,7 +45,7 @@ class ThreadsWait
73
45
  tw.all_waits
74
46
  end
75
47
  end
76
-
48
+
77
49
  #
78
50
  # Creates a ThreadsWait object, specifying the threads to wait on.
79
51
  # Non-blocking.
@@ -83,32 +55,33 @@ class ThreadsWait
83
55
  @wait_queue = Queue.new
84
56
  join_nowait(*threads) unless threads.empty?
85
57
  end
86
-
87
- # Returns the array of threads in the wait queue.
88
- attr_reader :threads
89
-
58
+
59
+ # Returns the array of threads that have not terminated yet.
60
+ attr :threads
61
+
90
62
  #
91
- # Returns +true+ if there are no threads to be synchronized.
63
+ # Returns +true+ if there are no threads in the pool still running.
92
64
  #
93
65
  def empty?
94
66
  @threads.empty?
95
67
  end
96
-
68
+
97
69
  #
98
- # Returns +true+ if any thread has terminated.
70
+ # Returns +true+ if any thread has terminated and is ready to be collected.
99
71
  #
100
72
  def finished?
101
73
  !@wait_queue.empty?
102
74
  end
103
-
75
+
104
76
  #
105
- # Waits for specified threads to terminate.
77
+ # Waits for specified threads to terminate, and returns when one of
78
+ # the threads terminated.
106
79
  #
107
80
  def join(*threads)
108
81
  join_nowait(*threads)
109
82
  next_wait
110
83
  end
111
-
84
+
112
85
  #
113
86
  # Specifies the threads that this object will wait for, but does not actually
114
87
  # wait.
@@ -116,8 +89,7 @@ class ThreadsWait
116
89
  def join_nowait(*threads)
117
90
  threads.flatten!
118
91
  @threads.concat threads
119
-
120
- threads.each do |th|
92
+ for th in threads
121
93
  Thread.start(th) do |t|
122
94
  begin
123
95
  t.join
@@ -127,27 +99,24 @@ class ThreadsWait
127
99
  end
128
100
  end
129
101
  end
130
-
102
+
131
103
  #
132
104
  # Waits until any of the specified threads has terminated, and returns the one
133
105
  # that does.
134
106
  #
135
- # If there are no pending threads to wait for, raises +ErrNoWaitingThread+.
136
- # If +nonblock+ is true and there is no terminated thread,
137
- # raises +ErrNoFinishedThread+.
107
+ # If there is no thread to wait, raises +ErrNoWaitingThread+. If +nonblock+
108
+ # is true, and there is no terminated thread, raises +ErrNoFinishedThread+.
138
109
  #
139
- def next_wait(nonblock=nil)
140
- raise ErrNoWaitingThread, "No threads for waiting" if @threads.empty?
141
-
110
+ def next_wait(nonblock = nil)
111
+ ThreadsWait.fail ErrNoWaitingThread if @threads.empty?
142
112
  begin
143
- th = @wait_queue.pop(nonblock)
144
- @threads.delete th
145
- return th
113
+ @threads.delete(th = @wait_queue.pop(nonblock))
114
+ th
146
115
  rescue ThreadError
147
- raise ErrNoFinishedThread, "No finished threads"
116
+ ThreadsWait.fail ErrNoFinishedThread
148
117
  end
149
118
  end
150
-
119
+
151
120
  #
152
121
  # Waits until all of the specified threads are terminated. If a block is
153
122
  # supplied for the method, it is executed for each thread termination.
@@ -162,7 +131,8 @@ class ThreadsWait
162
131
  end
163
132
  end
164
133
 
165
- # deprecated alias
134
+ ##
135
+ # An alias for ThreadsWait from thwait.rb
166
136
 
167
137
  ThWait = ThreadsWait
168
138
 
@@ -170,6 +140,3 @@ ThWait = ThreadsWait
170
140
  # - Source of documentation is evenly split between Nutshell, existing
171
141
  # comments, and my own rephrasing.
172
142
  # - I'm not particularly confident that the comments are all exactly correct.
173
- # - The history, etc., up the top appears in the RDoc output. Perhaps it would
174
- # be better to direct that not to appear, and put something else there
175
- # instead.
@@ -1,5 +1,5 @@
1
1
  module RubySL
2
2
  module ThreadsWait
3
- VERSION = "1.0.0"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -16,12 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ["lib"]
18
18
 
19
- spec.required_ruby_version = "~> 1.8.7"
20
-
21
- spec.add_runtime_dependency "rubysl-thread", "~> 1.0"
22
-
23
19
  spec.add_development_dependency "bundler", "~> 1.3"
24
20
  spec.add_development_dependency "rake", "~> 10.0"
25
21
  spec.add_development_dependency "mspec", "~> 1.5"
26
- spec.add_development_dependency "rubysl-prettyprint", "~> 1.0"
27
22
  end
metadata CHANGED
@@ -1,30 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubysl-thwait
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Shirai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-14 00:00:00.000000000 Z
11
+ date: 2013-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rubysl-thread
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
- type: :runtime
21
14
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ~>
25
- - !ruby/object:Gem::Version
26
- version: '1.0'
27
- - !ruby/object:Gem::Dependency
28
15
  name: bundler
29
16
  requirement: !ruby/object:Gem::Requirement
30
17
  requirements:
@@ -32,13 +19,13 @@ dependencies:
32
19
  - !ruby/object:Gem::Version
33
20
  version: '1.3'
34
21
  type: :development
35
- prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - ~>
39
25
  - !ruby/object:Gem::Version
40
26
  version: '1.3'
41
27
  - !ruby/object:Gem::Dependency
28
+ prerelease: false
42
29
  name: rake
43
30
  requirement: !ruby/object:Gem::Requirement
44
31
  requirements:
@@ -46,13 +33,13 @@ dependencies:
46
33
  - !ruby/object:Gem::Version
47
34
  version: '10.0'
48
35
  type: :development
49
- prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - ~>
53
39
  - !ruby/object:Gem::Version
54
40
  version: '10.0'
55
41
  - !ruby/object:Gem::Dependency
42
+ prerelease: false
56
43
  name: mspec
57
44
  requirement: !ruby/object:Gem::Requirement
58
45
  requirements:
@@ -60,26 +47,11 @@ dependencies:
60
47
  - !ruby/object:Gem::Version
61
48
  version: '1.5'
62
49
  type: :development
63
- prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - ~>
67
53
  - !ruby/object:Gem::Version
68
54
  version: '1.5'
69
- - !ruby/object:Gem::Dependency
70
- name: rubysl-prettyprint
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ~>
74
- - !ruby/object:Gem::Version
75
- version: '1.0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ~>
81
- - !ruby/object:Gem::Version
82
- version: '1.0'
83
55
  description: Ruby standard library threads_wait.
84
56
  email:
85
57
  - brixen@gmail.com
@@ -108,19 +80,20 @@ require_paths:
108
80
  - lib
109
81
  required_ruby_version: !ruby/object:Gem::Requirement
110
82
  requirements:
111
- - - ~>
83
+ - - ! '>='
112
84
  - !ruby/object:Gem::Version
113
- version: 1.8.7
85
+ version: !binary |-
86
+ MA==
114
87
  required_rubygems_version: !ruby/object:Gem::Requirement
115
88
  requirements:
116
- - - '>='
89
+ - - ! '>='
117
90
  - !ruby/object:Gem::Version
118
- version: '0'
91
+ version: !binary |-
92
+ MA==
119
93
  requirements: []
120
94
  rubyforge_project:
121
- rubygems_version: 2.0.7
95
+ rubygems_version: 2.0.6
122
96
  signing_key:
123
97
  specification_version: 4
124
98
  summary: Ruby standard library threads_wait.
125
99
  test_files: []
126
- has_rdoc: