eventmachine 1.0.0.beta.1-java → 1.0.0.beta.2-java
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +7 -298
- data/eventmachine.gemspec +1 -1
- data/ext/cmain.cpp +0 -14
- data/ext/em.cpp +3 -36
- data/ext/em.h +2 -13
- data/ext/eventmachine.h +0 -1
- data/ext/extconf.rb +53 -46
- data/ext/project.h +0 -4
- data/ext/rubymain.cpp +0 -15
- data/lib/em/pure_ruby.rb +3 -2
- data/lib/em/version.rb +1 -1
- data/lib/eventmachine.rb +2 -0
- data/lib/jeventmachine.rb +1 -1
- data/tasks/doc.rake +30 -0
- data/tasks/package.rake +85 -0
- data/tasks/test.rake +6 -0
- metadata +184 -213
- data/ext/cplusplus.cpp +0 -202
- data/ext/emwin.cpp +0 -300
- data/ext/emwin.h +0 -94
- data/ext/epoll.cpp +0 -26
- data/ext/epoll.h +0 -25
- data/ext/eventmachine_cpp.h +0 -96
- data/ext/files.cpp +0 -94
- data/ext/files.h +0 -65
- data/ext/sigs.cpp +0 -89
- data/ext/sigs.h +0 -32
- data/java/src/com/rubyeventmachine/application/Application.java +0 -194
- data/java/src/com/rubyeventmachine/application/Connection.java +0 -74
- data/java/src/com/rubyeventmachine/application/ConnectionFactory.java +0 -37
- data/java/src/com/rubyeventmachine/application/DefaultConnectionFactory.java +0 -46
- data/java/src/com/rubyeventmachine/application/PeriodicTimer.java +0 -38
- data/java/src/com/rubyeventmachine/application/Timer.java +0 -54
- data/java/src/com/rubyeventmachine/tests/ApplicationTest.java +0 -109
- data/java/src/com/rubyeventmachine/tests/ConnectTest.java +0 -148
- data/java/src/com/rubyeventmachine/tests/EMTest.java +0 -80
- data/java/src/com/rubyeventmachine/tests/TestDatagrams.java +0 -53
- data/java/src/com/rubyeventmachine/tests/TestServers.java +0 -75
- data/java/src/com/rubyeventmachine/tests/TestTimers.java +0 -90
- data/lib/evma.rb +0 -32
- data/lib/evma/callback.rb +0 -32
- data/lib/evma/container.rb +0 -75
- data/lib/evma/factory.rb +0 -77
- data/lib/evma/protocol.rb +0 -87
- data/lib/evma/reactor.rb +0 -48
@@ -1,90 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* $Id$
|
3
|
-
*
|
4
|
-
* Author:: Francis Cianfrocca (gmail: blackhedd)
|
5
|
-
* Homepage:: http://rubyeventmachine.com
|
6
|
-
* Date:: 15 Jul 2007
|
7
|
-
*
|
8
|
-
* See EventMachine and EventMachine::Connection for documentation and
|
9
|
-
* usage examples.
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*----------------------------------------------------------------------------
|
13
|
-
*
|
14
|
-
* Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
15
|
-
* Gmail: blackhedd
|
16
|
-
*
|
17
|
-
* This program is free software; you can redistribute it and/or modify
|
18
|
-
* it under the terms of either: 1) the GNU General Public License
|
19
|
-
* as published by the Free Software Foundation; either version 2 of the
|
20
|
-
* License, or (at your option) any later version; or 2) Ruby's License.
|
21
|
-
*
|
22
|
-
* See the file COPYING for complete licensing information.
|
23
|
-
*
|
24
|
-
*---------------------------------------------------------------------------
|
25
|
-
*
|
26
|
-
*
|
27
|
-
*/
|
28
|
-
|
29
|
-
|
30
|
-
package com.rubyeventmachine.tests;
|
31
|
-
|
32
|
-
import com.rubyeventmachine.*;
|
33
|
-
import com.rubyeventmachine.application.*;
|
34
|
-
import java.io.*;
|
35
|
-
|
36
|
-
import org.junit.Assert;
|
37
|
-
import org.junit.After;
|
38
|
-
import org.junit.AfterClass;
|
39
|
-
import org.junit.Before;
|
40
|
-
import org.junit.BeforeClass;
|
41
|
-
import org.junit.Test;
|
42
|
-
|
43
|
-
|
44
|
-
public class TestTimers {
|
45
|
-
|
46
|
-
@BeforeClass
|
47
|
-
public static void setUpBeforeClass() throws Exception {
|
48
|
-
}
|
49
|
-
|
50
|
-
@AfterClass
|
51
|
-
public static void tearDownAfterClass() throws Exception {
|
52
|
-
}
|
53
|
-
|
54
|
-
@Before
|
55
|
-
public void setUp() throws Exception {
|
56
|
-
}
|
57
|
-
|
58
|
-
@After
|
59
|
-
public void tearDown() throws Exception {
|
60
|
-
}
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
@Test
|
65
|
-
public final void test2() throws IOException {
|
66
|
-
Application a = new Application();
|
67
|
-
a.addTimer(0, new Timer() {
|
68
|
-
public void fire() {
|
69
|
-
application.stop();
|
70
|
-
}
|
71
|
-
});
|
72
|
-
a.run();
|
73
|
-
Assert.assertEquals (1, 1); // just to make sure the reactor halts.
|
74
|
-
}
|
75
|
-
|
76
|
-
@Test
|
77
|
-
public final void test3() throws IOException {
|
78
|
-
Application a = new Application();
|
79
|
-
a.addTimer (0.1, new PeriodicTimer() {
|
80
|
-
int n = 0;
|
81
|
-
public void fire() {
|
82
|
-
n++;
|
83
|
-
if (n == 5)
|
84
|
-
application.stop();
|
85
|
-
}
|
86
|
-
});
|
87
|
-
a.run();
|
88
|
-
Assert.assertEquals(1, 1);
|
89
|
-
}
|
90
|
-
}
|
data/lib/evma.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
#--
|
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
|
-
|
data/lib/evma/callback.rb
DELETED
@@ -1,32 +0,0 @@
|
|
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
|
data/lib/evma/container.rb
DELETED
@@ -1,75 +0,0 @@
|
|
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
DELETED
@@ -1,77 +0,0 @@
|
|
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
|
-
|
data/lib/evma/protocol.rb
DELETED
@@ -1,87 +0,0 @@
|
|
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
DELETED
@@ -1,48 +0,0 @@
|
|
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
|
-
|