diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-12-10 20:50:41 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2012-03-26 18:33:59 -0700 |
commit | b6982e360e00adc2a15c6d75dc6a5cde56cd9e7f (patch) | |
tree | 0d1b2aff6ba651037c5cdba734876824cd4f3cec | |
parent | 6fa0bc3f4c6fd959463a3906a820a724076a416c (diff) | |
download | sleepy_penguin-b6982e360e00adc2a15c6d75dc6a5cde56cd9e7f.tar.gz |
This is a testcase I wrote a few months ago
-rw-r--r-- | test/test_epoll.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/test_epoll.rb b/test/test_epoll.rb index 7633d94..fd22654 100644 --- a/test/test_epoll.rb +++ b/test/test_epoll.rb @@ -507,4 +507,21 @@ class TestEpoll < Test::Unit::TestCase w.close end end + + def test_epoll_as_queue + fl = Epoll::OUT | Epoll::ET + first = nil + 500.times do + r, w = IO.pipe + @ep.add(w, fl) + first ||= begin + @ep.add(r, Epoll::IN | Epoll::ET) + [ r, w ] + end + end + 500.times do |i| + @ep.wait(1) { |flags, io| first[1].write('.') if i == 0 } + end + @ep.wait(1) { |flags, io| assert_equal(first[0], io) } + end end |