cool.io 1.4.1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +29 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +13 -0
  5. data/CHANGES.md +229 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE +20 -0
  8. data/README.md +166 -0
  9. data/Rakefile +79 -0
  10. data/cool.io.gemspec +29 -0
  11. data/examples/callbacked_echo_server.rb +24 -0
  12. data/examples/dslified_echo_client.rb +34 -0
  13. data/examples/dslified_echo_server.rb +24 -0
  14. data/examples/echo_client.rb +38 -0
  15. data/examples/echo_server.rb +27 -0
  16. data/examples/google.rb +9 -0
  17. data/ext/cool.io/.gitignore +5 -0
  18. data/ext/cool.io/cool.io.h +59 -0
  19. data/ext/cool.io/cool.io_ext.c +25 -0
  20. data/ext/cool.io/ev_wrap.h +10 -0
  21. data/ext/cool.io/extconf.rb +61 -0
  22. data/ext/cool.io/iowatcher.c +189 -0
  23. data/ext/cool.io/libev.c +8 -0
  24. data/ext/cool.io/loop.c +261 -0
  25. data/ext/cool.io/stat_watcher.c +269 -0
  26. data/ext/cool.io/timer_watcher.c +219 -0
  27. data/ext/cool.io/utils.c +122 -0
  28. data/ext/cool.io/watcher.c +264 -0
  29. data/ext/cool.io/watcher.h +71 -0
  30. data/ext/iobuffer/extconf.rb +9 -0
  31. data/ext/iobuffer/iobuffer.c +767 -0
  32. data/ext/libev/Changes +507 -0
  33. data/ext/libev/LICENSE +37 -0
  34. data/ext/libev/README +58 -0
  35. data/ext/libev/README.embed +3 -0
  36. data/ext/libev/ev.c +5054 -0
  37. data/ext/libev/ev.h +853 -0
  38. data/ext/libev/ev_epoll.c +282 -0
  39. data/ext/libev/ev_kqueue.c +214 -0
  40. data/ext/libev/ev_poll.c +148 -0
  41. data/ext/libev/ev_port.c +185 -0
  42. data/ext/libev/ev_select.c +362 -0
  43. data/ext/libev/ev_vars.h +204 -0
  44. data/ext/libev/ev_win32.c +163 -0
  45. data/ext/libev/ev_wrap.h +200 -0
  46. data/ext/libev/ruby_gil.patch +97 -0
  47. data/ext/libev/test_libev_win32.c +123 -0
  48. data/ext/libev/win_select.patch +115 -0
  49. data/lib/.gitignore +2 -0
  50. data/lib/cool.io.rb +34 -0
  51. data/lib/cool.io/async_watcher.rb +43 -0
  52. data/lib/cool.io/custom_require.rb +9 -0
  53. data/lib/cool.io/dns_resolver.rb +219 -0
  54. data/lib/cool.io/dsl.rb +139 -0
  55. data/lib/cool.io/io.rb +194 -0
  56. data/lib/cool.io/iowatcher.rb +17 -0
  57. data/lib/cool.io/listener.rb +99 -0
  58. data/lib/cool.io/loop.rb +122 -0
  59. data/lib/cool.io/meta.rb +49 -0
  60. data/lib/cool.io/server.rb +75 -0
  61. data/lib/cool.io/socket.rb +230 -0
  62. data/lib/cool.io/timer_watcher.rb +17 -0
  63. data/lib/cool.io/version.rb +7 -0
  64. data/lib/coolio.rb +2 -0
  65. data/spec/async_watcher_spec.rb +57 -0
  66. data/spec/dns_spec.rb +43 -0
  67. data/spec/iobuffer_spec.rb +147 -0
  68. data/spec/spec_helper.rb +19 -0
  69. data/spec/stat_watcher_spec.rb +77 -0
  70. data/spec/tcp_server_spec.rb +225 -0
  71. data/spec/tcp_socket_spec.rb +185 -0
  72. data/spec/timer_watcher_spec.rb +59 -0
  73. data/spec/udp_socket_spec.rb +58 -0
  74. data/spec/unix_listener_spec.rb +25 -0
  75. data/spec/unix_server_spec.rb +27 -0
  76. metadata +182 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a3c3fb24366477f5c9b84e6d2382c1130fb63ada
