Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support proc-sources in EM::Iterator #639

Merged
merged 1 commit into from
Feb 25, 2016

Conversation

jdelStrother
Copy link
Contributor

eg EM::Iterator.new(proc{ queue.pop || EM::Iterator::Stop })

Would welcome any comments on this. The EM::Iterator::Stop is kinda weird - a simpler API might be to just return nil, but that would assume that no-one's interested in processing nils in their iterator.

@tmm1
Copy link
Contributor

tmm1 commented Sep 29, 2015

Cool! Looks like ruby 1.8 has a Proc#to_a which is causing failures there:

  test_default_concurrency_with_a_proc:         /home/travis/build/eventmachine/eventmachine/lib/em/iterator.rb:59: warning: default `to_a' will be obsolete
F
===============================================================================
Failure:
test_default_concurrency_with_a_proc(TestIterator)
/home/travis/build/eventmachine/eventmachine/tests/test_iterator.rb:36:in `test_default_concurrency_with_a_proc'
     33:         EM::Timer.new(1) {iter.next}
     34:       }, proc {EM.stop})
     35:     }
  => 36:     assert_equal(10, items.keys.size)
     37:     assert_equal(original_list.to_a.sort, items.values.flatten.sort)
     38:   end
     39: 
<10> expected but was
<1>
diff:
? 10
===============================================================================

@sodabrew
Copy link
Member

Well that was a bad idea: http://ruby-doc.org/core-1.8.7/Object.html#method-i-to_a

You could put a skip("Ruby 1.8 has an silly Object#to_a") if RUBY_VERSION =~ /1\.8/

eg EM::Iterator.new(proc{ queue.pop || EM::Iterator::Stop })
@jdelStrother
Copy link
Contributor Author

I changed it so that it checks respond_to?(:call) first, which should fix that error.

@sodabrew sodabrew added this to the v1.2.0 milestone Nov 2, 2015
@sodabrew sodabrew modified the milestones: v1.2.0, v1.2.1 Feb 25, 2016
sodabrew added a commit that referenced this pull request Feb 25, 2016
Support proc-sources in EM::Iterator
@sodabrew sodabrew merged commit dcced57 into eventmachine:master Feb 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants