foolio 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (261) hide show
  1. data/.gitignore +22 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +22 -0
  4. data/README.md +29 -0
  5. data/Rakefile +21 -0
  6. data/examples/timer.rb +20 -0
  7. data/ext/foolio/extconf.rb +34 -0
  8. data/ext/foolio/foolio_ext.c +921 -0
  9. data/ext/foolio/gen.rb +50 -0
  10. data/ext/foolio/make_table.rb +12 -0
  11. data/ext/foolio/templ +243 -0
  12. data/ext/libuv/.gitignore +33 -0
  13. data/ext/libuv/.mailmap +13 -0
  14. data/ext/libuv/.travis.yml +9 -0
  15. data/ext/libuv/AUTHORS +61 -0
  16. data/ext/libuv/LICENSE +44 -0
  17. data/ext/libuv/Makefile +71 -0
  18. data/ext/libuv/README.md +90 -0
  19. data/ext/libuv/common.gypi +178 -0
  20. data/ext/libuv/gyp_uv +73 -0
  21. data/ext/libuv/include/uv-private/eio.h +403 -0
  22. data/ext/libuv/include/uv-private/ev.h +838 -0
  23. data/ext/libuv/include/uv-private/ngx-queue.h +108 -0
  24. data/ext/libuv/include/uv-private/tree.h +768 -0
  25. data/ext/libuv/include/uv-private/uv-unix.h +324 -0
  26. data/ext/libuv/include/uv-private/uv-win.h +517 -0
  27. data/ext/libuv/include/uv.h +1838 -0
  28. data/ext/libuv/src/fs-poll.c +235 -0
  29. data/ext/libuv/src/inet.c +293 -0
  30. data/ext/libuv/src/unix/async.c +148 -0
  31. data/ext/libuv/src/unix/core.c +696 -0
  32. data/ext/libuv/src/unix/cygwin.c +83 -0
  33. data/ext/libuv/src/unix/darwin.c +342 -0
  34. data/ext/libuv/src/unix/dl.c +83 -0
  35. data/ext/libuv/src/unix/eio/Changes +63 -0
  36. data/ext/libuv/src/unix/eio/LICENSE +36 -0
  37. data/ext/libuv/src/unix/eio/Makefile.am +15 -0
  38. data/ext/libuv/src/unix/eio/aclocal.m4 +8957 -0
  39. data/ext/libuv/src/unix/eio/autogen.sh +3 -0
  40. data/ext/libuv/src/unix/eio/config.h.in +86 -0
  41. data/ext/libuv/src/unix/eio/config_cygwin.h +80 -0
  42. data/ext/libuv/src/unix/eio/config_darwin.h +141 -0
  43. data/ext/libuv/src/unix/eio/config_freebsd.h +81 -0
  44. data/ext/libuv/src/unix/eio/config_linux.h +94 -0
  45. data/ext/libuv/src/unix/eio/config_netbsd.h +81 -0
  46. data/ext/libuv/src/unix/eio/config_openbsd.h +137 -0
  47. data/ext/libuv/src/unix/eio/config_sunos.h +84 -0
  48. data/ext/libuv/src/unix/eio/configure.ac +22 -0
  49. data/ext/libuv/src/unix/eio/demo.c +194 -0
  50. data/ext/libuv/src/unix/eio/ecb.h +370 -0
  51. data/ext/libuv/src/unix/eio/eio.3 +3428 -0
  52. data/ext/libuv/src/unix/eio/eio.c +2593 -0
  53. data/ext/libuv/src/unix/eio/eio.pod +969 -0
  54. data/ext/libuv/src/unix/eio/libeio.m4 +195 -0
  55. data/ext/libuv/src/unix/eio/xthread.h +164 -0
  56. data/ext/libuv/src/unix/error.c +105 -0
  57. data/ext/libuv/src/unix/ev/Changes +388 -0
  58. data/ext/libuv/src/unix/ev/LICENSE +36 -0
  59. data/ext/libuv/src/unix/ev/Makefile.am +18 -0
  60. data/ext/libuv/src/unix/ev/Makefile.in +771 -0
  61. data/ext/libuv/src/unix/ev/README +58 -0
  62. data/ext/libuv/src/unix/ev/aclocal.m4 +8957 -0
  63. data/ext/libuv/src/unix/ev/autogen.sh +6 -0
  64. data/ext/libuv/src/unix/ev/config.guess +1526 -0
  65. data/ext/libuv/src/unix/ev/config.h.in +125 -0
  66. data/ext/libuv/src/unix/ev/config.sub +1658 -0
  67. data/ext/libuv/src/unix/ev/config_cygwin.h +123 -0
  68. data/ext/libuv/src/unix/ev/config_darwin.h +122 -0
  69. data/ext/libuv/src/unix/ev/config_freebsd.h +120 -0
  70. data/ext/libuv/src/unix/ev/config_linux.h +141 -0
  71. data/ext/libuv/src/unix/ev/config_netbsd.h +120 -0
  72. data/ext/libuv/src/unix/ev/config_openbsd.h +126 -0
  73. data/ext/libuv/src/unix/ev/config_sunos.h +122 -0
  74. data/ext/libuv/src/unix/ev/configure +13037 -0
  75. data/ext/libuv/src/unix/ev/configure.ac +18 -0
  76. data/ext/libuv/src/unix/ev/depcomp +630 -0
  77. data/ext/libuv/src/unix/ev/ev++.h +816 -0
  78. data/ext/libuv/src/unix/ev/ev.3 +5311 -0
  79. data/ext/libuv/src/unix/ev/ev.c +3925 -0
  80. data/ext/libuv/src/unix/ev/ev.pod +5243 -0
  81. data/ext/libuv/src/unix/ev/ev_epoll.c +266 -0
  82. data/ext/libuv/src/unix/ev/ev_kqueue.c +235 -0
  83. data/ext/libuv/src/unix/ev/ev_poll.c +148 -0
  84. data/ext/libuv/src/unix/ev/ev_port.c +179 -0
  85. data/ext/libuv/src/unix/ev/ev_select.c +310 -0
  86. data/ext/libuv/src/unix/ev/ev_vars.h +203 -0
  87. data/ext/libuv/src/unix/ev/ev_win32.c +153 -0
  88. data/ext/libuv/src/unix/ev/ev_wrap.h +196 -0
  89. data/ext/libuv/src/unix/ev/event.c +402 -0
  90. data/ext/libuv/src/unix/ev/event.h +170 -0
  91. data/ext/libuv/src/unix/ev/install-sh +294 -0
  92. data/ext/libuv/src/unix/ev/libev.m4 +39 -0
  93. data/ext/libuv/src/unix/ev/ltmain.sh +8413 -0
  94. data/ext/libuv/src/unix/ev/missing +336 -0
  95. data/ext/libuv/src/unix/ev/mkinstalldirs +111 -0
  96. data/ext/libuv/src/unix/freebsd.c +326 -0
  97. data/ext/libuv/src/unix/fs.c +739 -0
  98. data/ext/libuv/src/unix/internal.h +188 -0
  99. data/ext/libuv/src/unix/kqueue.c +120 -0
  100. data/ext/libuv/src/unix/linux/inotify.c +239 -0
  101. data/ext/libuv/src/unix/linux/linux-core.c +557 -0
  102. data/ext/libuv/src/unix/linux/syscalls.c +388 -0
  103. data/ext/libuv/src/unix/linux/syscalls.h +124 -0
  104. data/ext/libuv/src/unix/loop-watcher.c +62 -0
  105. data/ext/libuv/src/unix/loop.c +94 -0
  106. data/ext/libuv/src/unix/netbsd.c +108 -0
  107. data/ext/libuv/src/unix/openbsd.c +295 -0
  108. data/ext/libuv/src/unix/pipe.c +259 -0
  109. data/ext/libuv/src/unix/poll.c +114 -0
  110. data/ext/libuv/src/unix/process.c +495 -0
  111. data/ext/libuv/src/unix/signal.c +269 -0
  112. data/ext/libuv/src/unix/stream.c +990 -0
  113. data/ext/libuv/src/unix/sunos.c +481 -0
  114. data/ext/libuv/src/unix/tcp.c +393 -0
  115. data/ext/libuv/src/unix/thread.c +251 -0
  116. data/ext/libuv/src/unix/timer.c +136 -0
  117. data/ext/libuv/src/unix/tty.c +145 -0
  118. data/ext/libuv/src/unix/udp.c +659 -0
  119. data/ext/libuv/src/unix/uv-eio.c +107 -0
  120. data/ext/libuv/src/unix/uv-eio.h +13 -0
  121. data/ext/libuv/src/uv-common.c +380 -0
  122. data/ext/libuv/src/uv-common.h +170 -0
  123. data/ext/libuv/src/win/async.c +100 -0
  124. data/ext/libuv/src/win/atomicops-inl.h +56 -0
  125. data/ext/libuv/src/win/core.c +278 -0
  126. data/ext/libuv/src/win/dl.c +86 -0
  127. data/ext/libuv/src/win/error.c +155 -0
  128. data/ext/libuv/src/win/fs-event.c +510 -0
  129. data/ext/libuv/src/win/fs.c +1948 -0
  130. data/ext/libuv/src/win/getaddrinfo.c +365 -0
  131. data/ext/libuv/src/win/handle-inl.h +149 -0
  132. data/ext/libuv/src/win/handle.c +154 -0
  133. data/ext/libuv/src/win/internal.h +343 -0
  134. data/ext/libuv/src/win/loop-watcher.c +122 -0
  135. data/ext/libuv/src/win/pipe.c +1672 -0
  136. data/ext/libuv/src/win/poll.c +616 -0
  137. data/ext/libuv/src/win/process-stdio.c +500 -0
  138. data/ext/libuv/src/win/process.c +1013 -0
  139. data/ext/libuv/src/win/req-inl.h +220 -0
  140. data/ext/libuv/src/win/req.c +25 -0
  141. data/ext/libuv/src/win/signal.c +57 -0
  142. data/ext/libuv/src/win/stream-inl.h +67 -0
  143. data/ext/libuv/src/win/stream.c +167 -0
  144. data/ext/libuv/src/win/tcp.c +1394 -0
  145. data/ext/libuv/src/win/thread.c +372 -0
  146. data/ext/libuv/src/win/threadpool.c +74 -0
  147. data/ext/libuv/src/win/timer.c +224 -0
  148. data/ext/libuv/src/win/tty.c +1799 -0
  149. data/ext/libuv/src/win/udp.c +716 -0
  150. data/ext/libuv/src/win/util.c +864 -0
  151. data/ext/libuv/src/win/winapi.c +132 -0
  152. data/ext/libuv/src/win/winapi.h +4452 -0
  153. data/ext/libuv/src/win/winsock.c +557 -0
  154. data/ext/libuv/src/win/winsock.h +171 -0
  155. data/ext/libuv/test/benchmark-async-pummel.c +97 -0
  156. data/ext/libuv/test/benchmark-async.c +137 -0
  157. data/ext/libuv/test/benchmark-fs-stat.c +135 -0
  158. data/ext/libuv/test/benchmark-getaddrinfo.c +94 -0
  159. data/ext/libuv/test/benchmark-list.h +127 -0
  160. data/ext/libuv/test/benchmark-loop-count.c +88 -0
  161. data/ext/libuv/test/benchmark-million-timers.c +65 -0
  162. data/ext/libuv/test/benchmark-ping-pongs.c +213 -0
  163. data/ext/libuv/test/benchmark-pound.c +324 -0
  164. data/ext/libuv/test/benchmark-pump.c +462 -0
  165. data/ext/libuv/test/benchmark-sizes.c +44 -0
  166. data/ext/libuv/test/benchmark-spawn.c +162 -0
  167. data/ext/libuv/test/benchmark-tcp-write-batch.c +140 -0
  168. data/ext/libuv/test/benchmark-thread.c +64 -0
  169. data/ext/libuv/test/benchmark-udp-packet-storm.c +247 -0
  170. data/ext/libuv/test/blackhole-server.c +118 -0
  171. data/ext/libuv/test/dns-server.c +321 -0
  172. data/ext/libuv/test/echo-server.c +378 -0
  173. data/ext/libuv/test/fixtures/empty_file +0 -0
  174. data/ext/libuv/test/fixtures/load_error.node +1 -0
  175. data/ext/libuv/test/run-benchmarks.c +64 -0
  176. data/ext/libuv/test/run-tests.c +138 -0
  177. data/ext/libuv/test/runner-unix.c +295 -0
  178. data/ext/libuv/test/runner-unix.h +36 -0
  179. data/ext/libuv/test/runner-win.c +285 -0
  180. data/ext/libuv/test/runner-win.h +42 -0
  181. data/ext/libuv/test/runner.c +355 -0
  182. data/ext/libuv/test/runner.h +159 -0
  183. data/ext/libuv/test/task.h +112 -0
  184. data/ext/libuv/test/test-async.c +118 -0
  185. data/ext/libuv/test/test-callback-order.c +76 -0
  186. data/ext/libuv/test/test-callback-stack.c +203 -0
  187. data/ext/libuv/test/test-connection-fail.c +148 -0
  188. data/ext/libuv/test/test-cwd-and-chdir.c +64 -0
  189. data/ext/libuv/test/test-delayed-accept.c +188 -0
  190. data/ext/libuv/test/test-dlerror.c +58 -0
  191. data/ext/libuv/test/test-error.c +59 -0
  192. data/ext/libuv/test/test-fail-always.c +29 -0
  193. data/ext/libuv/test/test-fs-event.c +474 -0
  194. data/ext/libuv/test/test-fs-poll.c +146 -0
  195. data/ext/libuv/test/test-fs.c +1843 -0
  196. data/ext/libuv/test/test-get-currentexe.c +63 -0
  197. data/ext/libuv/test/test-get-loadavg.c +36 -0
  198. data/ext/libuv/test/test-get-memory.c +38 -0
  199. data/ext/libuv/test/test-getaddrinfo.c +122 -0
  200. data/ext/libuv/test/test-getsockname.c +342 -0
  201. data/ext/libuv/test/test-hrtime.c +54 -0
  202. data/ext/libuv/test/test-idle.c +81 -0
  203. data/ext/libuv/test/test-ipc-send-recv.c +209 -0
  204. data/ext/libuv/test/test-ipc.c +620 -0
  205. data/ext/libuv/test/test-list.h +427 -0
  206. data/ext/libuv/test/test-loop-handles.c +336 -0
  207. data/ext/libuv/test/test-multiple-listen.c +102 -0
  208. data/ext/libuv/test/test-mutexes.c +63 -0
  209. data/ext/libuv/test/test-pass-always.c +28 -0
  210. data/ext/libuv/test/test-ping-pong.c +253 -0
  211. data/ext/libuv/test/test-pipe-bind-error.c +140 -0
  212. data/ext/libuv/test/test-pipe-connect-error.c +96 -0
  213. data/ext/libuv/test/test-platform-output.c +87 -0
  214. data/ext/libuv/test/test-poll-close.c +72 -0
  215. data/ext/libuv/test/test-poll.c +573 -0
  216. data/ext/libuv/test/test-process-title.c +49 -0
  217. data/ext/libuv/test/test-ref.c +338 -0
  218. data/ext/libuv/test/test-run-once.c +48 -0
  219. data/ext/libuv/test/test-semaphore.c +111 -0
  220. data/ext/libuv/test/test-shutdown-close.c +103 -0
  221. data/ext/libuv/test/test-shutdown-eof.c +183 -0
  222. data/ext/libuv/test/test-signal.c +162 -0
  223. data/ext/libuv/test/test-spawn.c +863 -0
  224. data/ext/libuv/test/test-stdio-over-pipes.c +246 -0
  225. data/ext/libuv/test/test-tcp-bind-error.c +191 -0
  226. data/ext/libuv/test/test-tcp-bind6-error.c +154 -0
  227. data/ext/libuv/test/test-tcp-close-while-connecting.c +80 -0
  228. data/ext/libuv/test/test-tcp-close.c +129 -0
  229. data/ext/libuv/test/test-tcp-connect-error-after-write.c +95 -0
  230. data/ext/libuv/test/test-tcp-connect-error.c +70 -0
  231. data/ext/libuv/test/test-tcp-connect-timeout.c +85 -0
  232. data/ext/libuv/test/test-tcp-connect6-error.c +68 -0
  233. data/ext/libuv/test/test-tcp-flags.c +51 -0
  234. data/ext/libuv/test/test-tcp-shutdown-after-write.c +131 -0
  235. data/ext/libuv/test/test-tcp-unexpected-read.c +113 -0
  236. data/ext/libuv/test/test-tcp-write-error.c +168 -0
  237. data/ext/libuv/test/test-tcp-write-to-half-open-connection.c +135 -0
  238. data/ext/libuv/test/test-tcp-writealot.c +170 -0
  239. data/ext/libuv/test/test-thread.c +183 -0
  240. data/ext/libuv/test/test-threadpool.c +57 -0
  241. data/ext/libuv/test/test-timer-again.c +141 -0
  242. data/ext/libuv/test/test-timer.c +152 -0
  243. data/ext/libuv/test/test-tty.c +110 -0
  244. data/ext/libuv/test/test-udp-dgram-too-big.c +86 -0
  245. data/ext/libuv/test/test-udp-ipv6.c +156 -0
  246. data/ext/libuv/test/test-udp-multicast-join.c +139 -0
  247. data/ext/libuv/test/test-udp-multicast-ttl.c +86 -0
  248. data/ext/libuv/test/test-udp-options.c +86 -0
  249. data/ext/libuv/test/test-udp-send-and-recv.c +208 -0
  250. data/ext/libuv/test/test-util.c +97 -0
  251. data/ext/libuv/test/test-walk-handles.c +77 -0
  252. data/ext/libuv/uv.gyp +375 -0
  253. data/ext/libuv/vcbuild.bat +105 -0
  254. data/foolio.gemspec +18 -0
  255. data/lib/foolio.rb +9 -0
  256. data/lib/foolio/handle.rb +27 -0
  257. data/lib/foolio/listener.rb +26 -0
  258. data/lib/foolio/loop.rb +79 -0
  259. data/lib/foolio/stream.rb +109 -0
  260. data/lib/foolio/version.rb +3 -0
  261. metadata +309 -0
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/foolio/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["mzp"]
6
+ gem.email = ["mzpppp@gmail.com"]
7
+ gem.description = "Wow"
8
+ gem.summary = "Wow"
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.extensions = ['ext/foolio/extconf.rb']
13
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.name = "foolio"
16
+ gem.require_paths = ["lib", "ext"]
17
+ gem.version = Foolio::VERSION
18
+ end
@@ -0,0 +1,9 @@
1
+ require "foolio/version"
2
+ require "foolio/foolio_ext"
3
+ require "foolio/handle"
4
+ require "foolio/listener"
5
+ require "foolio/loop"
6
+ require "foolio/stream"
7
+
8
+ module Foolio
9
+ end
@@ -0,0 +1,27 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ module Foolio
4
+ class Handle
5
+ def initialize(loop, handle)
6
+ @loop = loop
7
+ @handle = handle
8
+ end
9
+
10
+ def callback(&block)
11
+ @loop.callback &block
12
+ end
13
+ end
14
+
15
+ class Idle < Foolio::Handle
16
+ def start(&block)
17
+ Foolio::UV.idle_start(@handle, callback(&block))
18
+ end
19
+ end
20
+
21
+ class Timer < Foolio::Handle
22
+ def start(interval, &block)
23
+ sec = (interval * 1000).to_i
24
+ Foolio::UV.timer_start(@handle, callback(&block), sec, sec)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ module Foolio
4
+ module Listener
5
+ def callback(&f)
6
+ const_name = "Callback_#{f.object_id}"
7
+ unless self.class.const_defined?(const_name)
8
+ callbacks << const_name
9
+ self.class.const_set(const_name, f)
10
+ end
11
+ self.class.const_get(const_name)
12
+ end
13
+
14
+ private
15
+ def callbacks
16
+ @callbacks ||= Set.new
17
+ end
18
+
19
+ def clear_callbacks
20
+ callbacks.each do |name|
21
+ self.class.send(:remove_const, name)
22
+ end
23
+ callbacks.clear
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,79 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ module Foolio
4
+ class Loop
5
+ include Foolio::Listener
6
+ attr_reader :loop
7
+ class << self
8
+ def default
9
+ self.new Foolio::UV.default_loop
10
+ end
11
+
12
+ def create
13
+ self.new Foolio::UV.loop_new
14
+ end
15
+ end
16
+
17
+ def initialize(loop)
18
+ @loop = loop
19
+
20
+ timer.start(1) do
21
+ if @stop
22
+ Foolio::UV.close_all(@loop, callback{
23
+ clear_callbacks
24
+ })
25
+ end
26
+ end
27
+ end
28
+
29
+ def idle
30
+ Foolio::Idle.new(self, Foolio::UV.idle_init(@loop))
31
+ end
32
+
33
+ def timer
34
+ Foolio::Timer.new(self, Foolio::UV.timer_init(@loop))
35
+ end
36
+
37
+ def tcp(ip, port)
38
+ handle = Foolio::UV.tcp_init(@loop)
39
+ @socket = Foolio::UV.ip4_addr(ip, port)
40
+ Foolio::UV.tcp_bind(handle, @socket)
41
+ Foolio::TCP.new self, handle
42
+ end
43
+
44
+ def udp
45
+ handle = Foolio::UV.udp_init(@loop)
46
+ Foolio::UDP.new self, handle
47
+ end
48
+
49
+ def unix(path, ipc = 0)
50
+ handle = Foolio::UV.pipe_init(@loop, ipc)
51
+ Foolio::UV.pipe_bind(handle, path)
52
+ Foolio::Pipe.new self, handle
53
+ end
54
+
55
+ def file_stat(path, &block)
56
+ cb = callback{|event, _|
57
+ block[path, event]
58
+ }
59
+ Foolio::UV.fs_event_init(@loop, path, cb, 0)
60
+ end
61
+
62
+ def run
63
+ Foolio::UV.run @loop
64
+ end
65
+
66
+ def alive?
67
+ not @stop
68
+ end
69
+
70
+ def stop
71
+ @stop = true
72
+ end
73
+
74
+ def force_stop
75
+ @stop = true
76
+ Foolio::UV.loop_delete @loop
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,109 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ module Foolio
4
+ class Handler
5
+ include Foolio::Listener
6
+
7
+ def initialize(handle)
8
+ @handle = handle
9
+ end
10
+
11
+ def write(data)
12
+ Foolio::UV.write(nil, @handle, data, callback{|status|
13
+ on_write_complete(status)})
14
+ end
15
+
16
+ def close
17
+ $log.info "close #{@handle}"
18
+ Foolio::UV.close(@handle, callback{
19
+ clear_callbacks
20
+ })
21
+ end
22
+
23
+ def on_write_complete(err); end
24
+ def on_connect; end
25
+ def on_close; end
26
+
27
+ def on_recv(data)
28
+ if data then
29
+ on_read(data)
30
+ else
31
+ close
32
+ end
33
+ end
34
+
35
+ def start
36
+ Foolio::UV.read_start(@handle, callback(&method(:on_recv)))
37
+ end
38
+ end
39
+
40
+ class BlockHandler < Foolio::Handler
41
+ def initialize(io, block)
42
+ super(io)
43
+ @block = block
44
+ end
45
+
46
+ def on_connect; end
47
+ def on_close; end
48
+
49
+ def on_read(data)
50
+ @block.call data
51
+ end
52
+ end
53
+
54
+ class Stream < Foolio::Handle
55
+ def listen_handler(backlog, klass, *args)
56
+ @klass = klass
57
+ @args = args
58
+ Foolio::UV.listen(@handle, backlog, callback(&method(:on_connect)))
59
+ self
60
+ end
61
+
62
+ def on_connect(status)
63
+ client = init
64
+ Foolio::UV.accept(@handle, client)
65
+ $log.info "accept #{client}"
66
+ handle = @klass.new(client, *@args)
67
+ handle.on_connect
68
+ handle.start
69
+ end
70
+
71
+ def listen(backlog=5, &block)
72
+ listen_handler(backlog, BlockHandler, block)
73
+ end
74
+ end
75
+
76
+ class TCP < Stream
77
+ def init
78
+ Foolio::UV.tcp_init(@loop.loop)
79
+ end
80
+ end
81
+
82
+ class Pipe < Stream
83
+ def init
84
+ Foolio::UV.pipe_init(@loop.loop, 0)
85
+ end
86
+ end
87
+
88
+ class UDP < Foolio::Handle
89
+ def bind(ip,port)
90
+ @socket = Foolio::UV.ip4_addr(ip, port)
91
+ Foolio::UV.udp_bind(@handle, @socket, 0)
92
+ self
93
+ end
94
+
95
+ def start(&block)
96
+ on_recv = callback do|data, addr, flags|
97
+ ip = Foolio::UV.ip_name addr
98
+ port = Foolio::UV.port addr
99
+ block.call(ip, port, data) if ip
100
+ end
101
+ Foolio::UV.udp_recv_start(@handle, on_recv)
102
+ end
103
+
104
+ def send(ip, port, data)
105
+ on_send = proc {|_|}
106
+ Foolio::UV.udp_send(nil, @handle, data, Foolio::UV.ip4_addr(ip, port), on_send)
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,3 @@
1
+ module Foolio
2
+ VERSION = "0.0.3"
3
+ end
metadata ADDED
@@ -0,0 +1,309 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: foolio
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - mzp
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-10 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Wow
15
+ email:
16
+ - mzpppp@gmail.com
17
+ executables: []
18
+ extensions:
19
+ - ext/foolio/extconf.rb
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE
25
+ - README.md
26
+ - Rakefile
27
+ - examples/timer.rb
28
+ - ext/foolio/extconf.rb
29
+ - ext/foolio/foolio_ext.c
30
+ - ext/foolio/gen.rb
31
+ - ext/foolio/make_table.rb
32
+ - ext/foolio/templ
33
+ - ext/libuv/.gitignore
34
+ - ext/libuv/.mailmap
35
+ - ext/libuv/.travis.yml
36
+ - ext/libuv/AUTHORS
37
+ - ext/libuv/LICENSE
38
+ - ext/libuv/Makefile
39
+ - ext/libuv/README.md
40
+ - ext/libuv/common.gypi
41
+ - ext/libuv/config-mingw.mk
42
+ - ext/libuv/config-unix.mk
43
+ - ext/libuv/gyp_uv
44
+ - ext/libuv/include/uv-private/eio.h
45
+ - ext/libuv/include/uv-private/ev.h
46
+ - ext/libuv/include/uv-private/ngx-queue.h
47
+ - ext/libuv/include/uv-private/tree.h
48
+ - ext/libuv/include/uv-private/uv-unix.h
49
+ - ext/libuv/include/uv-private/uv-win.h
50
+ - ext/libuv/include/uv.h
51
+ - ext/libuv/src/fs-poll.c
52
+ - ext/libuv/src/inet.c
53
+ - ext/libuv/src/unix/async.c
54
+ - ext/libuv/src/unix/core.c
55
+ - ext/libuv/src/unix/cygwin.c
56
+ - ext/libuv/src/unix/darwin.c
57
+ - ext/libuv/src/unix/dl.c
58
+ - ext/libuv/src/unix/eio/Changes
59
+ - ext/libuv/src/unix/eio/LICENSE
60
+ - ext/libuv/src/unix/eio/Makefile.am
61
+ - ext/libuv/src/unix/eio/aclocal.m4
62
+ - ext/libuv/src/unix/eio/autogen.sh
63
+ - ext/libuv/src/unix/eio/config.h.in
64
+ - ext/libuv/src/unix/eio/config_cygwin.h
65
+ - ext/libuv/src/unix/eio/config_darwin.h
66
+ - ext/libuv/src/unix/eio/config_freebsd.h
67
+ - ext/libuv/src/unix/eio/config_linux.h
68
+ - ext/libuv/src/unix/eio/config_netbsd.h
69
+ - ext/libuv/src/unix/eio/config_openbsd.h
70
+ - ext/libuv/src/unix/eio/config_sunos.h
71
+ - ext/libuv/src/unix/eio/configure.ac
72
+ - ext/libuv/src/unix/eio/demo.c
73
+ - ext/libuv/src/unix/eio/ecb.h
74
+ - ext/libuv/src/unix/eio/eio.3
75
+ - ext/libuv/src/unix/eio/eio.c
76
+ - ext/libuv/src/unix/eio/eio.pod
77
+ - ext/libuv/src/unix/eio/libeio.m4
78
+ - ext/libuv/src/unix/eio/xthread.h
79
+ - ext/libuv/src/unix/error.c
80
+ - ext/libuv/src/unix/ev/Changes
81
+ - ext/libuv/src/unix/ev/LICENSE
82
+ - ext/libuv/src/unix/ev/Makefile.am
83
+ - ext/libuv/src/unix/ev/Makefile.in
84
+ - ext/libuv/src/unix/ev/README
85
+ - ext/libuv/src/unix/ev/aclocal.m4
86
+ - ext/libuv/src/unix/ev/autogen.sh
87
+ - ext/libuv/src/unix/ev/config.guess
88
+ - ext/libuv/src/unix/ev/config.h.in
89
+ - ext/libuv/src/unix/ev/config.sub
90
+ - ext/libuv/src/unix/ev/config_cygwin.h
91
+ - ext/libuv/src/unix/ev/config_darwin.h
92
+ - ext/libuv/src/unix/ev/config_freebsd.h
93
+ - ext/libuv/src/unix/ev/config_linux.h
94
+ - ext/libuv/src/unix/ev/config_netbsd.h
95
+ - ext/libuv/src/unix/ev/config_openbsd.h
96
+ - ext/libuv/src/unix/ev/config_sunos.h
97
+ - ext/libuv/src/unix/ev/configure
98
+ - ext/libuv/src/unix/ev/configure.ac
99
+ - ext/libuv/src/unix/ev/depcomp
100
+ - ext/libuv/src/unix/ev/ev++.h
101
+ - ext/libuv/src/unix/ev/ev.3
102
+ - ext/libuv/src/unix/ev/ev.c
103
+ - ext/libuv/src/unix/ev/ev.pod
104
+ - ext/libuv/src/unix/ev/ev_epoll.c
105
+ - ext/libuv/src/unix/ev/ev_kqueue.c
106
+ - ext/libuv/src/unix/ev/ev_poll.c
107
+ - ext/libuv/src/unix/ev/ev_port.c
108
+ - ext/libuv/src/unix/ev/ev_select.c
109
+ - ext/libuv/src/unix/ev/ev_vars.h
110
+ - ext/libuv/src/unix/ev/ev_win32.c
111
+ - ext/libuv/src/unix/ev/ev_wrap.h
112
+ - ext/libuv/src/unix/ev/event.c
113
+ - ext/libuv/src/unix/ev/event.h
114
+ - ext/libuv/src/unix/ev/install-sh
115
+ - ext/libuv/src/unix/ev/libev.m4
116
+ - ext/libuv/src/unix/ev/ltmain.sh
117
+ - ext/libuv/src/unix/ev/missing
118
+ - ext/libuv/src/unix/ev/mkinstalldirs
119
+ - ext/libuv/src/unix/freebsd.c
120
+ - ext/libuv/src/unix/fs.c
121
+ - ext/libuv/src/unix/internal.h
122
+ - ext/libuv/src/unix/kqueue.c
123
+ - ext/libuv/src/unix/linux/inotify.c
124
+ - ext/libuv/src/unix/linux/linux-core.c
125
+ - ext/libuv/src/unix/linux/syscalls.c
126
+ - ext/libuv/src/unix/linux/syscalls.h
127
+ - ext/libuv/src/unix/loop-watcher.c
128
+ - ext/libuv/src/unix/loop.c
129
+ - ext/libuv/src/unix/netbsd.c
130
+ - ext/libuv/src/unix/openbsd.c
131
+ - ext/libuv/src/unix/pipe.c
132
+ - ext/libuv/src/unix/poll.c
133
+ - ext/libuv/src/unix/process.c
134
+ - ext/libuv/src/unix/signal.c
135
+ - ext/libuv/src/unix/stream.c
136
+ - ext/libuv/src/unix/sunos.c
137
+ - ext/libuv/src/unix/tcp.c
138
+ - ext/libuv/src/unix/thread.c
139
+ - ext/libuv/src/unix/timer.c
140
+ - ext/libuv/src/unix/tty.c
141
+ - ext/libuv/src/unix/udp.c
142
+ - ext/libuv/src/unix/uv-eio.c
143
+ - ext/libuv/src/unix/uv-eio.h
144
+ - ext/libuv/src/uv-common.c
145
+ - ext/libuv/src/uv-common.h
146
+ - ext/libuv/src/win/async.c
147
+ - ext/libuv/src/win/atomicops-inl.h
148
+ - ext/libuv/src/win/core.c
149
+ - ext/libuv/src/win/dl.c
150
+ - ext/libuv/src/win/error.c
151
+ - ext/libuv/src/win/fs-event.c
152
+ - ext/libuv/src/win/fs.c
153
+ - ext/libuv/src/win/getaddrinfo.c
154
+ - ext/libuv/src/win/handle-inl.h
155
+ - ext/libuv/src/win/handle.c
156
+ - ext/libuv/src/win/internal.h
157
+ - ext/libuv/src/win/loop-watcher.c
158
+ - ext/libuv/src/win/pipe.c
159
+ - ext/libuv/src/win/poll.c
160
+ - ext/libuv/src/win/process-stdio.c
161
+ - ext/libuv/src/win/process.c
162
+ - ext/libuv/src/win/req-inl.h
163
+ - ext/libuv/src/win/req.c
164
+ - ext/libuv/src/win/signal.c
165
+ - ext/libuv/src/win/stream-inl.h
166
+ - ext/libuv/src/win/stream.c
167
+ - ext/libuv/src/win/tcp.c
168
+ - ext/libuv/src/win/thread.c
169
+ - ext/libuv/src/win/threadpool.c
170
+ - ext/libuv/src/win/timer.c
171
+ - ext/libuv/src/win/tty.c
172
+ - ext/libuv/src/win/udp.c
173
+ - ext/libuv/src/win/util.c
174
+ - ext/libuv/src/win/winapi.c
175
+ - ext/libuv/src/win/winapi.h
176
+ - ext/libuv/src/win/winsock.c
177
+ - ext/libuv/src/win/winsock.h
178
+ - ext/libuv/test/benchmark-async-pummel.c
179
+ - ext/libuv/test/benchmark-async.c
180
+ - ext/libuv/test/benchmark-fs-stat.c
181
+ - ext/libuv/test/benchmark-getaddrinfo.c
182
+ - ext/libuv/test/benchmark-list.h
183
+ - ext/libuv/test/benchmark-loop-count.c
184
+ - ext/libuv/test/benchmark-million-timers.c
185
+ - ext/libuv/test/benchmark-ping-pongs.c
186
+ - ext/libuv/test/benchmark-pound.c
187
+ - ext/libuv/test/benchmark-pump.c
188
+ - ext/libuv/test/benchmark-sizes.c
189
+ - ext/libuv/test/benchmark-spawn.c
190
+ - ext/libuv/test/benchmark-tcp-write-batch.c
191
+ - ext/libuv/test/benchmark-thread.c
192
+ - ext/libuv/test/benchmark-udp-packet-storm.c
193
+ - ext/libuv/test/blackhole-server.c
194
+ - ext/libuv/test/dns-server.c
195
+ - ext/libuv/test/echo-server.c
196
+ - ext/libuv/test/fixtures/empty_file
197
+ - ext/libuv/test/fixtures/load_error.node
198
+ - ext/libuv/test/run-benchmarks.c
199
+ - ext/libuv/test/run-tests.c
200
+ - ext/libuv/test/runner-unix.c
201
+ - ext/libuv/test/runner-unix.h
202
+ - ext/libuv/test/runner-win.c
203
+ - ext/libuv/test/runner-win.h
204
+ - ext/libuv/test/runner.c
205
+ - ext/libuv/test/runner.h
206
+ - ext/libuv/test/task.h
207
+ - ext/libuv/test/test-async.c
208
+ - ext/libuv/test/test-callback-order.c
209
+ - ext/libuv/test/test-callback-stack.c
210
+ - ext/libuv/test/test-connection-fail.c
211
+ - ext/libuv/test/test-cwd-and-chdir.c
212
+ - ext/libuv/test/test-delayed-accept.c
213
+ - ext/libuv/test/test-dlerror.c
214
+ - ext/libuv/test/test-error.c
215
+ - ext/libuv/test/test-fail-always.c
216
+ - ext/libuv/test/test-fs-event.c
217
+ - ext/libuv/test/test-fs-poll.c
218
+ - ext/libuv/test/test-fs.c
219
+ - ext/libuv/test/test-get-currentexe.c
220
+ - ext/libuv/test/test-get-loadavg.c
221
+ - ext/libuv/test/test-get-memory.c
222
+ - ext/libuv/test/test-getaddrinfo.c
223
+ - ext/libuv/test/test-getsockname.c
224
+ - ext/libuv/test/test-hrtime.c
225
+ - ext/libuv/test/test-idle.c
226
+ - ext/libuv/test/test-ipc-send-recv.c
227
+ - ext/libuv/test/test-ipc.c
228
+ - ext/libuv/test/test-list.h
229
+ - ext/libuv/test/test-loop-handles.c
230
+ - ext/libuv/test/test-multiple-listen.c
231
+ - ext/libuv/test/test-mutexes.c
232
+ - ext/libuv/test/test-pass-always.c
233
+ - ext/libuv/test/test-ping-pong.c
234
+ - ext/libuv/test/test-pipe-bind-error.c
235
+ - ext/libuv/test/test-pipe-connect-error.c
236
+ - ext/libuv/test/test-platform-output.c
237
+ - ext/libuv/test/test-poll-close.c
238
+ - ext/libuv/test/test-poll.c
239
+ - ext/libuv/test/test-process-title.c
240
+ - ext/libuv/test/test-ref.c
241
+ - ext/libuv/test/test-run-once.c
242
+ - ext/libuv/test/test-semaphore.c
243
+ - ext/libuv/test/test-shutdown-close.c
244
+ - ext/libuv/test/test-shutdown-eof.c
245
+ - ext/libuv/test/test-signal.c
246
+ - ext/libuv/test/test-spawn.c
247
+ - ext/libuv/test/test-stdio-over-pipes.c
248
+ - ext/libuv/test/test-tcp-bind-error.c
249
+ - ext/libuv/test/test-tcp-bind6-error.c
250
+ - ext/libuv/test/test-tcp-close-while-connecting.c
251
+ - ext/libuv/test/test-tcp-close.c
252
+ - ext/libuv/test/test-tcp-connect-error-after-write.c
253
+ - ext/libuv/test/test-tcp-connect-error.c
254
+ - ext/libuv/test/test-tcp-connect-timeout.c
255
+ - ext/libuv/test/test-tcp-connect6-error.c
256
+ - ext/libuv/test/test-tcp-flags.c
257
+ - ext/libuv/test/test-tcp-shutdown-after-write.c
258
+ - ext/libuv/test/test-tcp-unexpected-read.c
259
+ - ext/libuv/test/test-tcp-write-error.c
260
+ - ext/libuv/test/test-tcp-write-to-half-open-connection.c
261
+ - ext/libuv/test/test-tcp-writealot.c
262
+ - ext/libuv/test/test-thread.c
263
+ - ext/libuv/test/test-threadpool.c
264
+ - ext/libuv/test/test-timer-again.c
265
+ - ext/libuv/test/test-timer.c
266
+ - ext/libuv/test/test-tty.c
267
+ - ext/libuv/test/test-udp-dgram-too-big.c
268
+ - ext/libuv/test/test-udp-ipv6.c
269
+ - ext/libuv/test/test-udp-multicast-join.c
270
+ - ext/libuv/test/test-udp-multicast-ttl.c
271
+ - ext/libuv/test/test-udp-options.c
272
+ - ext/libuv/test/test-udp-send-and-recv.c
273
+ - ext/libuv/test/test-util.c
274
+ - ext/libuv/test/test-walk-handles.c
275
+ - ext/libuv/uv.gyp
276
+ - ext/libuv/vcbuild.bat
277
+ - foolio.gemspec
278
+ - lib/foolio.rb
279
+ - lib/foolio/handle.rb
280
+ - lib/foolio/listener.rb
281
+ - lib/foolio/loop.rb
282
+ - lib/foolio/stream.rb
283
+ - lib/foolio/version.rb
284
+ homepage: ''
285
+ licenses: []
286
+ post_install_message:
287
+ rdoc_options: []
288
+ require_paths:
289
+ - lib
290
+ - ext
291
+ required_ruby_version: !ruby/object:Gem::Requirement
292
+ none: false
293
+ requirements:
294
+ - - ! '>='
295
+ - !ruby/object:Gem::Version
296
+ version: '0'
297
+ required_rubygems_version: !ruby/object:Gem::Requirement
298
+ none: false
299
+ requirements:
300
+ - - ! '>='
301
+ - !ruby/object:Gem::Version
302
+ version: '0'
303
+ requirements: []
304
+ rubyforge_project:
305
+ rubygems_version: 1.8.24
306
+ signing_key:
307
+ specification_version: 3
308
+ summary: Wow
309
+ test_files: []