eventmachine 0.12.6-x86-mswin32-60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +13 -0
- data/Rakefile +254 -0
- data/docs/COPYING +60 -0
- data/docs/ChangeLog +211 -0
- data/docs/DEFERRABLES +138 -0
- data/docs/EPOLL +141 -0
- data/docs/GNU +281 -0
- data/docs/INSTALL +15 -0
- data/docs/KEYBOARD +38 -0
- data/docs/LEGAL +25 -0
- data/docs/LIGHTWEIGHT_CONCURRENCY +72 -0
- data/docs/PURE_RUBY +77 -0
- data/docs/README +74 -0
- data/docs/RELEASE_NOTES +96 -0
- data/docs/SMTP +9 -0
- data/docs/SPAWNED_PROCESSES +93 -0
- data/docs/TODO +10 -0
- data/eventmachine.gemspec +32 -0
- data/ext/binder.cpp +126 -0
- data/ext/binder.h +48 -0
- data/ext/cmain.cpp +586 -0
- data/ext/cplusplus.cpp +193 -0
- data/ext/ed.cpp +1522 -0
- data/ext/ed.h +380 -0
- data/ext/em.cpp +1937 -0
- data/ext/em.h +186 -0
- data/ext/emwin.cpp +300 -0
- data/ext/emwin.h +94 -0
- data/ext/epoll.cpp +26 -0
- data/ext/epoll.h +25 -0
- data/ext/eventmachine.h +98 -0
- data/ext/eventmachine_cpp.h +95 -0
- data/ext/extconf.rb +129 -0
- data/ext/fastfilereader/extconf.rb +77 -0
- data/ext/fastfilereader/mapper.cpp +214 -0
- data/ext/fastfilereader/mapper.h +59 -0
- data/ext/fastfilereader/rubymain.cpp +127 -0
- data/ext/files.cpp +94 -0
- data/ext/files.h +65 -0
- data/ext/kb.cpp +82 -0
- data/ext/page.cpp +107 -0
- data/ext/page.h +51 -0
- data/ext/pipe.cpp +351 -0
- data/ext/project.h +119 -0
- data/ext/rubymain.cpp +847 -0
- data/ext/sigs.cpp +89 -0
- data/ext/sigs.h +32 -0
- data/ext/ssl.cpp +423 -0
- data/ext/ssl.h +90 -0
- data/java/.classpath +8 -0
- data/java/.project +17 -0
- data/java/src/com/rubyeventmachine/Application.java +196 -0
- data/java/src/com/rubyeventmachine/Connection.java +74 -0
- data/java/src/com/rubyeventmachine/ConnectionFactory.java +37 -0
- data/java/src/com/rubyeventmachine/DefaultConnectionFactory.java +46 -0
- data/java/src/com/rubyeventmachine/EmReactor.java +408 -0
- data/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
- data/java/src/com/rubyeventmachine/EventableChannel.java +57 -0
- data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +171 -0
- data/java/src/com/rubyeventmachine/EventableSocketChannel.java +244 -0
- data/java/src/com/rubyeventmachine/PeriodicTimer.java +38 -0
- data/java/src/com/rubyeventmachine/Timer.java +54 -0
- data/java/src/com/rubyeventmachine/tests/ApplicationTest.java +108 -0
- data/java/src/com/rubyeventmachine/tests/ConnectTest.java +124 -0
- data/java/src/com/rubyeventmachine/tests/EMTest.java +80 -0
- data/java/src/com/rubyeventmachine/tests/TestDatagrams.java +53 -0
- data/java/src/com/rubyeventmachine/tests/TestServers.java +74 -0
- data/java/src/com/rubyeventmachine/tests/TestTimers.java +89 -0
- data/lib/em/deferrable.rb +208 -0
- data/lib/em/eventable.rb +39 -0
- data/lib/em/future.rb +62 -0
- data/lib/em/messages.rb +66 -0
- data/lib/em/processes.rb +113 -0
- data/lib/em/spawnable.rb +88 -0
- data/lib/em/streamer.rb +112 -0
- data/lib/eventmachine.rb +1926 -0
- data/lib/eventmachine_version.rb +31 -0
- data/lib/evma.rb +32 -0
- data/lib/evma/callback.rb +32 -0
- data/lib/evma/container.rb +75 -0
- data/lib/evma/factory.rb +77 -0
- data/lib/evma/protocol.rb +87 -0
- data/lib/evma/reactor.rb +48 -0
- data/lib/jeventmachine.rb +137 -0
- data/lib/pr_eventmachine.rb +1011 -0
- data/lib/protocols/buftok.rb +127 -0
- data/lib/protocols/header_and_content.rb +129 -0
- data/lib/protocols/httpcli2.rb +803 -0
- data/lib/protocols/httpclient.rb +270 -0
- data/lib/protocols/line_and_text.rb +126 -0
- data/lib/protocols/linetext2.rb +161 -0
- data/lib/protocols/memcache.rb +293 -0
- data/lib/protocols/postgres.rb +261 -0
- data/lib/protocols/saslauth.rb +179 -0
- data/lib/protocols/smtpclient.rb +308 -0
- data/lib/protocols/smtpserver.rb +556 -0
- data/lib/protocols/stomp.rb +153 -0
- data/lib/protocols/tcptest.rb +57 -0
- data/setup.rb +1585 -0
- data/tasks/cpp.rake +77 -0
- data/tasks/project.rake +78 -0
- data/tasks/tests.rake +193 -0
- data/tests/test_attach.rb +83 -0
- data/tests/test_basic.rb +231 -0
- data/tests/test_connection_count.rb +45 -0
- data/tests/test_defer.rb +47 -0
- data/tests/test_epoll.rb +163 -0
- data/tests/test_error_handler.rb +35 -0
- data/tests/test_errors.rb +82 -0
- data/tests/test_eventables.rb +77 -0
- data/tests/test_exc.rb +58 -0
- data/tests/test_futures.rb +214 -0
- data/tests/test_handler_check.rb +37 -0
- data/tests/test_hc.rb +218 -0
- data/tests/test_httpclient.rb +215 -0
- data/tests/test_httpclient2.rb +155 -0
- data/tests/test_kb.rb +61 -0
- data/tests/test_ltp.rb +188 -0
- data/tests/test_ltp2.rb +320 -0
- data/tests/test_next_tick.rb +109 -0
- data/tests/test_processes.rb +95 -0
- data/tests/test_pure.rb +129 -0
- data/tests/test_running.rb +47 -0
- data/tests/test_sasl.rb +74 -0
- data/tests/test_send_file.rb +243 -0
- data/tests/test_servers.rb +80 -0
- data/tests/test_smtpclient.rb +83 -0
- data/tests/test_smtpserver.rb +93 -0
- data/tests/test_spawn.rb +329 -0
- data/tests/test_ssl_args.rb +68 -0
- data/tests/test_ssl_methods.rb +50 -0
- data/tests/test_timers.rb +148 -0
- data/tests/test_ud.rb +43 -0
- data/tests/testem.rb +31 -0
- data/web/whatis +7 -0
- metadata +207 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
# $Id$
|
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.6"
|
29
|
+
|
30
|
+
end
|
31
|
+
|
data/lib/evma.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# $Id$
|
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$
|
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$
|
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
|
+
|
data/lib/evma/factory.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# $Id$
|
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$
|
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
|
+
|
data/lib/evma/reactor.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# $Id$
|
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,137 @@
|
|
1
|
+
# $Id$
|
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
|
+
require 'java'
|
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
|
+
# This thunk class used to be called EM, but that caused conflicts with
|
45
|
+
# the alias "EM" for module EventMachine. (FC, 20Jun08)
|
46
|
+
class JEM < com.rubyeventmachine.EmReactor
|
47
|
+
def eventCallback a1, a2, a3
|
48
|
+
s = String.from_java_bytes(a3.array[a3.position...a3.limit])
|
49
|
+
EventMachine::event_callback a1, a2, s
|
50
|
+
end
|
51
|
+
end
|
52
|
+
class Connection < com.rubyeventmachine.Connection
|
53
|
+
def associate_callback_target sig
|
54
|
+
# No-op for the time being.
|
55
|
+
end
|
56
|
+
end
|
57
|
+
def self.initialize_event_machine
|
58
|
+
@em = JEM.new
|
59
|
+
end
|
60
|
+
def self.release_machine
|
61
|
+
@em = nil
|
62
|
+
end
|
63
|
+
def self.add_oneshot_timer interval
|
64
|
+
@em.installOneshotTimer interval
|
65
|
+
end
|
66
|
+
def self.run_machine
|
67
|
+
@em.run
|
68
|
+
end
|
69
|
+
def self.stop
|
70
|
+
@em.stop
|
71
|
+
end
|
72
|
+
def self.start_tcp_server server, port
|
73
|
+
@em.startTcpServer server, port
|
74
|
+
end
|
75
|
+
def self.stop_tcp_server sig
|
76
|
+
@em.stopTcpServer sig
|
77
|
+
end
|
78
|
+
def self.start_unix_server filename
|
79
|
+
# TEMPORARILY unsupported until someone figures out how to do it.
|
80
|
+
raise "unsupported on this platform"
|
81
|
+
end
|
82
|
+
def self.send_data sig, data, length
|
83
|
+
@em.sendData sig, data.to_java_bytes
|
84
|
+
end
|
85
|
+
def self.send_datagram sig, data, length, address, port
|
86
|
+
@em.sendDatagram sig, data, length, address, port
|
87
|
+
end
|
88
|
+
def self.connect_server server, port
|
89
|
+
@em.connectTcpServer server, port
|
90
|
+
end
|
91
|
+
def self.close_connection sig, after_writing
|
92
|
+
@em.closeConnection sig, after_writing
|
93
|
+
end
|
94
|
+
def self.set_comm_inactivity_timeout sig, interval
|
95
|
+
@em.setCommInactivityTimeout sig, interval
|
96
|
+
end
|
97
|
+
def self.start_tls sig
|
98
|
+
@em.startTls sig
|
99
|
+
end
|
100
|
+
def self.signal_loopbreak
|
101
|
+
@em.signalLoopbreak
|
102
|
+
end
|
103
|
+
def self.set_timer_quantum q
|
104
|
+
@em.setTimerQuantum q
|
105
|
+
end
|
106
|
+
def self.epoll
|
107
|
+
# Epoll is a no-op for Java.
|
108
|
+
# The latest Java versions run epoll when possible in NIO.
|
109
|
+
end
|
110
|
+
def self.set_rlimit_nofile n_descriptors
|
111
|
+
# Currently a no-op for Java.
|
112
|
+
end
|
113
|
+
def self.open_udp_socket server, port
|
114
|
+
@em.openUdpSocket server, port
|
115
|
+
end
|
116
|
+
def self.invoke_popen cmd
|
117
|
+
# TEMPORARILY unsupported until someone figures out how to do it.
|
118
|
+
raise "unsupported on this platform"
|
119
|
+
end
|
120
|
+
def self.read_keyboard
|
121
|
+
# TEMPORARILY unsupported until someone figures out how to do it.
|
122
|
+
raise "temporarily unsupported on this platform"
|
123
|
+
end
|
124
|
+
def self.set_max_timer_count num
|
125
|
+
# harmless no-op in Java. There's no built-in timer limit.
|
126
|
+
end
|
127
|
+
def self.library_type
|
128
|
+
:java
|
129
|
+
end
|
130
|
+
|
131
|
+
class Connection
|
132
|
+
def associate_callback_target sig
|
133
|
+
# No-op for the time being
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|