eventmachine 1.0.0.beta.3 → 1.0.0.beta.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/.gitignore +5 -0
  2. data/.yardopts +5 -1
  3. data/{docs/GNU → GNU} +0 -0
  4. data/Gemfile +1 -0
  5. data/{docs/COPYING → LICENSE} +0 -0
  6. data/README.md +109 -0
  7. data/Rakefile +8 -0
  8. data/docs/DocumentationGuidesIndex.md +27 -0
  9. data/docs/GettingStarted.md +521 -0
  10. data/docs/{ChangeLog → old/ChangeLog} +0 -0
  11. data/docs/{DEFERRABLES → old/DEFERRABLES} +0 -0
  12. data/docs/{EPOLL → old/EPOLL} +0 -0
  13. data/docs/{INSTALL → old/INSTALL} +0 -0
  14. data/docs/{KEYBOARD → old/KEYBOARD} +0 -0
  15. data/docs/{LEGAL → old/LEGAL} +0 -0
  16. data/docs/{LIGHTWEIGHT_CONCURRENCY → old/LIGHTWEIGHT_CONCURRENCY} +0 -0
  17. data/docs/{PURE_RUBY → old/PURE_RUBY} +0 -0
  18. data/docs/{RELEASE_NOTES → old/RELEASE_NOTES} +0 -0
  19. data/docs/{SMTP → old/SMTP} +0 -0
  20. data/docs/{SPAWNED_PROCESSES → old/SPAWNED_PROCESSES} +0 -0
  21. data/docs/{TODO → old/TODO} +0 -0
  22. data/eventmachine.gemspec +4 -1
  23. data/examples/guides/getting_started/01_eventmachine_echo_server.rb +18 -0
  24. data/examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb +22 -0
  25. data/examples/guides/getting_started/03_simple_chat_server.rb +149 -0
  26. data/examples/guides/getting_started/04_simple_chat_server_step_one.rb +27 -0
  27. data/examples/guides/getting_started/05_simple_chat_server_step_two.rb +43 -0
  28. data/examples/guides/getting_started/06_simple_chat_server_step_three.rb +98 -0
  29. data/examples/guides/getting_started/07_simple_chat_server_step_four.rb +121 -0
  30. data/examples/guides/getting_started/08_simple_chat_server_step_five.rb +141 -0
  31. data/examples/{ex_channel.rb → old/ex_channel.rb} +3 -3
  32. data/examples/{ex_queue.rb → old/ex_queue.rb} +0 -0
  33. data/examples/{ex_tick_loop_array.rb → old/ex_tick_loop_array.rb} +0 -0
  34. data/examples/{ex_tick_loop_counter.rb → old/ex_tick_loop_counter.rb} +0 -0
  35. data/examples/{helper.rb → old/helper.rb} +0 -0
  36. data/ext/cmain.cpp +3 -3
  37. data/ext/ed.cpp +90 -15
  38. data/ext/ed.h +5 -5
  39. data/ext/em.cpp +47 -55
  40. data/ext/em.h +12 -2
  41. data/ext/pipe.cpp +2 -2
  42. data/ext/project.h +1 -1
  43. data/ext/rubymain.cpp +48 -3
  44. data/ext/ssl.cpp +5 -0
  45. data/java/src/com/rubyeventmachine/EmReactor.java +2 -2
  46. data/lib/em/buftok.rb +35 -63
  47. data/lib/em/callback.rb +43 -11
  48. data/lib/em/channel.rb +21 -14
  49. data/lib/em/completion.rb +304 -0
  50. data/lib/em/connection.rb +339 -209
  51. data/lib/em/deferrable.rb +4 -0
  52. data/lib/em/deferrable/pool.rb +2 -0
  53. data/lib/em/file_watch.rb +37 -18
  54. data/lib/em/iterator.rb +42 -42
  55. data/lib/em/pool.rb +146 -0
  56. data/lib/em/process_watch.rb +5 -4
  57. data/lib/em/processes.rb +8 -4
  58. data/lib/em/protocols/httpclient.rb +22 -11
  59. data/lib/em/protocols/httpclient2.rb +15 -5
  60. data/lib/em/protocols/line_protocol.rb +2 -1
  61. data/lib/em/protocols/memcache.rb +17 -9
  62. data/lib/em/protocols/object_protocol.rb +2 -1
  63. data/lib/em/protocols/postgres3.rb +8 -9
  64. data/lib/em/protocols/smtpclient.rb +19 -11
  65. data/lib/em/protocols/smtpserver.rb +1 -1
  66. data/lib/em/protocols/stomp.rb +8 -6
  67. data/lib/em/protocols/tcptest.rb +3 -2
  68. data/lib/em/pure_ruby.rb +212 -208
  69. data/lib/em/queue.rb +22 -13
  70. data/lib/em/resolver.rb +70 -64
  71. data/lib/em/spawnable.rb +6 -3
  72. data/lib/em/streamer.rb +33 -45
  73. data/lib/em/threaded_resource.rb +90 -0
  74. data/lib/em/timers.rb +6 -2
  75. data/lib/em/version.rb +1 -1
  76. data/lib/eventmachine.rb +538 -602
  77. data/lib/jeventmachine.rb +22 -1
  78. data/tasks/package.rake +12 -2
  79. data/tasks/test.rake +1 -0
  80. data/tests/em_test_helper.rb +12 -3
  81. data/tests/test_completion.rb +177 -0
  82. data/tests/test_epoll.rb +2 -2
  83. data/tests/test_httpclient.rb +9 -9
  84. data/tests/test_httpclient2.rb +11 -9
  85. data/tests/test_ltp.rb +2 -10
  86. data/tests/test_pool.rb +128 -0
  87. data/tests/test_processes.rb +20 -2
  88. data/tests/test_queue.rb +8 -0
  89. data/tests/test_resolver.rb +1 -1
  90. data/tests/test_set_sock_opt.rb +37 -0
  91. data/tests/test_shutdown_hooks.rb +23 -0
  92. data/tests/test_threaded_resource.rb +53 -0
  93. data/tests/test_unbind_reason.rb +31 -0
  94. metadata +262 -192
  95. data/README +0 -81
  96. data/tasks/doc.rake +0 -30
