rev 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -8,6 +8,10 @@ if have_func('rb_thread_blocking_region')
8
8
  $defs << '-DHAVE_RB_THREAD_BLOCKING_REGION'
9
9
  end
10
10
 
11
+ if have_func('rb_thread_alone')
12
+ $defs << '-DHAVE_RB_THREAD_ALONE'
13
+ end
14
+
11
15
  if have_func('rb_str_set_len')
12
16
  $defs << '-DHAVE_RB_STR_SET_LEN'
13
17
  end
@@ -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
- assert(loop_data->ev_loop && !loop_data->events_received);
184
-
185
- Rev_Loop_ev_loop_oneshot(loop_data);
186
- Rev_Loop_dispatch_events(loop_data);
187
-
188
- nevents = INT2NUM(loop_data->events_received);
189
- loop_data->events_received = 0;
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
@@ -23,6 +23,6 @@ require 'iobuffer'
23
23
  end
24
24
 
25
25
  module Rev
26
- Rev::VERSION = '0.3.1' unless defined? Rev::VERSION
26
+ Rev::VERSION = '0.3.2' unless defined? Rev::VERSION
27
27
  def self.version() VERSION end
28
28
  end
@@ -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
- @reader.read 1
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
@@ -5,13 +5,13 @@
5
5
  #++
6
6
 
7
7
  module Rev
8
- class IOWatcher
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 :timer_watcher
15
+ event_callback :on_timer
16
16
  end
17
17
  end
@@ -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.1"
5
+ s.version = "0.3.2"
6
6
  s.authors = "Tony Arcieri"
7
7
  s.email = "tony@medioh.com"
8
- s.date = "2009-10-13"
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.0"
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.1
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-10-13 00:00:00 -06:00
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.0
23
+ version: 0.1.3
24
24
  version:
25
25
  description:
26
26
  email: tony@medioh.com