rev 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +10 -0
- data/ext/rev/extconf.rb +4 -0
- data/ext/rev/rev_loop.c +28 -11
- data/lib/rev.rb +1 -1
- data/lib/rev/async_watcher.rb +6 -1
- data/lib/rev/timer_watcher.rb +2 -2
- data/rev.gemspec +3 -3
- metadata +3 -3
data/CHANGES
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
0.3.2:
|
2
|
+
|
3
|
+
* Perform a blocking system call if we're the only thread running (1.8 only)
|
4
|
+
|
5
|
+
* Run in non-blocking mode if we're the only thread in the process (1.8 only)
|
6
|
+
|
7
|
+
* Make Rev::Loop#run_nonblock signal-safe
|
8
|
+
|
9
|
+
* Fix spurious firing of Rev::AsyncWatchers
|
10
|
+
|
1
11
|
0.3.1:
|
2
12
|
|
3
13
|
* Configurable intervals for Rev::StatWatcher
|
data/ext/rev/extconf.rb
CHANGED
data/ext/rev/rev_loop.c
CHANGED
@@ -12,6 +12,14 @@
|
|
12
12
|
|
13
13
|
#include "rev.h"
|
14
14
|
|
15
|
+
#if defined(HAVE_RB_THREAD_BLOCKING_REGION)
|
16
|
+
# define Rev_Loop_may_block_safely() (1)
|
17
|
+
#elif defined(HAVE_RB_THREAD_ALONE)
|
18
|
+
# define Rev_Loop_may_block_safely() (rb_thread_alone())
|
19
|
+
#else /* just in case Ruby changes: */
|
20
|
+
# define Rev_Loop_may_block_safely() (0)
|
21
|
+
#endif
|
22
|
+
|
15
23
|
static VALUE mRev = Qnil;
|
16
24
|
static VALUE cRev_Loop = Qnil;
|
17
25
|
|
@@ -175,19 +183,26 @@ void Rev_Loop_process_event(VALUE watcher, int revents)
|
|
175
183
|
*/
|
176
184
|
static VALUE Rev_Loop_run_once(VALUE self)
|
177
185
|
{
|
178
|
-
struct Rev_Loop *loop_data;
|
179
186
|
VALUE nevents;
|
180
|
-
|
181
|
-
Data_Get_Struct(self, struct Rev_Loop, loop_data);
|
182
187
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
188
|
+
if (Rev_Loop_may_block_safely()) {
|
189
|
+
struct Rev_Loop *loop_data;
|
190
|
+
|
191
|
+
Data_Get_Struct(self, struct Rev_Loop, loop_data);
|
192
|
+
|
193
|
+
assert(loop_data->ev_loop && !loop_data->events_received);
|
194
|
+
|
195
|
+
Rev_Loop_ev_loop_oneshot(loop_data);
|
196
|
+
Rev_Loop_dispatch_events(loop_data);
|
197
|
+
|
198
|
+
nevents = INT2NUM(loop_data->events_received);
|
199
|
+
loop_data->events_received = 0;
|
200
|
+
|
201
|
+
} else {
|
202
|
+
nevents = Rev_Loop_run_nonblock(self);
|
203
|
+
rb_thread_schedule();
|
204
|
+
}
|
205
|
+
|
191
206
|
return nevents;
|
192
207
|
}
|
193
208
|
|
@@ -260,7 +275,9 @@ static VALUE Rev_Loop_run_nonblock(VALUE self)
|
|
260
275
|
|
261
276
|
assert(loop_data->ev_loop && !loop_data->events_received);
|
262
277
|
|
278
|
+
TRAP_BEG;
|
263
279
|
RUN_LOOP(loop_data, EVLOOP_NONBLOCK);
|
280
|
+
TRAP_END;
|
264
281
|
Rev_Loop_dispatch_events(loop_data);
|
265
282
|
|
266
283
|
nevents = INT2NUM(loop_data->events_received);
|
data/lib/rev.rb
CHANGED
data/lib/rev/async_watcher.rb
CHANGED
@@ -31,7 +31,12 @@ module Rev
|
|
31
31
|
def on_readable
|
32
32
|
# Read a byte from the pipe. This clears readability, unless
|
33
33
|
# another signal is pending
|
34
|
-
|
34
|
+
begin
|
35
|
+
@reader.read_nonblock 1
|
36
|
+
rescue Errno::EAGAIN
|
37
|
+
# in case there are spurious wakeups from forked processs
|
38
|
+
return
|
39
|
+
end
|
35
40
|
on_signal
|
36
41
|
end
|
37
42
|
end
|
data/lib/rev/timer_watcher.rb
CHANGED
@@ -5,13 +5,13 @@
|
|
5
5
|
#++
|
6
6
|
|
7
7
|
module Rev
|
8
|
-
class
|
8
|
+
class TimerWatcher
|
9
9
|
# The actual implementation of this class resides in the C extension
|
10
10
|
# Here we metaprogram proper event_callbacks for the callback methods
|
11
11
|
# These can take a block and store it to be called when the event
|
12
12
|
# is actually fired.
|
13
13
|
|
14
14
|
extend Meta
|
15
|
-
event_callback :
|
15
|
+
event_callback :on_timer
|
16
16
|
end
|
17
17
|
end
|
data/rev.gemspec
CHANGED
@@ -2,10 +2,10 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
GEMSPEC = Gem::Specification.new do |s|
|
4
4
|
s.name = "rev"
|
5
|
-
s.version = "0.3.
|
5
|
+
s.version = "0.3.2"
|
6
6
|
s.authors = "Tony Arcieri"
|
7
7
|
s.email = "tony@medioh.com"
|
8
|
-
s.date = "2009-
|
8
|
+
s.date = "2009-11-28"
|
9
9
|
s.summary = "Rev is a Ruby binding to the libev high performance event library"
|
10
10
|
s.platform = Gem::Platform::RUBY
|
11
11
|
s.required_ruby_version = '>= 1.8.6'
|
@@ -14,7 +14,7 @@ GEMSPEC = Gem::Specification.new do |s|
|
|
14
14
|
s.files = Dir.glob("{lib,ext,examples}/**/*") + ['Rakefile', 'rev.gemspec']
|
15
15
|
|
16
16
|
# Dependencies
|
17
|
-
s.add_dependency "iobuffer", ">= 0.1.
|
17
|
+
s.add_dependency "iobuffer", ">= 0.1.3"
|
18
18
|
|
19
19
|
# RubyForge info
|
20
20
|
s.homepage = "http://rev.rubyforge.org"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rev
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Arcieri
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-28 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.1.
|
23
|
+
version: 0.1.3
|
24
24
|
version:
|
25
25
|
description:
|
26
26
|
email: tony@medioh.com
|