data/README DELETED
@@ -1,81 +0,0 @@
1
- = RUBY/EventMachine
2
-
3
- Homepage:: http://rubyeventmachine.com
4
- Rubyforge Page:: http://rubyforge.org/projects/eventmachine
5
- Google Group:: http://groups.google.com/group/eventmachine
6
- RDoc:: http://eventmachine.rubyforge.org
7
- IRC:: #eventmachine on irc.freenode.net
8
- Copyright:: (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
9
- Email:: gmail address: garbagecat10
10
-
11
- EventMachine is copyrighted free software made available under the terms
12
- of either the GPL or Ruby's License. See the file COPYING for full licensing
13
- information.
14
- See EventMachine and EventMachine::Connection for documentation and
15
- usage examples.
16
-
17
- EventMachine implements a fast, single-threaded engine for arbitrary network
18
- communications. It's extremely easy to use in Ruby. EventMachine wraps all
19
- interactions with IP sockets, allowing programs to concentrate on the
20
- implementation of network protocols. It can be used to create both network
21
- servers and clients. To create a server or client, a Ruby program only needs
22
- to specify the IP address and port, and provide a Module that implements the
23
- communications protocol. Implementations of several standard network protocols
24
- are provided with the package, primarily to serve as examples. The real goal
25
- of EventMachine is to enable programs to easily interface with other programs
26
- using TCP/IP, especially if custom protocols are required.
27
-
28
- A Ruby program uses EventMachine by registering the addresses and ports of
29
- network servers and clients, and then entering an event-handling loop.
30
- EventMachine contains glue code in Ruby which will execute callbacks to
31
- user-supplied code for all significant events occurring in the clients
32
- and servers. These events include connection acceptance, startup, data-receipt,
33
- shutdown, and timer events. Arbitrary processing can be performed by user code
34
- during event callbacks, including sending data to one or more remote network
35
- peers, startup and shutdown of network connections, and installation of new
36
- event handlers.
37
-
38
- The EventMachine implements a very familiar model for network programming.
39
- It emphasizes: 1) the maximum possible isolation of user code from network
40
- objects like sockets; 2) maximum performance and scalability; and 3) extreme
41
- ease-of-use for user code. It attempts to provide a higher-level interface
42
- than similar projects which expose a variety of low-level event-handling
43
- and networking objects to Ruby programs.
44
-
45
- The design and implementation of EventMachine grows out of nearly ten years
46
- of experience writing high-performance, high-scaling network server applications.
47
- We have taken particular account of the challenges and lessons described as
48
- the "C10K problem" by Dan Kegel and others.
49
-
50
- EventMachine consists of an extension library written in C++ (which can be
51
- accessed from languages other than Ruby), and a Ruby module which can be dropped
52
- into user programs. On most platforms, EventMachine uses the
53
- <tt>select(2)</tt> system call,
54
- so it will run on a large range of Unix-like systems and on Microsoft
55
- Windows with good performance and scalability. On Linux 2.6 kernels, EventMachine
56
- automatically configures itself to use <tt>epoll(4)</tt> instead of
57
- <tt>select(2),</tt> so scalability on that platform can be significantly
58
- improved.
59
-
60
- Here's a fully-functional echo server written with EventMachine:
61
-
62
- require 'eventmachine'
63
-
64
- module EchoServer
65
- def post_init
66
- puts "-- someone connected to the echo server!"
67
- end
68
-
69
- def receive_data data
70
- send_data ">>>you sent: #{data}"
71
- close_connection if data =~ /quit/i
72
- end
73
-
74
- def unbind
75
- puts "-- someone disconnected from the echo server!"
76
- end
77
- end
78
-
79
- EventMachine::run {
80
- EventMachine::start_server "127.0.0.1", 8081, EchoServer
81
- }
@@ -1,30 +0,0 @@
1
- rdoc_task_type = begin
2
- require 'rdoc/task'
3
- RDoc::Task
4
- rescue LoadError
5
- require 'rake/rdoctask'
6
- Rake::RDocTask
7
- end
8
-
9
- df = begin; require 'rdoc/rdoc'; require 'rdoc/generator/darkfish'; true; rescue LoadError; end
10
-
11
- rdtask = rdoc_task_type.new do |rd|
12
- rd.title = GEMSPEC.name
13
- rd.rdoc_dir = 'rdoc'
14
- rd.main = "README"
15
- rd.rdoc_files.include("lib/**/*.rb", *GEMSPEC.extra_rdoc_files)
16
- rd.rdoc_files.exclude(*%w(lib/em/version lib/emva lib/evma/ lib/pr_eventmachine lib/jeventmachine))
17
- rd.template = 'darkfish' if df
18
- end
19
-
20
- Rake::Task[:clean].enhance [:clobber_rdoc]
21
-
22
- desc 'Generate and open documentation'
23
- task :docs => :rdoc do
24
- case RUBY_PLATFORM
25
- when /darwin/ ; sh 'open rdoc/index.html'
26
- when /mswin|mingw/ ; sh 'start rdoc\index.html'
27
- else
28
- sh 'firefox rdoc/index.html'
29
- end
30
- end