Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Using a selector seems to make this whole thing work a little better.

  • Loading branch information...
commit 78bbc8bfef611cfa4285343062c778a0a53dc87a 1 parent 4dac494
Darrick Wiebe authored
Showing with 21 additions and 4 deletions.
  1. +1 −0  .gitignore
  2. +1 −0  Gemfile
  3. +19 −4 lib/pacer-agent.rb
View
1  .gitignore
@@ -10,6 +10,7 @@ doc
# bundler
.bundle
+Gemfile.lock
# jeweler generated
pkg
View
1  Gemfile
@@ -1,5 +1,6 @@
source "http://rubygems.org"
gem 'pacer', '>= 0.6.0'
+gem 'agent', '0.1'
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
View
23 lib/pacer-agent.rb
@@ -45,17 +45,32 @@ def to_route
def each
return to_enum unless block_given?
- while not closed?
+ s = Agent::Selector.new
+ s.case(self, :receive) do
value = receive
- return close if self == value
- yield value
+ if self == value
+ close rescue nil
+ return
+ else
+ yield value
+ end
+ end
+ s.timeout(0.5) { }
+ while not closed?
+ begin
+ s.select
+ rescue Exception, StandardError => e
+ puts e.message
+ pp e.backtrace
+ raise
+ end
end
end
def ==(other)
other.is_a?(Channel) and
other.name == name and
- other.type == type and
+ other.instance_variable_get('@type') == @type and
other.instance_variable_get('@direction') == @direction
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.