cool.io 1.0.0 → 1.9.0

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.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/test.yaml +54 -0
  3. data/.gitignore +30 -0
  4. data/.rspec +3 -0
  5. data/{CHANGES → CHANGES.md} +175 -79
  6. data/{README.markdown → README.md} +43 -49
  7. data/Rakefile +44 -69
  8. data/appveyor.yml +18 -0
  9. data/cool.io.gemspec +18 -131
  10. data/examples/callbacked_echo_server.rb +24 -0
  11. data/ext/cool.io/buffer.c +781 -0
  12. data/ext/cool.io/cool.io.h +13 -0
  13. data/ext/cool.io/cool.io_ext.c +1 -0
  14. data/ext/cool.io/ev_wrap.h +4 -2
  15. data/ext/cool.io/extconf.rb +27 -16
  16. data/ext/cool.io/iowatcher.c +17 -8
  17. data/ext/cool.io/loop.c +36 -84
  18. data/ext/cool.io/stat_watcher.c +103 -25
  19. data/ext/cool.io/timer_watcher.c +3 -3
  20. data/ext/cool.io/utils.c +5 -0
  21. data/ext/cool.io/watcher.h +1 -1
  22. data/ext/libev/Changes +152 -3
  23. data/ext/libev/LICENSE +2 -1
  24. data/ext/libev/README +8 -8
  25. data/ext/libev/ev.c +1719 -348
  26. data/ext/libev/ev.h +146 -118
  27. data/ext/libev/ev_epoll.c +71 -20
  28. data/ext/libev/ev_kqueue.c +36 -16
  29. data/ext/libev/ev_poll.c +14 -11
  30. data/ext/libev/ev_port.c +43 -18
  31. data/ext/libev/ev_select.c +82 -25
  32. data/ext/libev/ev_vars.h +28 -21
  33. data/ext/libev/ev_win32.c +19 -10
  34. data/ext/libev/ev_wrap.h +166 -152
  35. data/ext/libev/test_libev_win32.c +1 -1
  36. data/gems.rb +9 -0
  37. data/lib/cool.io/async_watcher.rb +1 -1
  38. data/lib/cool.io/custom_require.rb +9 -0
  39. data/lib/cool.io/dns_resolver.rb +30 -22
  40. data/lib/cool.io/dsl.rb +32 -28
  41. data/lib/cool.io/io.rb +55 -35
  42. data/lib/cool.io/iowatcher.rb +1 -1
  43. data/lib/cool.io/listener.rb +35 -17
  44. data/lib/cool.io/loop.rb +17 -25
  45. data/lib/cool.io/meta.rb +6 -5
  46. data/lib/cool.io/server.rb +5 -4
  47. data/lib/cool.io/socket.rb +41 -30
  48. data/lib/cool.io/timer_watcher.rb +1 -1
  49. data/lib/cool.io/version.rb +7 -0
  50. data/lib/cool.io.rb +11 -10
  51. data/lib/coolio.rb +1 -1
  52. data/libev_ruby_gil.diff +175 -0
  53. data/libev_win_select.diff +130 -0
  54. data/spec/async_watcher_spec.rb +5 -5
  55. data/spec/dns_spec.rb +27 -8
  56. data/spec/iobuffer_spec.rb +147 -0
  57. data/spec/spec_helper.rb +15 -1
  58. data/spec/stat_watcher_spec.rb +81 -0
  59. data/spec/tcp_server_spec.rb +225 -0
  60. data/spec/tcp_socket_spec.rb +185 -0
  61. data/spec/timer_watcher_spec.rb +23 -19
  62. data/spec/udp_socket_spec.rb +58 -0
  63. data/spec/unix_listener_spec.rb +8 -8
  64. data/spec/unix_server_spec.rb +10 -8
  65. metadata +109 -112
  66. data/VERSION +0 -1
  67. data/examples/httpclient.rb +0 -38
  68. data/ext/http11_client/.gitignore +0 -5
  69. data/ext/http11_client/LICENSE +0 -31
  70. data/ext/http11_client/ext_help.h +0 -14
  71. data/ext/http11_client/extconf.rb +0 -6
  72. data/ext/http11_client/http11_client.c +0 -300
  73. data/ext/http11_client/http11_parser.c +0 -403
  74. data/ext/http11_client/http11_parser.h +0 -48
  75. data/ext/http11_client/http11_parser.rl +0 -173
  76. data/lib/cool.io/eventmachine.rb +0 -234
  77. data/lib/cool.io/http_client.rb +0 -419
  78. data/lib/rev.rb +0 -4
  79. data/spec/possible_tests/schedules_other_threads.rb +0 -48
  80. data/spec/possible_tests/test_on_resolve_failed.rb +0 -9
  81. data/spec/possible_tests/test_resolves.rb +0 -27
  82. data/spec/possible_tests/test_write_during_resolve.rb +0 -27
  83. data/spec/possible_tests/works_straight.rb +0 -71
