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,31 @@
1
+ # $Id: eventmachine_version.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 8 Apr 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
+ module EventMachine
27
+
28
+ VERSION = "0.12.0"
29
+
30
+ end
31
+
@@ -0,0 +1,32 @@
1
+ # $Id: evma.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 8 Apr 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 'rubyeventmachine'
27
+ require 'evma/reactor'
28
+ require 'evma/callback'
29
+ require 'evma/protocol'
30
+ require 'evma/factory'
31
+ require 'evma/container'
32
+
@@ -0,0 +1,32 @@
1
+ # $Id: callback.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 19 May 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
+ module EventMachine
27
+
28
+ def self.event_callback target, opcode, data
29
+ Evma::Container.callback target, opcode, data
30
+ end
31
+
32
+ end # module EventMachine
@@ -0,0 +1,75 @@
1
+ # $Id: container.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 19 May 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
+ require 'singleton'
28
+
29
+ module Evma
30
+
31
+ class ContainerHasObject < Exception; end
32
+ class UnsupportedCallback < Exception; end
33
+ class UnknownTarget < Exception; end
34
+
35
+ class Container
36
+ include Singleton
37
+
38
+ def initialize
39
+ @objects = {}
40
+ end
41
+
42
+ def self.store obj
43
+ instance.store obj
44
+ end
45
+
46
+ def self.callback target, opcode, data
47
+ instance.callback target, opcode, data
48
+ end
49
+
50
+ def store obj
51
+ sig = obj.signature
52
+ raise ContainerHasObject.new(sig) if @objects.has_key?(sig)
53
+ @objects[sig] = obj
54
+ end
55
+
56
+ def callback target, opcode, data
57
+ case opcode
58
+ when 101 # received data
59
+ obj = @objects[target] or raise UnknownTarget.new( target )
60
+ obj.receive_data data
61
+ when 102 # unbind
62
+ obj = @objects[target] or raise UnknownTarget.new( target )
63
+ obj.unbind
64
+ @objects.delete obj.signature
65
+ when 103 # accept
66
+ obj = @objects[target] or raise UnknownTarget.new( target )
67
+ obj.accept data
68
+ else
69
+ raise UnsupportedCallback.new( opcode.to_s )
70
+ end
71
+ end
72
+
73
+ end # class Container
74
+ end # module Evma
75
+
@@ -0,0 +1,77 @@
1
+ # $Id: factory.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 19 May 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
+ module Evma
27
+ class ProtocolFactory < Protocol
28
+
29
+ #--
30
+ # default implementation raises an exception.
31
+ # we expect subclasses to override this.
32
+ # we can't do anything reasonable here because
33
+ def accept new_object
34
+ # don't bother calling Evma::Reactor.instance, since only Reactor can call accept
35
+ Evma::Container.store Evma::Protocol.new( new_object )
36
+ EventMachine.close_connection new_object, false
37
+ end
38
+
39
+
40
+ end # class ProtocolFactory
41
+ end # module Evma
42
+
43
+ ######################################
44
+
45
+ module Evma
46
+ class TcpSocket
47
+
48
+ def self.connect server, port, protocol_handler = Evma::Protocol
49
+ Evma::Reactor.instance # ensure initialization
50
+ sig = EventMachine.connect_server server, port
51
+ Evma::Container.store protocol_handler.new( sig )
52
+ end
53
+
54
+ end
55
+ end # module Evma
56
+
57
+ ######################################
58
+
59
+ module Evma
60
+ class TcpServerFactory < Evma::ProtocolFactory
61
+
62
+ def initialize server, port, protocol_handler = Evma::Protocol
63
+ Evma::Reactor.instance # ensure initialization
64
+ sig = EventMachine.start_tcp_server server, port
65
+ super sig
66
+ @protocol_handler = protocol_handler
67
+ Evma::Container.store self
68
+ end
69
+
70
+ def accept new_obj
71
+ # don't bother calling Evma::Reactor.instance, since only Reactor can call accept
72
+ Evma::Container.store @protocol_handler.new( new_obj )
73
+ end
74
+
75
+ end
76
+ end # module Evma
77
+
@@ -0,0 +1,87 @@
1
+ # $Id: protocol.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 19 May 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
+ module Evma
27
+ class Protocol
28
+
29
+ attr_reader :signature
30
+
31
+ def initialize sig
32
+ @signature = sig
33
+ end
34
+
35
+ def unbind
36
+ end
37
+
38
+ def close
39
+ Evma::Reactor.instance # ensure initialized
40
+ EventMachine.close_connection signature, false
41
+ end
42
+
43
+ def close_after_writing
44
+ Evma::Reactor.instance # ensure initialized
45
+ EventMachine.close_connection signature, true
46
+ end
47
+
48
+ end # class Protocol
49
+ end # module Evma
50
+
51
+
52
+ ###########################################
53
+
54
+ module Evma
55
+ class StreamProtocol < Protocol
56
+
57
+ def initialize sig
58
+ super
59
+ end
60
+
61
+ def send_data data
62
+ Evma::Reactor.instance # ensure initialized
63
+ EventMachine.send_data signature, data, data.length
64
+ end
65
+
66
+ end # class Protocol
67
+ end # module Evma
68
+
69
+
70
+ ###########################################
71
+
72
+ module Evma
73
+ class DatagramProtocol < Protocol
74
+
75
+ def initialize sig
76
+ super
77
+ end
78
+
79
+ def send_message data
80
+ Evma::Reactor.instance # ensure initialized
81
+ raise "unimplemented"
82
+ end
83
+
84
+ end # class Protocol
85
+ end # module Evma
86
+
87
+
@@ -0,0 +1,48 @@
1
+ # $Id: reactor.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 18 May 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
+ require 'singleton'
28
+
29
+ module Evma
30
+ class Reactor
31
+ include Singleton
32
+
33
+ #--
34
+ def initialize
35
+ EventMachine.initialize_event_machine
36
+ end
37
+
38
+ #--
39
+ #
40
+ def run
41
+ EventMachine.run_machine
42
+ end
43
+
44
+ end # class Reactor
45
+ end # module Evma
46
+
47
+
48
+
@@ -0,0 +1,106 @@
1
+ # $Id: jeventmachine.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 8 Apr 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
+ # This module provides "glue" for the Java version of the EventMachine reactor core.
28
+ # For C++ EventMachines, the analogous functionality is found in ext/rubymain.cpp,
29
+ # which is a garden-variety Ruby-extension glue module.
30
+
31
+
32
+ require 'em_reactor'
33
+
34
+ module EventMachine
35
+ # TODO: These event numbers are defined in way too many places.
36
+ # DRY them up.
37
+ TimerFired = 100
38
+ ConnectionData = 101
39
+ ConnectionUnbound = 102
40
+ ConnectionAccepted = 103
41
+ ConnectionCompleted = 104
42
+ LoopbreakSignalled = 105
43
+
44
+ class EM < com.rubyeventmachine.EmReactor
45
+ def eventCallback a1, a2, a3
46
+ s = String.from_java_bytes(a3.array[a3.position...a3.limit])
47
+ EventMachine::event_callback a1, a2, s
48
+ end
49
+ end
50
+ def self.initialize_event_machine
51
+ @em = EM.new
52
+ end
53
+ def self.release_machine
54
+ @em = nil
55
+ end
56
+ def self.add_oneshot_timer interval
57
+ @em.installOneshotTimer interval
58
+ end
59
+ def self.run_machine
60
+ @em.run
61
+ end
62
+ def self.stop
63
+ @em.stop
64
+ end
65
+ def self.start_tcp_server server, port
66
+ @em.startTcpServer server, port
67
+ end
68
+ def self.stop_tcp_server sig
69
+ @em.stopTcpServer sig
70
+ end
71
+ def self.send_data sig, data, length
72
+ @em.sendData sig, data, length
73
+ end
74
+ def self.send_datagram sig, data, length, address, port
75
+ @em.sendDatagram sig, data, length, address, port
76
+ end
77
+ def self.connect_server server, port
78
+ @em.connectTcpServer server, port
79
+ end
80
+ def self.close_connection sig, after_writing
81
+ @em.closeConnection sig, after_writing
82
+ end
83
+ def self.start_tls sig
84
+ @em.startTls sig
85
+ end
86
+ def self.signal_loopbreak
87
+ @em.signalLoopbreak
88
+ end
89
+ def self.set_timer_quantum q
90
+ @em.setTimerQuantum q
91
+ end
92
+ def self.epoll
93
+ # Epoll is a no-op for Java.
94
+ # The latest Java versions run epoll when possible in NIO.
95
+ end
96
+ def self.set_rlimit_nofile n_descriptors
97
+ # Currently a no-op for Java.
98
+ end
99
+ def self.open_udp_socket server, port
100
+ @em.openUdpSocket server, port
101
+ end
102
+ def self.library_type
103
+ :java
104
+ end
105
+ end
106
+