eventmachine 0.12.0-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/COPYING +60 -0
  2. data/DEFERRABLES +138 -0
  3. data/EPOLL +141 -0
  4. data/GNU +281 -0
  5. data/KEYBOARD +38 -0
  6. data/LEGAL +25 -0
  7. data/LIGHTWEIGHT_CONCURRENCY +72 -0
  8. data/PURE_RUBY +77 -0
  9. data/README +74 -0
  10. data/RELEASE_NOTES +96 -0
  11. data/SMTP +9 -0
  12. data/SPAWNED_PROCESSES +93 -0
  13. data/TODO +10 -0
  14. data/ext/Makefile +180 -0
  15. data/ext/binder.cpp +126 -0
  16. data/ext/binder.h +48 -0
  17. data/ext/cmain.cpp +527 -0
  18. data/ext/cplusplus.cpp +172 -0
  19. data/ext/ed.cpp +1442 -0
  20. data/ext/ed.h +351 -0
  21. data/ext/em.cpp +1781 -0
  22. data/ext/em.h +167 -0
  23. data/ext/emwin.cpp +300 -0
  24. data/ext/emwin.h +94 -0
  25. data/ext/epoll.cpp +26 -0
  26. data/ext/epoll.h +25 -0
  27. data/ext/eventmachine.h +83 -0
  28. data/ext/eventmachine_cpp.h +94 -0
  29. data/ext/extconf.rb +203 -0
  30. data/ext/files.cpp +94 -0
  31. data/ext/files.h +65 -0
  32. data/ext/kb.cpp +368 -0
  33. data/ext/mkmf.log +129 -0
  34. data/ext/page.cpp +107 -0
  35. data/ext/page.h +51 -0
  36. data/ext/pipe.cpp +327 -0
  37. data/ext/project.h +119 -0
  38. data/ext/rubyeventmachine-i386-mswin32.def +2 -0
  39. data/ext/rubyeventmachine-i386-mswin32.exp +0 -0
  40. data/ext/rubyeventmachine-i386-mswin32.lib +0 -0
  41. data/ext/rubyeventmachine-i386-mswin32.pdb +0 -0
  42. data/ext/rubyeventmachine.so +0 -0
  43. data/ext/rubymain.cpp +630 -0
  44. data/ext/sigs.cpp +89 -0
  45. data/ext/sigs.h +32 -0
  46. data/ext/ssl.cpp +408 -0
  47. data/ext/ssl.h +86 -0
  48. data/ext/vc60.pdb +0 -0
  49. data/lib/em/deferrable.rb +208 -0
  50. data/lib/em/eventable.rb +39 -0
  51. data/lib/em/future.rb +62 -0
  52. data/lib/em/messages.rb +66 -0
  53. data/lib/em/processes.rb +68 -0
  54. data/lib/em/spawnable.rb +88 -0
  55. data/lib/em/streamer.rb +112 -0
  56. data/lib/eventmachine.rb +1621 -0
  57. data/lib/eventmachine_version.rb +31 -0
  58. data/lib/evma.rb +32 -0
  59. data/lib/evma/callback.rb +32 -0
  60. data/lib/evma/container.rb +75 -0
  61. data/lib/evma/factory.rb +77 -0
  62. data/lib/evma/protocol.rb +87 -0
  63. data/lib/evma/reactor.rb +48 -0
  64. data/lib/jeventmachine.rb +106 -0
  65. data/lib/pr_eventmachine.rb +1011 -0
  66. data/lib/protocols/buftok.rb +127 -0
  67. data/lib/protocols/header_and_content.rb +123 -0
  68. data/lib/protocols/httpcli2.rb +784 -0
  69. data/lib/protocols/httpclient.rb +253 -0
  70. data/lib/protocols/line_and_text.rb +122 -0
  71. data/lib/protocols/linetext2.rb +145 -0
  72. data/lib/protocols/saslauth.rb +179 -0
  73. data/lib/protocols/smtpclient.rb +308 -0
  74. data/lib/protocols/smtpserver.rb +543 -0
  75. data/lib/protocols/stomp.rb +127 -0
  76. data/lib/protocols/tcptest.rb +57 -0
  77. data/lib/rubyeventmachine.so +0 -0
  78. data/tests/test_basic.rb +142 -0
  79. data/tests/test_defer.rb +63 -0
  80. data/tests/test_epoll.rb +168 -0
  81. data/tests/test_errors.rb +82 -0
  82. data/tests/test_eventables.rb +78 -0
  83. data/tests/test_exc.rb +58 -0
  84. data/tests/test_futures.rb +214 -0
  85. data/tests/test_hc.rb +221 -0
  86. data/tests/test_httpclient.rb +194 -0
  87. data/tests/test_httpclient2.rb +133 -0
  88. data/tests/test_kb.rb +61 -0
  89. data/tests/test_ltp.rb +190 -0
  90. data/tests/test_ltp2.rb +261 -0
  91. data/tests/test_next_tick.rb +58 -0
  92. data/tests/test_processes.rb +56 -0
  93. data/tests/test_pure.rb +128 -0
  94. data/tests/test_running.rb +47 -0
  95. data/tests/test_sasl.rb +73 -0
  96. data/tests/test_send_file.rb +238 -0
  97. data/tests/test_servers.rb +90 -0
  98. data/tests/test_smtpclient.rb +81 -0
  99. data/tests/test_smtpserver.rb +93 -0
  100. data/tests/test_spawn.rb +329 -0
  101. data/tests/test_timers.rb +138 -0
  102. data/tests/test_ud.rb +43 -0
  103. data/tests/testem.rb +5 -0
  104. metadata +170 -0
