eventmachine 1.0.0.beta.1-java → 1.0.0.beta.2-java
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/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
data/ext/emwin.h
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
/*****************************************************************************
|
2
|
-
|
3
|
-
$Id$
|
4
|
-
|
5
|
-
File: emwin.h
|
6
|
-
Date: 05May06
|
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
|
-
// THIS ENTIRE FILE IS FOR WINDOWS BUILDS ONLY.
|
22
|
-
// INCOMPLETE AND DISABLED FOR NOW.
|
23
|
-
#ifdef xOS_WIN32
|
24
|
-
|
25
|
-
#ifndef __EventMachine__H_
|
26
|
-
#define __EventMachine__H_
|
27
|
-
|
28
|
-
|
29
|
-
extern time_t gCurrentLoopTime;
|
30
|
-
|
31
|
-
class EventableDescriptor;
|
32
|
-
|
33
|
-
|
34
|
-
/********************
|
35
|
-
class EventMachine_t
|
36
|
-
********************/
|
37
|
-
|
38
|
-
class EventMachine_t
|
39
|
-
{
|
40
|
-
public:
|
41
|
-
EventMachine_t (void(*event_callback)(const char*, int, const char*, int));
|
42
|
-
virtual ~EventMachine_t();
|
43
|
-
|
44
|
-
void Run();
|
45
|
-
void ScheduleHalt();
|
46
|
-
const char *InstallOneshotTimer (int);
|
47
|
-
const char *ConnectToServer (const char *, int);
|
48
|
-
const char *CreateTcpServer (const char *, int);
|
49
|
-
const char *OpenDatagramSocket (const char *, int);
|
50
|
-
|
51
|
-
void Add (EventableDescriptor*);
|
52
|
-
|
53
|
-
public:
|
54
|
-
enum { // Event names
|
55
|
-
TIMER_FIRED = 100,
|
56
|
-
CONNECTION_READ = 101,
|
57
|
-
CONNECTION_UNBOUND = 102,
|
58
|
-
CONNECTION_ACCEPTED = 103,
|
59
|
-
CONNECTION_COMPLETED = 104,
|
60
|
-
LOOPBREAK_SIGNAL = 105
|
61
|
-
};
|
62
|
-
|
63
|
-
private:
|
64
|
-
HANDLE Iocp;
|
65
|
-
|
66
|
-
private:
|
67
|
-
bool _RunOnce();
|
68
|
-
bool _RunTimers();
|
69
|
-
void _AddNewDescriptors();
|
70
|
-
|
71
|
-
private:
|
72
|
-
enum {
|
73
|
-
MaxOutstandingTimers = 40,
|
74
|
-
HeartbeatInterval = 2
|
75
|
-
};
|
76
|
-
void (*EventCallback)(const char*, int, const char*, int);
|
77
|
-
|
78
|
-
class Timer_t: public Bindable_t {
|
79
|
-
};
|
80
|
-
|
81
|
-
multimap<time_t, Timer_t> Timers;
|
82
|
-
vector<EventableDescriptor*> Descriptors;
|
83
|
-
vector<EventableDescriptor*> NewDescriptors;
|
84
|
-
|
85
|
-
time_t NextHeartbeatTime;
|
86
|
-
};
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
#endif // __EventMachine__H_
|
92
|
-
|
93
|
-
#endif // OS_WIN32
|
94
|
-
|
data/ext/epoll.cpp
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
/*****************************************************************************
|
2
|
-
|
3
|
-
$Id$
|
4
|
-
|
5
|
-
File: epoll.cpp
|
6
|
-
Date: 06Jun07
|
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
|
-
#ifdef HAVE_EPOLL
|
22
|
-
|
23
|
-
#include "project.h"
|
24
|
-
|
25
|
-
#endif // HAVE_EPOLL
|
26
|
-
|
data/ext/epoll.h
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
/*****************************************************************************
|
2
|
-
|
3
|
-
$Id$
|
4
|
-
|
5
|
-
File: epoll.h
|
6
|
-
Date: 06Jun07
|
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
|
-
#ifdef HAVE_EPOLL
|
22
|
-
|
23
|
-
|
24
|
-
#endif // HAVE_EPOLL
|
25
|
-
|
data/ext/eventmachine_cpp.h
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
/*****************************************************************************
|
2
|
-
|
3
|
-
$Id$
|
4
|
-
|
5
|
-
File: eventmachine_cpp.h
|
6
|
-
Date: 27Jul07
|
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 __EVMA_EventmachineCpp__H_
|
22
|
-
#define __EVMA_EventmachineCpp__H_
|
23
|
-
|
24
|
-
|
25
|
-
// This material is only for directly integrating EM into C++ programs.
|
26
|
-
|
27
|
-
namespace EM {
|
28
|
-
|
29
|
-
void Callback (const unsigned long sig, int event, const char *data, const unsigned long length);
|
30
|
-
void Run (void(*)(void));
|
31
|
-
void AddTimer (int, void(*)());
|
32
|
-
void StopReactor();
|
33
|
-
|
34
|
-
/***************
|
35
|
-
class Eventable
|
36
|
-
***************/
|
37
|
-
|
38
|
-
class Eventable {
|
39
|
-
public:
|
40
|
-
Eventable() {}
|
41
|
-
virtual ~Eventable() {}
|
42
|
-
|
43
|
-
unsigned long Signature;
|
44
|
-
|
45
|
-
// Called by the framework
|
46
|
-
virtual void ReceiveData (const char *data, int length) {}
|
47
|
-
virtual void ConnectionCompleted() {}
|
48
|
-
virtual void Accept (const unsigned long) {}
|
49
|
-
virtual void Unbind() {}
|
50
|
-
virtual void PostInit() {}
|
51
|
-
virtual void SslHandshakeCompleted() {}
|
52
|
-
|
53
|
-
void StopReactor() {EM::StopReactor();}
|
54
|
-
};
|
55
|
-
|
56
|
-
/****************
|
57
|
-
class Connection
|
58
|
-
****************/
|
59
|
-
|
60
|
-
class Connection: public Eventable {
|
61
|
-
public:
|
62
|
-
Connection() {}
|
63
|
-
virtual ~Connection() {}
|
64
|
-
|
65
|
-
virtual void Connect (const char*, int);
|
66
|
-
virtual void BindConnect (const char *, int, const char*, int);
|
67
|
-
|
68
|
-
void SendData (const char *data);
|
69
|
-
void SendData (const char *data, int length);
|
70
|
-
void Close (bool afterWriting);
|
71
|
-
};
|
72
|
-
|
73
|
-
|
74
|
-
/**************
|
75
|
-
class Acceptor
|
76
|
-
**************/
|
77
|
-
|
78
|
-
class Acceptor: public Eventable {
|
79
|
-
public:
|
80
|
-
Acceptor() {PostInit();}
|
81
|
-
virtual ~Acceptor() {}
|
82
|
-
|
83
|
-
void Start (const char*, int);
|
84
|
-
void Accept (const unsigned long);
|
85
|
-
|
86
|
-
virtual Connection *MakeConnection() {return new Connection();}
|
87
|
-
};
|
88
|
-
|
89
|
-
|
90
|
-
};
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
#endif // __EVMA_EventmachineCpp__H_
|
data/ext/files.cpp
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
/*****************************************************************************
|
2
|
-
|
3
|
-
$Id$
|
4
|
-
|
5
|
-
File: files.cpp
|
6
|
-
Date: 26Aug06
|
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
|
-
#include "project.h"
|
21
|
-
|
22
|
-
|
23
|
-
/******************************************
|
24
|
-
FileStreamDescriptor::FileStreamDescriptor
|
25
|
-
******************************************/
|
26
|
-
|
27
|
-
FileStreamDescriptor::FileStreamDescriptor (int fd, EventMachine_t *em):
|
28
|
-
EventableDescriptor (fd, em),
|
29
|
-
OutboundDataSize (0)
|
30
|
-
{
|
31
|
-
cerr << "#####";
|
32
|
-
}
|
33
|
-
|
34
|
-
|
35
|
-
/*******************************************
|
36
|
-
FileStreamDescriptor::~FileStreamDescriptor
|
37
|
-
*******************************************/
|
38
|
-
|
39
|
-
FileStreamDescriptor::~FileStreamDescriptor()
|
40
|
-
{
|
41
|
-
// Run down any stranded outbound data.
|
42
|
-
for (size_t i=0; i < OutboundPages.size(); i++)
|
43
|
-
OutboundPages[i].Free();
|
44
|
-
}
|
45
|
-
|
46
|
-
|
47
|
-
/**************************
|
48
|
-
FileStreamDescriptor::Read
|
49
|
-
**************************/
|
50
|
-
|
51
|
-
void FileStreamDescriptor::Read()
|
52
|
-
{
|
53
|
-
}
|
54
|
-
|
55
|
-
/***************************
|
56
|
-
FileStreamDescriptor::Write
|
57
|
-
***************************/
|
58
|
-
|
59
|
-
void FileStreamDescriptor::Write()
|
60
|
-
{
|
61
|
-
}
|
62
|
-
|
63
|
-
|
64
|
-
/*******************************
|
65
|
-
FileStreamDescriptor::Heartbeat
|
66
|
-
*******************************/
|
67
|
-
|
68
|
-
void FileStreamDescriptor::Heartbeat()
|
69
|
-
{
|
70
|
-
}
|
71
|
-
|
72
|
-
|
73
|
-
/***********************************
|
74
|
-
FileStreamDescriptor::SelectForRead
|
75
|
-
***********************************/
|
76
|
-
|
77
|
-
bool FileStreamDescriptor::SelectForRead()
|
78
|
-
{
|
79
|
-
cerr << "R?";
|
80
|
-
return false;
|
81
|
-
}
|
82
|
-
|
83
|
-
|
84
|
-
/************************************
|
85
|
-
FileStreamDescriptor::SelectForWrite
|
86
|
-
************************************/
|
87
|
-
|
88
|
-
bool FileStreamDescriptor::SelectForWrite()
|
89
|
-
{
|
90
|
-
cerr << "W?";
|
91
|
-
return false;
|
92
|
-
}
|
93
|
-
|
94
|
-
|
data/ext/files.h
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
/*****************************************************************************
|
2
|
-
|
3
|
-
$Id$
|
4
|
-
|
5
|
-
File: files.h
|
6
|
-
Date: 26Aug06
|
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 __FileStreamDescriptor__H_
|
22
|
-
#define __FileStreamDescriptor__H_
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
/**************************
|
27
|
-
class FileStreamDescriptor
|
28
|
-
**************************/
|
29
|
-
|
30
|
-
class FileStreamDescriptor: public EventableDescriptor
|
31
|
-
{
|
32
|
-
public:
|
33
|
-
FileStreamDescriptor (int, EventMachine_t*);
|
34
|
-
virtual ~FileStreamDescriptor();
|
35
|
-
|
36
|
-
virtual void Read();
|
37
|
-
virtual void Write();
|
38
|
-
virtual void Heartbeat();
|
39
|
-
|
40
|
-
virtual bool SelectForRead();
|
41
|
-
virtual bool SelectForWrite();
|
42
|
-
|
43
|
-
// Do we have any data to write? This is used by ShouldDelete.
|
44
|
-
virtual int GetOutboundDataSize() {return OutboundDataSize;}
|
45
|
-
|
46
|
-
protected:
|
47
|
-
struct OutboundPage {
|
48
|
-
OutboundPage (const char *b, int l, int o=0): Buffer(b), Length(l), Offset(o) {}
|
49
|
-
void Free() {if (Buffer) free ((char*)Buffer); }
|
50
|
-
const char *Buffer;
|
51
|
-
int Length;
|
52
|
-
int Offset;
|
53
|
-
};
|
54
|
-
|
55
|
-
protected:
|
56
|
-
deque<OutboundPage> OutboundPages;
|
57
|
-
int OutboundDataSize;
|
58
|
-
|
59
|
-
private:
|
60
|
-
|
61
|
-
};
|
62
|
-
|
63
|
-
|
64
|
-
#endif // __FileStreamDescriptor__H_
|
65
|
-
|
data/ext/sigs.cpp
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
/*****************************************************************************
|
2
|
-
|
3
|
-
$Id$
|
4
|
-
|
5
|
-
File: sigs.cpp
|
6
|
-
Date: 06Apr06
|
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
|
-
#include "project.h"
|
21
|
-
|
22
|
-
|
23
|
-
bool gTerminateSignalReceived;
|
24
|
-
|
25
|
-
|
26
|
-
/**************
|
27
|
-
SigtermHandler
|
28
|
-
**************/
|
29
|
-
|
30
|
-
void SigtermHandler (int sig)
|
31
|
-
{
|
32
|
-
// This is a signal-handler, don't do anything frisky. Interrupts are disabled.
|
33
|
-
// Set the terminate flag WITHOUT trying to lock a mutex- otherwise we can easily
|
34
|
-
// self-deadlock, especially if the event machine is looping quickly.
|
35
|
-
gTerminateSignalReceived = true;
|
36
|
-
}
|
37
|
-
|
38
|
-
|
39
|
-
/*********************
|
40
|
-
InstallSignalHandlers
|
41
|
-
*********************/
|
42
|
-
|
43
|
-
void InstallSignalHandlers()
|
44
|
-
{
|
45
|
-
#ifdef OS_UNIX
|
46
|
-
static bool bInstalled = false;
|
47
|
-
if (!bInstalled) {
|
48
|
-
bInstalled = true;
|
49
|
-
signal (SIGINT, SigtermHandler);
|
50
|
-
signal (SIGTERM, SigtermHandler);
|
51
|
-
signal (SIGPIPE, SIG_IGN);
|
52
|
-
}
|
53
|
-
#endif
|
54
|
-
}
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
/*******************
|
59
|
-
WintelSignalHandler
|
60
|
-
*******************/
|
61
|
-
|
62
|
-
#ifdef OS_WIN32
|
63
|
-
BOOL WINAPI WintelSignalHandler (DWORD control)
|
64
|
-
{
|
65
|
-
if (control == CTRL_C_EVENT)
|
66
|
-
gTerminateSignalReceived = true;
|
67
|
-
return TRUE;
|
68
|
-
}
|
69
|
-
#endif
|
70
|
-
|
71
|
-
/************
|
72
|
-
HookControlC
|
73
|
-
************/
|
74
|
-
|
75
|
-
#ifdef OS_WIN32
|
76
|
-
void HookControlC (bool hook)
|
77
|
-
{
|
78
|
-
if (hook) {
|
79
|
-
// INSTALL hook
|
80
|
-
SetConsoleCtrlHandler (WintelSignalHandler, TRUE);
|
81
|
-
}
|
82
|
-
else {
|
83
|
-
// UNINSTALL hook
|
84
|
-
SetConsoleCtrlHandler (WintelSignalHandler, FALSE);
|
85
|
-
}
|
86
|
-
}
|
87
|
-
#endif
|
88
|
-
|
89
|
-
|