pubsub 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pubsub/pubsub.rb +22 -1
- metadata +15 -135
- data/.autotest +0 -1
- data/.document +0 -5
- data/.rspec +0 -2
- data/Gemfile +0 -14
- data/Gemfile.lock +0 -36
- data/LICENSE.txt +0 -20
- data/VERSION +0 -1
- data/autotest/discover.rb +0 -1
data/lib/pubsub/pubsub.rb
CHANGED
@@ -33,6 +33,12 @@ module PubSub
|
|
33
33
|
logger.info "Add to publish queue #{self.class.name} to #{channel} with #{args.to_s}"
|
34
34
|
PubSub.queue.push({:sender => self, :channel => channel, :params => args})
|
35
35
|
PubSub.thread.wakeup if PubSub.thread.status == "sleep"
|
36
|
+
if PubSub.queue.count > PubSub.queue_size
|
37
|
+
#puts "Mutex sleep, queue length #{PubSub.queue.count}"
|
38
|
+
PubSub.waiting.push Thread.current
|
39
|
+
mutex.sleep
|
40
|
+
end
|
41
|
+
|
36
42
|
end
|
37
43
|
end
|
38
44
|
|
@@ -45,7 +51,10 @@ module PubSub
|
|
45
51
|
break
|
46
52
|
end
|
47
53
|
|
48
|
-
|
54
|
+
if PubSub.queue.empty?
|
55
|
+
PubSub.waiting.push.each {|thread| thread.wakeup }
|
56
|
+
sleep
|
57
|
+
end
|
49
58
|
|
50
59
|
unless PubSub.queue.empty?
|
51
60
|
publish_info = PubSub.queue.shift
|
@@ -96,6 +105,18 @@ module PubSub
|
|
96
105
|
channel_handlers[channel].delete_if {|stored_event| stored_event == proc} if channel_handlers.include? channel
|
97
106
|
end
|
98
107
|
|
108
|
+
def PubSub.queue_size
|
109
|
+
@@queue_size ||= 100
|
110
|
+
end
|
111
|
+
|
112
|
+
def PubSub.queue_size=(value)
|
113
|
+
@@queue_size = value
|
114
|
+
end
|
115
|
+
|
116
|
+
def PubSub.waiting
|
117
|
+
@@waiting ||= []
|
118
|
+
end
|
119
|
+
|
99
120
|
def PubSub.thread
|
100
121
|
@@thread ||= Thread.current
|
101
122
|
end
|
metadata
CHANGED
@@ -1,171 +1,56 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubsub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
prerelease: false
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Max Kazarin
|
13
|
-
autorequire:
|
9
|
+
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
date: 2011-07-25 00:00:00.
|
17
|
-
default_executable: !!null
|
12
|
+
date: 2011-07-25 00:00:00.000000000Z
|
18
13
|
dependencies:
|
19
14
|
- !ruby/object:Gem::Dependency
|
20
15
|
name: ruby_events
|
21
|
-
requirement: &
|
16
|
+
requirement: &7627720 !ruby/object:Gem::Requirement
|
22
17
|
none: false
|
23
18
|
requirements:
|
24
19
|
- - ! '>='
|
25
20
|
- !ruby/object:Gem::Version
|
26
21
|
version: '0'
|
27
|
-
segments:
|
28
|
-
- 0
|
29
22
|
type: :runtime
|
30
23
|
prerelease: false
|
31
|
-
version_requirements: *
|
32
|
-
- !ruby/object:Gem::Dependency
|
33
|
-
name: shoulda
|
34
|
-
requirement: &24510180 !ruby/object:Gem::Requirement
|
35
|
-
none: false
|
36
|
-
requirements:
|
37
|
-
- - ! '>='
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '0'
|
40
|
-
segments:
|
41
|
-
- 0
|
42
|
-
type: :development
|
43
|
-
prerelease: false
|
44
|
-
version_requirements: *24510180
|
45
|
-
- !ruby/object:Gem::Dependency
|
46
|
-
name: bundler
|
47
|
-
requirement: &24494060 !ruby/object:Gem::Requirement
|
48
|
-
none: false
|
49
|
-
requirements:
|
50
|
-
- - ! '>='
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: 1.0.0
|
53
|
-
segments:
|
54
|
-
- 1
|
55
|
-
- 0
|
56
|
-
- 0
|
57
|
-
type: :development
|
58
|
-
prerelease: false
|
59
|
-
version_requirements: *24494060
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
|
-
name: jeweler
|
62
|
-
requirement: &24493280 !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
|
-
requirements:
|
65
|
-
- - ~>
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: 1.6.4
|
68
|
-
segments:
|
69
|
-
- 1
|
70
|
-
- 6
|
71
|
-
- 4
|
72
|
-
type: :development
|
73
|
-
prerelease: false
|
74
|
-
version_requirements: *24493280
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: rcov
|
77
|
-
requirement: &24492440 !ruby/object:Gem::Requirement
|
78
|
-
none: false
|
79
|
-
requirements:
|
80
|
-
- - ! '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
segments:
|
84
|
-
- 0
|
85
|
-
type: :development
|
86
|
-
prerelease: false
|
87
|
-
version_requirements: *24492440
|
24
|
+
version_requirements: *7627720
|
88
25
|
- !ruby/object:Gem::Dependency
|
89
26
|
name: rspec
|
90
|
-
requirement: &
|
27
|
+
requirement: &7627180 !ruby/object:Gem::Requirement
|
91
28
|
none: false
|
92
29
|
requirements:
|
93
|
-
- -
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '0'
|
96
|
-
segments:
|
97
|
-
- 0
|
98
|
-
type: :development
|
99
|
-
prerelease: false
|
100
|
-
version_requirements: *24491780
|
101
|
-
- !ruby/object:Gem::Dependency
|
102
|
-
name: ZenTest
|
103
|
-
requirement: &24491040 !ruby/object:Gem::Requirement
|
104
|
-
none: false
|
105
|
-
requirements:
|
106
|
-
- - ! '>='
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
version: '0'
|
109
|
-
segments:
|
110
|
-
- 0
|
111
|
-
type: :development
|
112
|
-
prerelease: false
|
113
|
-
version_requirements: *24491040
|
114
|
-
- !ruby/object:Gem::Dependency
|
115
|
-
name: autotest-growl
|
116
|
-
requirement: &24490380 !ruby/object:Gem::Requirement
|
117
|
-
none: false
|
118
|
-
requirements:
|
119
|
-
- - ! '>='
|
30
|
+
- - ~>
|
120
31
|
- !ruby/object:Gem::Version
|
121
|
-
version:
|
122
|
-
segments:
|
123
|
-
- 0
|
32
|
+
version: 2.6.0
|
124
33
|
type: :development
|
125
34
|
prerelease: false
|
126
|
-
version_requirements: *
|
127
|
-
- !ruby/object:Gem::Dependency
|
128
|
-
name: ruby_events
|
129
|
-
requirement: &24489660 !ruby/object:Gem::Requirement
|
130
|
-
none: false
|
131
|
-
requirements:
|
132
|
-
- - ! '>='
|
133
|
-
- !ruby/object:Gem::Version
|
134
|
-
version: '0'
|
135
|
-
segments:
|
136
|
-
- 0
|
137
|
-
type: :runtime
|
138
|
-
prerelease: false
|
139
|
-
version_requirements: *24489660
|
35
|
+
version_requirements: *7627180
|
140
36
|
description: PubSub pattern
|
141
37
|
email: maxkazargm@gmail.com
|
142
38
|
executables: []
|
143
39
|
extensions: []
|
144
40
|
extra_rdoc_files:
|
145
|
-
- LICENSE.txt
|
146
41
|
- README.rdoc
|
147
42
|
files:
|
148
|
-
- .autotest
|
149
|
-
- .document
|
150
|
-
- .rspec
|
151
|
-
- Gemfile
|
152
|
-
- Gemfile.lock
|
153
|
-
- LICENSE.txt
|
154
43
|
- README.rdoc
|
155
44
|
- Rakefile
|
156
|
-
- VERSION
|
157
|
-
- autotest/discover.rb
|
158
45
|
- lib/pubsub.rb
|
159
46
|
- lib/pubsub/logger.rb
|
160
47
|
- lib/pubsub/pubsub.rb
|
161
48
|
- lib/pubsub/string.rb
|
162
49
|
- spec/pubsup_spec.rb
|
163
50
|
- spec/spec_helper.rb
|
164
|
-
has_rdoc: true
|
165
51
|
homepage: http://github.com/maxkazar/pubsub
|
166
|
-
licenses:
|
167
|
-
|
168
|
-
post_install_message: !!null
|
52
|
+
licenses: []
|
53
|
+
post_install_message:
|
169
54
|
rdoc_options: []
|
170
55
|
require_paths:
|
171
56
|
- lib
|
@@ -175,21 +60,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
175
60
|
- - ! '>='
|
176
61
|
- !ruby/object:Gem::Version
|
177
62
|
version: '0'
|
178
|
-
segments:
|
179
|
-
- 0
|
180
|
-
hash: -2395597313828472709
|
181
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
64
|
none: false
|
183
65
|
requirements:
|
184
66
|
- - ! '>='
|
185
67
|
- !ruby/object:Gem::Version
|
186
68
|
version: '0'
|
187
|
-
segments:
|
188
|
-
- 0
|
189
69
|
requirements: []
|
190
|
-
rubyforge_project:
|
191
|
-
rubygems_version: 1.
|
192
|
-
signing_key:
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.8.5
|
72
|
+
signing_key:
|
193
73
|
specification_version: 3
|
194
74
|
summary: PubSub pattern
|
195
75
|
test_files: []
|
data/.autotest
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'autotest/growl'
|
data/.document
DELETED
data/.rspec
DELETED
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
ZenTest (4.6.0)
|
5
|
-
autotest-growl (0.2.9)
|
6
|
-
diff-lcs (1.1.2)
|
7
|
-
git (1.2.5)
|
8
|
-
jeweler (1.6.4)
|
9
|
-
bundler (~> 1.0)
|
10
|
-
git (>= 1.2.5)
|
11
|
-
rake
|
12
|
-
rake (0.9.2)
|
13
|
-
rcov (0.9.9)
|
14
|
-
rspec (2.6.0)
|
15
|
-
rspec-core (~> 2.6.0)
|
16
|
-
rspec-expectations (~> 2.6.0)
|
17
|
-
rspec-mocks (~> 2.6.0)
|
18
|
-
rspec-core (2.6.4)
|
19
|
-
rspec-expectations (2.6.0)
|
20
|
-
diff-lcs (~> 1.1.2)
|
21
|
-
rspec-mocks (2.6.0)
|
22
|
-
ruby_events (1.1.0)
|
23
|
-
shoulda (2.11.3)
|
24
|
-
|
25
|
-
PLATFORMS
|
26
|
-
ruby
|
27
|
-
|
28
|
-
DEPENDENCIES
|
29
|
-
ZenTest
|
30
|
-
autotest-growl
|
31
|
-
bundler (>= 1.0.0)
|
32
|
-
jeweler (~> 1.6.4)
|
33
|
-
rcov
|
34
|
-
rspec
|
35
|
-
ruby_events
|
36
|
-
shoulda
|
data/LICENSE.txt
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2011 Max Kazarin
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.0.2
|
data/autotest/discover.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Autotest.add_discovery { "rspec2" }
|