@@ -0,0 +1,86 @@
1
+ /*****************************************************************************
2
+
3
+ $Id: ssl.h 668 2008-01-04 23:00:34Z blackhedd $
4
+
5
+ File: ssl.h
6
+ Date: 30Apr06
7
+
8
+ Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
9
+ Gmail: blackhedd
10
+
11
+ This program is free software; you can redistribute it and/or modify
12
+ it under the terms of either: 1) the GNU General Public License
13
+ as published by the Free Software Foundation; either version 2 of the
14
+ License, or (at your option) any later version; or 2) Ruby's License.
15
+
16
+ See the file COPYING for complete licensing information.
17
+
18
+ *****************************************************************************/
19
+
20
+
21
+ #ifndef __SslBox__H_
22
+ #define __SslBox__H_
23
+
24
+
25
+
26
+
27
+ #ifdef WITH_SSL
28
+
29
+ /******************
30
+ class SslContext_t
31
+ ******************/
32
+
33
+ class SslContext_t
34
+ {
35
+ public:
36
+ SslContext_t (bool is_server, const string &privkeyfile, const string &certchainfile);
37
+ virtual ~SslContext_t();
38
+
39
+ private:
40
+ static bool bLibraryInitialized;
41
+
42
+ private:
43
+ bool bIsServer;
44
+ SSL_CTX *pCtx;
45
+
46
+ EVP_PKEY *PrivateKey;
47
+ X509 *Certificate;
48
+
49
+ friend class SslBox_t;
50
+ };
51
+
52
+
53
+ /**************
54
+ class SslBox_t
55
+ **************/
56
+
57
+ class SslBox_t
58
+ {
59
+ public:
60
+ SslBox_t (bool is_server, const string &privkeyfile, const string &certchainfile);
61
+ virtual ~SslBox_t();
62
+
63
+ int PutPlaintext (const char*, int);
64
+ int GetPlaintext (char*, int);
65
+
66
+ bool PutCiphertext (const char*, int);
67
+ bool CanGetCiphertext();
68
+ int GetCiphertext (char*, int);
69
+
70
+ void Shutdown();
71
+
72
+ protected:
73
+ SslContext_t *Context;
74
+
75
+ bool bIsServer;
76
+ SSL *pSSL;
77
+ BIO *pbioRead;
78
+ BIO *pbioWrite;
79
+
80
+ PageList OutboundQ;
81
+ };
82
+ #endif // WITH_SSL
83
+
84
+
85
+ #endif // __SslBox__H_
86
+
Binary file
@@ -0,0 +1,208 @@
1
+ # $Id: deferrable.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 16 Jul 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+
26
+ require 'forwardable'
27
+
28
+ module EventMachine
29
+
30
+ module Deferrable
31
+
32
+ # Specify a block to be executed if and when the Deferrable object receives
33
+ # a status of :succeeded. See #set_deferred_status for more information.
34
+ #
35
+ # Calling this method on a Deferrable object whose status is not yet known
36
+ # will cause the callback block to be stored on an internal list.
37
+ # If you call this method on a Deferrable whose status is :succeeded, the
38
+ # block will be executed immediately, receiving the parameters given to the
39
+ # prior #set_deferred_status call.
40
+ #
41
+ #--
42
+ # If there is no status, add a callback to an internal list.
43
+ # If status is succeeded, execute the callback immediately.
44
+ # If status is failed, do nothing.
45
+ #
46
+ def callback &block
47
+ return unless block
48
+ if @deferred_status == :succeeded
49
+ block.call(*@deferred_args)
50
+ elsif @deferred_status != :failed
51
+ @callbacks ||= []
52
+ @callbacks.unshift block # << block
53
+ end
54
+ end
55
+
56
+ # Specify a block to be executed if and when the Deferrable object receives
57
+ # a status of :failed. See #set_deferred_status for more information.
58
+ #--
59
+ # If there is no status, add an errback to an internal list.
60
+ # If status is failed, execute the errback immediately.
61
+ # If status is succeeded, do nothing.
62
+ #
63
+ def errback &block
64
+ return unless block
65
+ if @deferred_status == :failed
66
+ block.call(*@deferred_args)
67
+ elsif @deferred_status != :succeeded
68
+ @errbacks ||= []
69
+ @errbacks.unshift block # << block
70
+ end
71
+ end
72
+
73
+ # Sets the "disposition" (status) of the Deferrable object. See also the large set of
74
+ # sugarings for this method.
75
+ # Note that if you call this method without arguments,
76
+ # no arguments will be passed to the callback/errback.
77
+ # If the user has coded these with arguments, then the
78
+ # user code will throw an argument exception.
79
+ # Implementors of deferrable classes <b>must</b>
80
+ # document the arguments they will supply to user callbacks.
81
+ #
82
+ # OBSERVE SOMETHING VERY SPECIAL here: you may call this method even
83
+ # on the INSIDE of a callback. This is very useful when a previously-registered
84
+ # callback wants to change the parameters that will be passed to subsequently-registered
85
+ # ones.
86
+ #
87
+ # You may give either :succeeded or :failed as the status argument.
88
+ #
89
+ # If you pass :succeeded, then all of the blocks passed to the object using the #callback
90
+ # method (if any) will be executed BEFORE the #set_deferred_status method returns. All of the blocks
91
+ # passed to the object using #errback will be discarded.
92
+ #
93
+ # If you pass :failed, then all of the blocks passed to the object using the #errback
94
+ # method (if any) will be executed BEFORE the #set_deferred_status method returns. All of the blocks
95
+ # passed to the object using # callback will be discarded.
96
+ #
97
+ # If you pass any arguments to #set_deferred_status in addition to the status argument,
98
+ # they will be passed as arguments to any callbacks or errbacks that are executed.
99
+ # It's your responsibility to ensure that the argument lists specified in your callbacks and
100
+ # errbacks match the arguments given in calls to #set_deferred_status, otherwise Ruby will raise
101
+ # an ArgumentError.
102
+ #
103
+ # --
104
+ # We're shifting callbacks off and discarding them as we execute them.
105
+ # This is valid because by definition callbacks are executed no more than
106
+ # once. It also has the magic effect of permitting recursive calls, which
107
+ # means that a callback can call #set_deferred_status and change the parameters
108
+ # that will be sent to subsequent callbacks down the chain.
109
+ #
110
+ # Changed @callbacks and @errbacks from push/shift to unshift/pop, per suggestion
111
+ # by Kirk Haines, to work around the memory leak bug that still exists in many Ruby
112
+ # versions.
113
+ #
114
+ # Changed 15Sep07: after processing callbacks or errbacks, CLEAR the other set of
115
+ # handlers. This gets us a little closer to the behavior of Twisted's "deferred,"
116
+ # which only allows status to be set once. Prior to making this change, it was possible
117
+ # to "succeed" a Deferrable (triggering its callbacks), and then immediately "fail" it,
118
+ # triggering its errbacks! That is clearly undesirable, but it's just as undesirable
119
+ # to raise an exception is status is set more than once on a Deferrable. The latter
120
+ # behavior would invalidate the idiom of resetting arguments by setting status from
121
+ # within a callback or errback, but more seriously it would cause spurious errors
122
+ # if a Deferrable was timed out and then an attempt was made to succeed it. See the
123
+ # comments under the new method #timeout.
124
+ #
125
+ def set_deferred_status status, *args
126
+ cancel_timeout
127
+ @deferred_status = status
128
+ @deferred_args = args
129
+ case @deferred_status
130
+ when :succeeded
131
+ if @callbacks
132
+ while cb = @callbacks.pop
133
+ cb.call(*@deferred_args)
134
+ end
135
+ end
136
+ @errbacks.clear if @errbacks
137
+ when :failed
138
+ if @errbacks
139
+ while eb = @errbacks.pop
140
+ eb.call(*@deferred_args)
141
+ end
142
+ end
143
+ @callbacks.clear if @callbacks
144
+ end
145
+ end
146
+
147
+
148
+ # Setting a timeout on a Deferrable causes it to go into the failed state after
149
+ # the Timeout expires (passing no arguments to the object's errbacks).
150
+ # Setting the status at any time prior to a call to the expiration of the timeout
151
+ # will cause the timer to be cancelled.
152
+ #--
153
+ #
154
+ #
155
+ def timeout seconds
156
+ cancel_timeout
157
+ me = self
158
+ @deferred_timeout = EventMachine::Timer.new(seconds) {me.fail}
159
+ end
160
+
161
+
162
+ # Cancels an outstanding timeout if any. Undoes the action of #timeout.
163
+ #
164
+ #
165
+ def cancel_timeout
166
+ if @deferred_timeout
167
+ @deferred_timeout.cancel
168
+ @deferred_timeout = nil
169
+ end
170
+ end
171
+
172
+
173
+ # Equivalent to set_deferred_status(:succeeded, ...)
174
+ #
175
+ def set_deferred_success *args
176
+ set_deferred_status :succeeded, *args
177
+ end
178
+
179
+ # Equivalent to set_deferred_status(:failed, ...)
180
+ #
181
+ def set_deferred_failure *args
182
+ set_deferred_status :failed, *args
183
+ end
184
+
185
+ # And still more sugar
186
+ #
187
+ def succeed *args
188
+ set_deferred_success(*args)
189
+ end
190
+
191
+ # Can't get enough sugar
192
+ #
193
+ def fail *args
194
+ set_deferred_failure(*args)
195
+ end
196
+ end
197
+
198
+
199
+ # DefaultDeferrable is an otherwise empty class that includes Deferrable.
200
+ # This is very useful when you just need to return a Deferrable object
201
+ # as a way of communicating deferred status to some other part of a program.
202
+ #
203
+ class DefaultDeferrable
204
+ include Deferrable
205
+ end
206
+
207
+ end
208
+
@@ -0,0 +1,39 @@
1
+ # $Id: eventable.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 16 Jul 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+
26
+
27
+ module EventMachine
28
+ module Eventable
29
+
30
+ def listen_event event_name
31
+ end
32
+
33
+ def post_event event_name, arg
34
+ end
35
+
36
+ end
37
+ end
38
+
39
+
@@ -0,0 +1,62 @@
1
+ # $Id: future.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 16 Jul 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+
26
+ # This defines EventMachine::Deferrable#future, which requires
27
+ # that the rest of EventMachine::Deferrable has already been seen.
28
+ # (It's in deferrable.rb.)
29
+ #
30
+ # A future is a sugaring of a typical deferrable usage.
31
+
32
+ module EventMachine
33
+ module Deferrable
34
+
35
+ class << self
36
+ # Evaluate arg (which may be an expression or a block).
37
+ # What's the class of arg?
38
+ # If arg is an ordinary expression, then return it.
39
+ # If arg is deferrable (responds to :set_deferred_status),
40
+ # then look at the arguments. If either callback or errback
41
+ # are defined, then use them. If neither are defined, then
42
+ # use the supplied block (if any) as the callback.
43
+ # Then return arg.
44
+ def future arg, cb=nil, eb=nil, &blk
45
+ arg = arg.call if arg.respond_to?(:call)
46
+
47
+ if arg.respond_to?(:set_deferred_status)
48
+ if cb || eb
49
+ arg.callback(&cb) if cb
50
+ arg.errback(&eb) if eb
51
+ else
52
+ arg.callback(&blk) if blk
53
+ end
54
+ end
55
+
56
+ arg
57
+ end
58
+ end
59
+
60
+ end
61
+ end
62
+
@@ -0,0 +1,66 @@
1
+ # $Id: messages.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 16 Jul 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+
26
+ =begin
27
+
28
+ Message Routing in EventMachine.
29
+
30
+ The goal here is to enable "routing points," objects that can send and receive
31
+ "messages," which are delimited streams of bytes. The boundaries of a message
32
+ are preserved as it passes through the reactor system.
33
+
34
+ There will be several module methods defined in EventMachine to create route-point
35
+ objects (which will probably have a base class of EventMachine::MessageRouter
36
+ until someone suggests a better name).
37
+
38
+ As with I/O objects, routing objects will receive events by having the router
39
+ core call methods on them. And of course user code can and will define handlers
40
+ to deal with events of interest.
41
+
42
+ The message router base class only really needs a receive_message method. There will
43
+ be an EM module-method to send messages, in addition to the module methods to create
44
+ the various kinds of message receivers.
45
+
46
+ The simplest kind of message receiver object can receive messages by being named
47
+ explicitly in a parameter to EM#send_message. More sophisticated receivers can define
48
+ pub-sub selectors and message-queue names. And they can also define channels for
49
+ route-points in other processes or even on other machines.
50
+
51
+ A message is NOT a marshallable entity. Rather, it's a chunk of flat content more like
52
+ an Erlang message. Initially, all content submitted for transmission as a message will
53
+ have the to_s method called on it. Eventually, we'll be able to transmit certain structured
54
+ data types (XML and YAML documents, Structs within limits) and have them reconstructed
55
+ on the other end.
56
+
57
+ A fundamental goal of the message-routing capability is to interoperate seamlessly with
58
+ external systems, including non-Ruby systems like ActiveMQ. We will define various protocol
59
+ handlers for things like Stomp and possibly AMQP, but these will be wrapped up and hidden
60
+ from the users of the basic routing capability.
61
+
62
+ As with Erlang, a critical goal is for programs that are built to use message-passing to work
63
+ WITHOUT CHANGE when the code is re-based on a multi-process system.
64
+
65
+ =end
66
+