@@ -1,27 +0,0 @@
1
- require File.dirname(__FILE__) + '/../rev'
2
-
3
- ADDR = 'wilkboardonline.com'
4
- PORT = 80
5
-
6
- class ClientConnection < Rev::TCPSocket
7
- def on_connect
8
- puts "#{remote_addr}:#{remote_port} connected"
9
- write ("GET / HTTP/1.1\r\nhost:wilkboardonline.com:80\r\nconnection:close\r\n\r\n")
10
- end
11
-
12
- def on_close
13
- puts "#{remote_addr}:#{remote_port} disconnected"
14
- end
15
-
16
- def on_read(data)
17
- print "got #{data}"
18
- close
19
- end
20
-
21
- end
22
-
23
- event_loop = Rev::Loop.default
24
- client = ClientConnection.connect(ADDR, PORT)
25
- client.attach(event_loop)
26
- puts "Echo client started to #{ADDR}:#{PORT}"
27
- event_loop.run
@@ -1,27 +0,0 @@
1
- require File.dirname(__FILE__) + '/../rev'
2
-
3
- ADDR = 'wilkboardonline.com'
4
- PORT = 80
5
-
6
- class ClientConnection < Rev::TCPSocket
7
- def on_connect
8
- puts "#{remote_addr}:#{remote_port} connected"
9
- end
10
-
11
- def on_close
12
- puts "#{remote_addr}:#{remote_port} disconnected"
13
- end
14
-
15
- def on_read(data)
16
- print "got #{data}"
17
- close
18
- end
19
-
20
- end
21
-
22
- event_loop = Rev::Loop.default
23
- client = ClientConnection.connect(ADDR, PORT)
24
- client.write ("GET / HTTP/1.1\r\nhost:wilkboardonline.com:80\r\nconnection:close\r\n\r\n")
25
- client.attach(event_loop)
26
- puts "Echo client started to #{ADDR}:#{PORT}"
27
- event_loop.run
@@ -1,71 +0,0 @@
1
- require File.dirname(__FILE__) + '/../lib/rev'
2
- def dbg
3
- require 'rubygems'
4
- require 'ruby-debug'
5
- debugger
6
- end
7
- Thread.abort_on_exception=true
8
-
9
- require 'socket'
10
-
11
- describe Rev::TCPSocket do
12
- HOST = '127.0.0.1'
13
- PORT = 4321
14
- before :each do
15
- @server = Rev::TCPServer.new(HOST, PORT) do |c|
16
- c.on_connect { puts "#{remote_addr}:#{remote_port} connected" }
17
- c.on_close { puts "#{remote_addr}:#{remote_port} disconnected" }
18
- #c.on_read { |data| write data }
19
- end
20
-
21
- end
22
-
23
- after :each do
24
- @server.close
25
- end
26
-
27
- def sleep_until(seconds = 1, interval = 0.1)
28
- raise unless block_given?
29
- start_time=Time.now
30
- sleep interval until ((Time.now - start_time) > seconds) or yield
31
- end
32
-
33
- it "should stop" do
34
- loop = Rev::Loop.default
35
- stopped = false;
36
- @server.attach(loop)
37
- Thread.new {
38
- loop.run_nonblock_over_and_over_again
39
- stopped = true
40
- }
41
- sleep 0
42
- stopped.should == false
43
- loop.stop
44
-
45
- sleep_until { stopped == true }
46
- stopped.should == true
47
- end
48
-
49
- it "should auto bind on 1.8.6" do
50
- @server.close
51
- loop = Rev::Loop.default
52
- server = Rev::TCPServer.new(HOST, PORT) do |c|
53
- #c.on_connect { puts "#{remote_addr}:#{remote_port} connected" }
54
- #c.on_close { puts "#{remote_addr}:#{remote_port} disconnected" }
55
- print "CREATING\n"
56
- c.on_read { |conn, data| print "WITHIN MYINE"; conn.write data; conn.close; loop.stop }
57
- end
58
-
59
- server.attach(loop)
60
-
61
- Thread.new { loop.run_nonblock_over_and_over_again }
62
- puts "Echo server listening on #{HOST}:#{PORT}"
63
- # now connect and write -- it should close
64
- connector = TCPSocket.new HOST, PORT
65
- connector.write "yup"
66
- connector.read.should == 'yup'
67
- sleep 0
68
- loop.running?.should != true
69
- connector.closed?.should == true # it should close me, too
70
- end
71
- end