4
+ data.tar.gz: 11fc33983352f1d82da7d12106c39703747ea6c0
5
+ SHA512:
6
+ metadata.gz: 3a75a1e77f44ff93546039f1d5995b9379a8c6979acc93529568f864798a3586ce60821133c2dc0dd0d98041e676ad00040b9e3d0752d60b2e0724cd22dfde45
7
+ data.tar.gz: a0a5440b6d2ff3523aadc46e7277ec7bcd9225c0375e77ea3832f24e25b617a1d9f8aa56a407fd0612d99b2e8399f4b0b01ec1e36d7d902df6a765e825c30d1b
@@ -0,0 +1,29 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+ tmp
21
+
22
+ ## RUBINIUS
23
+ *.rbc
24
+
25
+ ## PROJECT::SPECIFIC
26
+ conftest.dSYM
27
+
28
+ *.lock
29
+ .ruby-version
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --backtrace
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0
6
+ - 2.1
7
+ - 2.2
8
+ - ruby-head
9
+ - rbx
10
+
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: rbx
@@ -0,0 +1,229 @@
1
+ 1.4.1
2
+ -----
3
+
4
+ * Use SleepEx instead of Sleep for better fix of process hung problem on windows environment
5
+ * Use rake-compiler-dock for cross compilation
6
+
7
+ 1.4.0
8
+ -----
9
+
10
+ * Update libev to 4.20
11
+ * Sleep in timeout instead of select on Windows
12
+
13
+ 1.3.1
14
+ -----
15
+
16
+ * Fix several bugs for JRuby support enhancement
17
+ * Fix deadlock bug on Windows environment
18
+ * Use RSpec3
19
+
20
+ 1.3.0
21
+ -----
22
+
23
+ * Block evaluation doesn't change self for keeping consistency with Ruby block
24
+ * Remove EventMachine emulation module
25
+ * Remove HttpClient
26
+ * DSL syntax is no longer available by default. Need to require 'cool.io/dsl' in user code
27
+ * Update libev to 4.19
28
+
29
+ 1.2.4
30
+ -----
31
+
32
+ * Fix a bug that #close for unconnected Socket doesn't detach all watchers (#33)
33
+ * Remove 1.8 support code
34
+ * Use standard library instead of own hosts list (#34)
35
+
36
+ 1.2.3
37
+ -----
38
+
39
+ * Fix CPU consuming issue on Windows.
40
+
41
+ 1.2.2
42
+ -----
43
+
44
+ * Add timeout option to Loop#run and Loop#run_once. Default by nil
45
+ * Support Ruby 2.2.0
46
+
47
+ 1.2.1
48
+ -----
49
+
50
+ * Release the GIL when libev polls (#24)
51
+ * Add Listener#listen method to change backlog size
52
+
53
+ 1.2.0
54
+ -----
55
+
56
+ * Support Windows environment via cross compilation
57
+ * Include iobuffer library
58
+ * Update to libev 4.15
59
+ * Remove Ruby 1.8 support
60
+
61
+ 1.1.0
62
+ -----
63
+
64
+ * Switch from Jeweler to Bundler for the gem boilerplate
65
+ * Fix firing of Coolio::HttpClient#on_request_complete (#15)
66
+ * Fix failure to resolve Init_cool symbol on win32 mingw (#14)
67
+ * Fix closing /etc/hosts in the DNS resolver (#12)
68
+ * Refactor StatWatcher to pass pervious and current path state ala Node.js
69
+ * spec:valgrind Rake task to run specs under valgrind
70
+ * Use rake-compiler to build cool.io
71
+ * Upgrade to libev 4.04
72
+
73
+ 1.0.0
74
+ -----
75
+
76
+ * Fancy new DSL
77
+
78
+ 0.9.0
79
+ -----
80
+
81
+ * Rename the project to cool.io
82
+ * Bump the version all the way to 0.9! Hell yeah! 1.0 soon!
83
+ * Rename the main module from Rev to Coolio, with deprecation warnings for Rev
84
+ * Use Jeweler to manage the gem
85
+ * Update to RSpec 2.0
86
+ * Update to libev 4.01
87
+ * Initial Rubinius support
88
+
89
+ 0.3.2
90
+ -----
91
+
92
+ * Perform a blocking system call if we're the only thread running (1.8 only)
93
+ * Run in non-blocking mode if we're the only thread in the process (1.8 only)
94
+ * Make Rev::Loop#run_nonblock signal-safe
95
+ * Fix spurious firing of Rev::AsyncWatchers
96
+
97
+ 0.3.1
98
+ -----
99
+
100
+ * Configurable intervals for Rev::StatWatcher
101
+ * Fix broken version number :(
102
+ * Removed warning about spuriously readable sockets from Rev::Listener
103
+ * Rev::Listener ignores ECONNABORTED from accept_nonblock
104
+ * Document rationale for EAGAIN/ECONNABORTED handling in Rev::Listener
105
+
106
+ 0.3.0
107
+ -----
108
+
109
+ * Add Rev::StatWatcher to monitor filesystem changes
110
+ * Add Rev::Listener#fileno for accessing the underlying file descriptor
111
+ * Support for creating Rev::Listeners from existing TCPServers/UNIXServers
112
+ * Upgrade to libev 3.8
113
+ * Simplified code loading
114
+ * Pull in iobuffer gem and change outstanding uses of Rev::Buffer to IO::Buffer
115
+ * Fix memory leaks resulting from strange semantics of Ruby's xrealloc
116
+ * Rev::UNIXServer: use path instead of the first argument
117
+ * Rev::Server-based classes can build off ::*Server objects
118
+
119
+ 0.2.4
120
+ -----
121
+
122
+ * Ugh, botched my first release from the git repo. Oh well. Try, try again.
123
+
124
+ 0.2.3
125
+ -----
126
+
127
+ * Initial Windows support
128
+ * Initial Ruby 1.8.7 and 1.9.1 support
129
+ * Upgrade to libev 3.52
130
+ * Add checks for sys/resource.h and don't allow getting/setting maxfds if it
131
+ isn't present
132
+
133
+ 0.2.2
134
+ -----
135
+
136
+ * Correct a pointer arithmetic error in the buffering code that could result
137
+ in data corruption.
138
+ * Upgrade to libev 3.41
139
+ * Relax HTTP/1.1 reponse parser to allow the "reason" portion of the response
140
+ header to be omitted
141
+
142
+ 0.2.1
143
+ -----
144
+
145
+ * Upgrade to libev 3.31
146
+ * Rev::Loop#run_once and Rev::Loop#run_nonblock now return the number of events
147
+ received when they were running
148
+ * Remove inheritence relationship between Rev::IO and Rev::IOWatcher
149
+ * Loosen HTTP/1.1 response parser to accept a common malformation in HTTP/1.1
150
+ chunk headers
151
+ * Add underscore prefix to instance variables to avoid conflicts in subclasses
152
+ * Remove Rev::SSLServer until it can be made more useful
153
+
154
+ 0.2.0
155
+ -----
156
+
157
+ * Initial Ruby 1.8.6 support
158
+ * Omit Rev::LIBEV_VERSION constant
159
+ * Catch Errno::ECONNRESET when writing to sockets
160
+ * SSL support via Rev::SSL, with a small C extension subclassing Ruby's
161
+ OpenSSL::SSL::SSLSocket allowing for non-blocking SSL handshakes
162
+ * Initial Rev::Utils implementation with #ncpus and methods to query and
163
+ change the maximum number of file descriptors for the current process.
164
+ * Initial Rev::AsyncWatcher implementation for cross-thread signaling
165
+ * Handle unspecified Content-Length when encoding is identity in HttpClient
166
+ * Fix bug in HttpClient processing zero Content-Length
167
+ * Get rid of method_missing stuff in Rev::HttpClient
168
+ * Have Rev::HttpClient close the connection on error
169
+ * Allow Rev::TCPSocket#on_connect to be private when accepting connections
170
+ from a Rev::TCPServer
171
+
172
+ 0.1.4
173
+ -----
174
+
175
+ * Calibrate Rev::TimerWatchers against ev_time() and ev_now() when the watcher
176
+ is attached to the loop to ensure that the timeout interval is correct.
177
+ * Add check to ensure that a Rev::Loop cannot be run from within a callback
178
+ * Store Rev::Loop.default in a Thread-specific instance variable
179
+ * Upgrade libev to 0.3.0
180
+ * Rename BufferedIO to IO
181
+ * Fixed bug in BufferedIO#write_output_buffer causing it to spin endlessly on
182
+ an empty buffer.
183
+ * Added has_active_watchers? to Rev::Loop to check for active watchers
184
+
185
+ 0.1.3
186
+ -----
187
+
188
+ * Fixed bug in Rev::Buffer read_from and write_to: now rb_sys_fail on failed
189
+ reads/writes.
190
+ * Change Rev::Buffer memory pools to purge on a periodic interval, rather than
191
+ whenever the GC marks the object.
192
+ * Fix bug in tracking the active watcher count. Factor shared watcher behavior
193
+ from rev_watcher.h to rev_watcher.c.
194
+
195
+ 0.1.2
196
+ -----
197
+
198
+ * Commit initial specs
199
+ * Improve RDoc for the library
200
+ * Eliminate "zero copy" writes as they bypass the event loop
201
+ * Added Rev::Buffer C extension to provide high speed buffered writes
202
+ * Implement Rev::TCPSocket#peeraddr to improve compatibility with Ruby sockets
203
+ * Added Rev::Listener.close for clean shutdown of a listener
204
+ * Rev::Loop.default used to call ev_loop_default() (in C). However, this
205
+ registers signal handlers which conflict with Ruby's own. Now the behavior
206
+ has been changed to return a thread-local singleton of Rev::Loop.
207
+ * Creating a new Rev::TCPListener will disable reverse lookups in BasicSocket
208
+ * Made backlog for Rev::TCPListener user-definable
209
+ * Rev::TCPSocket now implements an on_resolve_failed callback for failed DNS
210
+ resolution. By default it's aliased to on_connect_failed.
211
+ * Changed event_callbacks to use instance_exec rather than passing the
212
+ watcher object as an argument. Documented use of defining an event
213
+ callback as a block
214
+ * Subsecond precision for Rev::TimerWatchers
215
+
216
+ 0.1.1
217
+ -----
218
+
219
+ * Added Rev::HttpClient, an asynchronous HTTP/1.1 client written on top of
220
+ the Rev::TCPSocket class
221
+ * Imported HTTP response parser from the RFuzz project
222
+ * Added exception handling for Errno::ECONNRESET and Errno::EAGAIN
223
+ * Fixed bugs in buffered writer which resulted in exceptions if all data
224
+ couldn't be written with a nonblocking write.
225
+
226
+ 0.1.0
227
+ -----
228
+
229
+ * Initial public release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in cool.io.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2007-10 Tony Arcieri
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,166 @@
1
+ Cool.io
2
+ =======
3
+
4
+ ### If you are interested in Celluloid based IO framework, please check out [Celluloid::IO](http://github.com/celluloid/celluloid-io)
5
+
6
+ Cool.io is an event library for Ruby, built on the libev event library which
7
+ provides a cross-platform interface to high performance system calls . This
8
+ includes the epoll system call for Linux, the kqueue system call for BSDs and
9
+ OS X, and the completion ports interface for Solaris.
10
+
11
+ Cool.io also binds asynchronous wrappers to Ruby's core socket classes so you can
12
+ use them in conjunction with Cool.io to build asynchronous event-driven
13
+ applications.
14
+
15
+ You can include Cool.io in your programs with:
16
+
17
+ require 'cool.io'
18
+
19
+
20
+ Anatomy
21
+ -------
22
+
23
+ Cool.io builds on two core classes which bind to the libev API:
24
+
25
+ * Cool.io::Loop - This class represents an event loop which uses underlying high
26
+ performance system calls to wait for events.
27
+
28
+ * Cool.io::Watcher - This is the base class for event observers. Once you attach
29
+ an event observer to a loop and start running it, you will begin receiving
30
+ callbacks to particlar methods when events occur.
31
+
32
+ Watchers
33
+ --------
34
+
35
+ There are presently four types of watchers:
36
+
37
+ * Cool.io::IOWatcher - This class waits for an IO object to become readable,
38
+ writable, or both.
39
+
40
+ * Cool.io::TimerWatcher - This class waits for a specified duration then fires
41
+ an event. You can also configure it to fire an event at specified intervals.
42
+
43
+ * Cool.io::StatWatcher - Monitors files or directories for changes
44
+
45
+ * Cool.io::AsyncWatcher - Can be used to wake up a Cool.io::Loop running in a
46
+ different thread. This allows each thread to run a separate Cool.io::Loop and
47
+ for the different event loops to be able to signal each other.
48
+
49
+ Using Watchers
50
+ --------------
51
+
52
+ Watchers have five important methods:
53
+
54
+ * attach(loop) - This binds a watcher to the specified event loop. If the
55
+ watcher is already bound to a loop it will be detached first, then attached
56
+ to the new one.
57
+
58
+ * detach - This completely unbinds a watcher from an event loop.
59
+
60
+ * disable - This stops the watcher from receiving events but does not unbind
61
+ it from the loop. If you are trying to toggle a watcher on and off, it's
62
+ best to use this method (and enable) as it performs better than completely
63
+ removing the watcher from the event loop.
64
+
65
+ * enable - This re-enables a watcher which has been disabled in the past.
66
+ The watcher must still be bound to an event loop.
67
+
68
+ * evloop - This returns the Cool.io::Loop object which the watcher is currently
69
+ bound to.
70
+
71
+ Asynchronous Wrappers
72
+ ---------------------
73
+
74
+ Several classes which provide asynchronous event-driven wrappers for Ruby's
75
+ core socket classes are also provided. Among these are:
76
+
77
+ * Cool.io::TCPSocket - A buffered wrapper to core Ruby's Socket class for use with
78
+ TCP sockets. You can asynchronously create outgoing TCP connections using
79
+ its Cool.io::TCPSocket.connect method. Cool.io::TCPSocket provides write buffering
80
+ to ensure that writing never blocks, and has asynchronous callbacks for
81
+ several events, including when the connection is opened (or failed), when
82
+ data is received, when the write buffer has been written out completely,
83
+ and when the connection closes.
84
+
85
+ * Cool.io::TCPServer - A wrapper for TCPServer which creates new instances of
86
+ Cool.io::TCPSocket (or any subclass you wish to provide) whenever an incoming
87
+ connection is received.
88
+
89
+ Example Program
90
+ ---------------
91
+
92
+ Cool.io provides a Sinatra-like DSL for authoring event-driven programs:
93
+
94
+ require 'cool.io'
95
+ require 'cool.io/dsl'
96
+
97
+ ADDR = '127.0.0.1'
98
+ PORT = 4321
99
+
100
+ cool.io.connection :echo_server_connection do
101
+ on_connect do
102
+ puts "#{remote_addr}:#{remote_port} connected"
103
+ end
104
+
105
+ on_close do
106
+ puts "#{remote_addr}:#{remote_port} disconnected"
107
+ end
108
+
109
+ on_read do |data|
110
+ write data
111
+ end
112
+ end
113
+
114
+ puts "Echo server listening on #{ADDR}:#{PORT}"
115
+ cool.io.server ADDR, PORT, :echo_server_connection
116
+ cool.io.run
117
+
118
+ This creates a new connection class called :echo_server_connection and defines
119
+ a set of callbacks for when various events occur.
120
+
121
+ We then create a new server on the given address and port. When this server
122
+ receives new connections, it will create new instances of the given connection
123
+ class for each connection.
124
+
125
+ Finally, we kick everything off with cool.io.run. Calling cool.io.run will
126
+ block, listening for events on our server.
127
+
128
+ Using Cool.io subclasses directly
129
+ ---------------------------------
130
+
131
+ Below is an example of how to write an echo server using a subclass instead of
132
+ the DSL:
133
+
134
+ require 'cool.io'
135
+ HOST = 'localhost'
136
+ PORT = 4321
137
+
138
+ class EchoServerConnection < Cool.io::TCPSocket
139
+ def on_connect
140
+ puts "#{remote_addr}:#{remote_port} connected"
141
+ end
142
+
143
+ def on_close
144
+ puts "#{remote_addr}:#{remote_port} disconnected"
145
+ end
146
+
147
+ def on_read(data)
148
+ write data
149
+ end
150
+ end
151
+
152
+ server = Cool.io::TCPServer.new(HOST, PORT, EchoServerConnection)
153
+ server.attach(Cool.io::Loop.default)
154
+
155
+ puts "Echo server listening on #{HOST}:#{PORT}"
156
+ Cool.io::Loop.default.run
157
+
158
+ Here a new observer type (EchoServerConnection) is made by subclassing an
159
+ existing one and adding new implementations to existing event handlers.
160
+
161
+ A new event loop is created, and a new Cool.io::TCPServer (whose base class is
162
+ Cool.io::Watcher) is created and attached to the event loop.
163
+
164
+ Once this is done, the event loop is started with event_loop.run. This method
165
+ will block until there are no active watchers for the loop or the loop is
166
+ stopped explicitly with event_loop.stop.