eventmachine 1.0.0.beta.1 → 1.0.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/Rakefile +7 -298
  2. data/eventmachine.gemspec +1 -1
  3. data/ext/cmain.cpp +0 -14
  4. data/ext/em.cpp +3 -36
  5. data/ext/em.h +2 -13
  6. data/ext/eventmachine.h +0 -1
  7. data/ext/extconf.rb +53 -46
  8. data/ext/project.h +0 -4
  9. data/ext/rubymain.cpp +0 -15
  10. data/lib/em/pure_ruby.rb +3 -2
  11. data/lib/em/version.rb +1 -1
  12. data/lib/eventmachine.rb +2 -0
  13. data/lib/jeventmachine.rb +1 -1
  14. data/tasks/doc.rake +30 -0
  15. data/tasks/package.rake +85 -0
  16. data/tasks/test.rake +6 -0
  17. metadata +6 -35
  18. data/ext/cplusplus.cpp +0 -202
  19. data/ext/emwin.cpp +0 -300
  20. data/ext/emwin.h +0 -94
  21. data/ext/epoll.cpp +0 -26
  22. data/ext/epoll.h +0 -25
  23. data/ext/eventmachine_cpp.h +0 -96
  24. data/ext/files.cpp +0 -94
  25. data/ext/files.h +0 -65
  26. data/ext/sigs.cpp +0 -89
  27. data/ext/sigs.h +0 -32
  28. data/java/src/com/rubyeventmachine/application/Application.java +0 -194
  29. data/java/src/com/rubyeventmachine/application/Connection.java +0 -74
  30. data/java/src/com/rubyeventmachine/application/ConnectionFactory.java +0 -37
  31. data/java/src/com/rubyeventmachine/application/DefaultConnectionFactory.java +0 -46
  32. data/java/src/com/rubyeventmachine/application/PeriodicTimer.java +0 -38
  33. data/java/src/com/rubyeventmachine/application/Timer.java +0 -54
  34. data/java/src/com/rubyeventmachine/tests/ApplicationTest.java +0 -109
  35. data/java/src/com/rubyeventmachine/tests/ConnectTest.java +0 -148
  36. data/java/src/com/rubyeventmachine/tests/EMTest.java +0 -80
  37. data/java/src/com/rubyeventmachine/tests/TestDatagrams.java +0 -53
  38. data/java/src/com/rubyeventmachine/tests/TestServers.java +0 -75
  39. data/java/src/com/rubyeventmachine/tests/TestTimers.java +0 -90
  40. data/lib/evma.rb +0 -32
  41. data/lib/evma/callback.rb +0 -32
  42. data/lib/evma/container.rb +0 -75
  43. data/lib/evma/factory.rb +0 -77
  44. data/lib/evma/protocol.rb +0 -87
  45. data/lib/evma/reactor.rb +0 -48
data/Rakefile CHANGED
@@ -1,302 +1,11 @@
1
- #!/usr/bin/env rake
2
- #
3
- # Ruby/EventMachine
4
- # http://rubyeventmachine.com
5
- # Copyright (C) 2006-07 by Francis Cianfrocca
6
- #
7
- # This program is copyrighted free software. You may use it under
8
- # the terms of either the GPL or Ruby's License. See the file
9
- # COPYING in the EventMachine distribution for full licensing
10
- # information.
11
- #
1
+ require 'rubygems' unless defined?(Gem)
2
+ require 'rake' unless defined?(Rake)
3
+ import *Dir['tasks/*.rake']
12
4
 
13
- require 'rubygems' unless defined?(Gem)
14
- require 'rake' unless defined?(Rake)
15
-
16
- Package = false # Build zips and tarballs?
17
- Dir.glob('tasks/*.rake').each { |r| Rake.application.add_import r }
18
-
19
- MAKE = ENV['MAKE'] || if RUBY_PLATFORM =~ /mswin/ # mingw uses make.
20
- 'nmake'
21
- else
22
- 'make'
23
- end
24
-
25
- desc "Build gemspec, then build eventmachine, then run tests."
26
- task :default => [:build, :test]
27
-
28
- desc "Build extension (or EVENTMACHINE_LIBRARY) and place in lib"
29
- build_task = 'ext:build'
30
- build_task = 'java:build' if RUBY_PLATFORM =~ /java/
31
- task :build => build_task do |t|
32
- Dir.glob('{ext,java/src,ext/fastfilereader}/*.{so,bundle,dll,jar}').each do |f|
33
- mv f, "lib"
34
- end
35
- end
36
-
37
- task :dummy_build
38
-
39
- require 'rake/testtask'
40
- Rake::TestTask.new(:test) do |t|
41
- t.pattern = 'tests/**/test_*.rb'
42
- t.warning = true
43
- end
44
-
45
- # Basic clean definition, this is enhanced by imports aswell.
46
- task :clean do
47
- chdir 'ext' do
48
- sh "#{MAKE} clean" if test ?e, 'Makefile'
49
- end
50
- chdir 'ext/fastfilereader' do
51
- sh "#{MAKE} clean" if test ?e, 'Makefile'
52
- end
53
- Dir.glob('**/Makefile').each { |file| rm file }
54
- Dir.glob('**/*.{o,so,bundle,class,jar,dll,log}').each { |file| rm file }
55
- Dir.glob('ext/**/conftest.dSYM').each{ |file| rm_rf file }
56
- end
57
-
58
- Spec = eval(File.read(File.expand_path('../eventmachine.gemspec', __FILE__)))
59
-
60
- if RUBY_PLATFORM =~ /mswin/
61
- Spec.platform = 'x86-mswin32-60'
62
- Spec.files += %w[ lib/rubyeventmachine.so lib/fastfilereaderext.so ]
63
- Spec.extensions = nil
64
- elsif RUBY_PLATFORM =~ /java/
65
- Spec.platform = 'java'
66
- Spec.files += %w[ lib/em_reactor.jar ]
67
- Spec.extensions = nil
68
- end
69
-
70
- # this is a hack right now, it requires installing msysgit in the global path so it can use tar/curl/etc.
71
- namespace :win32 do
72
- task :check_git do
73
- unless `git` =~ /rebase/
74
- raise 'git not found, install msys git into the GLOBAL PATH: http://msysgit.googlecode.com/files/Git-1.6.2-preview20090308.exe'
75
- end
76
- end
77
-
78
- task :check_vc6 do
79
- begin
80
- raise unless `nmake 2>&1` =~ /Microsoft/
81
- rescue
82
- raise 'VC6 not found, please run c:\vc\setvc.bat vc6'
83
- end
84
- end
85
-
86
- task :check_perl do
87
- unless `perl --version` =~ /ActiveState/
88
- raise 'ActiveState perl required to build OpenSSL: http://downloads.activestate.com/ActivePerl/Windows/5.10/ActivePerl-5.10.0.1004-MSWin32-x86-287188.msi'
89
- end
90
- end
91
-
92
- task :build_openssl => [:check_git, :check_perl, :check_vc6] do
93
- mkdir_p 'build'
94
- chdir 'build' do
95
- unless File.exists?('openssl-0.9.8j')
96
- sh 'curl http://www.openssl.org/source/openssl-0.9.8j.tar.gz > openssl.tar.gz'
97
- sh 'tar zxvf openssl.tar.gz' rescue nil # fails because of symlinks
98
- end
99
-
100
- mkdir_p 'local'
101
- chdir 'openssl-0.9.8j' do
102
- sh "perl Configure VC-WIN32 --prefix=\"../local/\""
103
- sh 'ms\do_ms.bat'
104
- sh 'nmake -f ms\nt.mak install'
105
- end
106
-
107
- chdir '../ext' do
108
- sh 'git clean -fd .'
109
- end
110
-
111
- mv 'local/include/openssl', '../ext/'
112
- mv 'local/lib/ssleay32.lib', '../ext/'
113
- mv 'local/lib/libeay32.lib', '../ext/'
114
- end
115
- end
116
-
117
- desc "build binary win32 gem"
118
- task :gem => :build_openssl do
119
- Rake::Task['build'].invoke
120
- Rake::Task['gem'].invoke
121
- end
122
- end
123
-
124
- namespace :ext do
125
- ext_sources = FileList['ext/*.{h,cpp,rb,c}']
126
- ffr_sources = FileList['ext/fastfilereader/*.{h,cpp,rb}']
127
- file ext_extconf = 'ext/extconf.rb'
128
- file ffr_extconf = 'ext/fastfilereader/extconf.rb'
129
- ext_libname = "lib/rubyeventmachine.#{Config::CONFIG['DLEXT']}"
130
- ffr_libname = "lib/fastfilereaderext.#{Config::CONFIG['DLEXT']}"
131
-
132
- file ext_libname => ext_sources + ['ext/Makefile'] do
133
- chdir('ext') { sh MAKE }
134
- end
135
-
136
- file ffr_libname => ffr_sources + ['ext/fastfilereader/Makefile'] do
137
- chdir('ext/fastfilereader') { sh MAKE }
138
- end
139
-
140
- desc "Build C++ extension"
141
- task :build => [:make]
142
-
143
- task :make => ext_libname
144
- task :make => ffr_libname
145
-
146
- file 'ext/Makefile' => ext_extconf do
147
- chdir 'ext' do
148
- ruby 'extconf.rb'
149
- end
150
- end
151
-
152
- file 'ext/fastfilereader/Makefile' => ffr_extconf do
153
- chdir 'ext/fastfilereader' do
154
- ruby 'extconf.rb'
155
- end
156
- end
157
- end
158
-
159
- namespace :java do
160
- # This task creates the JRuby JAR file and leaves it in the lib directory.
161
- # This step is required before executing the jgem task.
162
- desc "Build java extension"
163
- task :build => [:jar] do |t|
164
- mv 'java/em_reactor.jar', 'lib/'
165
- end
166
-
167
- task :compile do
168
- chdir('java') do
169
- mkdir_p "build"
170
- sh 'javac src/com/rubyeventmachine/*.java -d build'
171
- end
172
- end
173
-
174
- task :jar => [:compile] do
175
- chdir('java/build') do
176
- sh "jar -cf ../em_reactor.jar com/rubyeventmachine/*.class"
177
- end
178
- end
179
-
180
- desc "build a java binary gem"
181
- task :gem => :build do
182
- Spec.platform = 'java'
183
- Spec.files += %w[ lib/em_reactor.jar ]
184
- Spec.extensions = nil
185
-
186
- Rake::Task['gem'].invoke
187
- end
188
- end
189
-
190
- namespace :osx do
191
- desc "Build OSX binary gem"
192
- task :gem do
193
- Spec.platform = RUBY_PLATFORM.sub(/darwin.+$/, 'darwin')
194
- Spec.files += %w[ lib/rubyeventmachine.bundle lib/fastfilereaderext.bundle ]
195
- Spec.extensions = nil
196
-
197
- Rake::Task['build'].invoke
198
- Rake::Task['gem'].invoke
199
- end
200
-
201
- # XXX gcc will still prefer the shared libssl on the system, so we need to hack the extconf
202
- # XXX to use the static library to make this actually work
203
- task :static_gem => [:build_openssl, :gem]
204
-
205
- task :build_openssl do
206
- mkdir_p 'build'
207
- chdir 'build' do
208
- unless File.exists?('openssl-0.9.8j')
209
- sh 'curl http://www.openssl.org/source/openssl-0.9.8j.tar.gz > openssl-0.9.8j.tar.gz'
210
- sh 'tar zxvf openssl-0.9.8j.tar.gz'
211
- end
212
-
213
- mkdir_p 'local'
214
- chdir 'openssl-0.9.8j' do
215
- local_dir = File.expand_path(File.join(File.dirname(__FILE__),'build','local'))
216
- sh "./config --prefix=#{local_dir}"
217
- sh 'make'
218
- sh 'make install'
219
- end
220
-
221
- chdir '../ext' do
222
- sh 'git clean -fd .'
223
- end
224
-
225
- mv 'local/include/openssl', '../ext/'
226
- mv 'local/lib/libssl.a', '../ext/'
227
- mv 'local/lib/libcrypto.a', '../ext/'
228
- end
229
- end
230
- end
5
+ GEMSPEC = eval(File.read(File.expand_path('../eventmachine.gemspec', __FILE__)))
231
6
 
232
7
  require 'rake/clean'
233
-
234
- rdoc_task_type = begin
235
- require 'rdoc/task'
236
- RDoc::Task
237
- rescue LoadError
238
- require 'rake/rdoctask'
239
- Rake::RDocTask
240
- end
241
- df = begin; require 'rdoc/rdoc'; require 'rdoc/generator/darkfish'; true; rescue LoadError; end
242
- rdtask = rdoc_task_type.new do |rd|
243
- rd.title = Spec.name
244
- rd.rdoc_dir = 'rdoc'
245
- rd.main = "README"
246
- rd.rdoc_files.include("lib/**/*.rb", *Spec.extra_rdoc_files)
247
- rd.rdoc_files.exclude(*%w(lib/em/version lib/emva lib/evma/ lib/pr_eventmachine lib/jeventmachine))
248
- rd.template = 'darkfish' if df
249
- end
250
- Rake::Task[:clean].enhance [:clobber_rdoc]
251
-
252
- desc 'Generate and open documentation'
253
- task :docs => :rdoc do
254
- case RUBY_PLATFORM
255
- when /darwin/ ; sh 'open rdoc/index.html'
256
- when /mswin|mingw/ ; sh 'start rdoc\index.html'
257
- else
258
- sh 'firefox rdoc/index.html'
259
- end
260
- end
261
-
262
- def windows?; RUBY_PLATFORM =~ /mswin|mingw/; end
263
- def sudo(cmd)
264
- if windows? || (require 'etc'; Etc.getpwuid.uid == 0)
265
- sh cmd
266
- else
267
- sh "sudo #{cmd}"
268
- end
269
- end
270
- def gem_cmd(action, name, *args)
271
- rb = Gem.ruby rescue nil
272
- rb ||= (require 'rbconfig'; File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']))
273
- sudo "#{rb} -r rubygems -e 'require %{rubygems/gem_runner}; Gem::GemRunner.new.run(%w{#{action} #{name} #{args.join(' ')}})'"
274
- end
275
-
276
- begin
277
- require 'rubygems/package_task'
278
- Gem::PackageTask
279
- rescue LoadError
280
- require 'rake/gempackagetask'
281
- Rake::GemPackageTask
282
- end.new(Spec) do |pkg|
283
- pkg.need_tar, pkg.need_tar_gz, pkg.need_zip = true, true, true if Package
284
- pkg.gem_spec = Spec
285
- end
286
-
287
- Rake::Task[:clean].enhance [:clobber_package]
288
-
289
- namespace :gem do
290
- desc 'Install gem (and sudo if required)'
291
- task :install => :package do
292
- gem_cmd(:install, "pkg/#{Spec.name}-#{Spec.version}.gem")
293
- end
294
-
295
- desc 'Uninstall gem (and sudo if required)'
296
- task :uninstall do
297
- gem_cmd(:uninstall, "#{Spec.name}", "-v=#{Spec.version}")
298
- end
299
- end
300
-
301
8
  task :clobber => :clean
302
- task :test => :build
9
+
10
+ desc "Build eventmachine, then run tests."
11
+ task :default => [:compile, :test]
data/eventmachine.gemspec CHANGED
@@ -29,5 +29,5 @@ are provided with the package, primarily to serve as examples. The real goal
29
29
  of EventMachine is to enable programs to easily interface with other programs
30
30
  using TCP/IP, especially if custom protocols are required."
31
31
 
32
- s.rdoc_options = ["--title", "EventMachine", "--main", "README", "-x", "lib/em/version", "-x", "lib/emva", "-x", "lib/evma/", "-x", "lib/jeventmachine"]
32
+ s.rdoc_options = ["--title", "EventMachine", "--main", "README", "-x", "lib/em/version", "-x", "lib/jeventmachine"]
33
33
  end
data/ext/cmain.cpp CHANGED
@@ -52,9 +52,6 @@ evma_initialize_library
52
52
 
53
53
  extern "C" void evma_initialize_library (EMCallback cb)
54
54
  {
55
- // Probably a bad idea to mess with the signal mask of a process
56
- // we're just being linked into.
57
- //InstallSignalHandlers();
58
55
  if (EventMachine)
59
56
  #ifdef BUILD_FOR_RUBY
60
57
  rb_raise(rb_eRuntimeError, "eventmachine already initialized: evma_initialize_library");
@@ -553,17 +550,6 @@ extern "C" void evma_signal_loopbreak()
553
550
 
554
551
 
555
552
 
556
- /****************
557
- evma__write_file
558
- ****************/
559
-
560
- extern "C" const unsigned long evma__write_file (const char *filename)
561
- {
562
- ensure_eventmachine("evma__write_file");
563
- return EventMachine->_OpenFileForWriting (filename);
564
- }
565
-
566
-
567
553
  /********************************
568
554
  evma_get_comm_inactivity_timeout
569
555
  ********************************/
data/ext/em.cpp CHANGED
@@ -73,6 +73,7 @@ EventMachine_t::EventMachine_t (EMCallback event_callback):
73
73
  NextHeartbeatTime (0),
74
74
  LoopBreakerReader (-1),
75
75
  LoopBreakerWriter (-1),
76
+ bTerminateSignalReceived (false),
76
77
  bEpoll (false),
77
78
  epfd (-1),
78
79
  bKqueue (false),
@@ -83,7 +84,6 @@ EventMachine_t::EventMachine_t (EMCallback event_callback):
83
84
  Quantum.tv_sec = 0;
84
85
  Quantum.tv_usec = 90000;
85
86
 
86
- gTerminateSignalReceived = false;
87
87
  // Make sure the current loop time is sane, in case we do any initializations of
88
88
  // objects before we start running.
89
89
  _UpdateTime();
@@ -185,7 +185,7 @@ void EventMachine_t::ScheduleHalt()
185
185
  * We need a FAQ. And one of the questions is: how do I stop EM when Ctrl-C happens?
186
186
  * The answer is to call evma_stop_machine, which calls here, from a SIGINT handler.
187
187
  */
188
- gTerminateSignalReceived = true;
188
+ bTerminateSignalReceived = true;
189
189
  }
190
190
 
191
191
 
@@ -419,10 +419,6 @@ EventMachine_t::Run
419
419
 
420
420
  void EventMachine_t::Run()
421
421
  {
422
- #ifdef OS_WIN32
423
- HookControlC (true);
424
- #endif
425
-
426
422
  #ifdef HAVE_EPOLL
427
423
  if (bEpoll) {
428
424
  epfd = epoll_create (MaxEpollDescriptors);
@@ -474,13 +470,9 @@ void EventMachine_t::Run()
474
470
 
475
471
  if (!_RunOnce())
476
472
  break;
477
- if (gTerminateSignalReceived)
473
+ if (bTerminateSignalReceived)
478
474
  break;
479
475
  }
480
-
481
- #ifdef OS_WIN32
482
- HookControlC (false);
483
- #endif
484
476
  }
485
477
 
486
478
 
@@ -1842,31 +1834,6 @@ void EventMachine_t::Modify (EventableDescriptor *ed)
1842
1834
  }
1843
1835
 
1844
1836
 
1845
- /***********************************
1846
- EventMachine_t::_OpenFileForWriting
1847
- ***********************************/
1848
-
1849
- const unsigned long EventMachine_t::_OpenFileForWriting (const char *filename)
1850
- {
1851
- /*
1852
- * Return the binding-text of the newly-opened file,
1853
- * or NULL if there was a problem.
1854
- */
1855
-
1856
- if (!filename || !*filename)
1857
- return 0;
1858
-
1859
- int fd = open (filename, O_CREAT|O_TRUNC|O_WRONLY|O_NONBLOCK, 0644);
1860
-
1861
- FileStreamDescriptor *fsd = new FileStreamDescriptor (fd, this);
1862
- if (!fsd)
1863
- throw std::runtime_error ("no file-stream allocated");
1864
- Add (fsd);
1865
- return fsd->GetBinding();
1866
-
1867
- }
1868
-
1869
-
1870
1837
  /**************************************
1871
1838
  EventMachine_t::CreateUnixDomainServer
1872
1839
  **************************************/
data/ext/em.h CHANGED
@@ -17,16 +17,6 @@ See the file COPYING for complete licensing information.
17
17
 
18
18
  *****************************************************************************/
19
19
 
20
-
21
-
22
- #ifdef OS_WIN32
23
- #include "emwin.h"
24
- #endif
25
-
26
-
27
- // THIS ENTIRE FILE WILL EVENTUALLY BE FOR UNIX BUILDS ONLY.
28
- //#ifdef OS_UNIX
29
-
30
20
  #ifndef __EventMachine__H_
31
21
  #define __EventMachine__H_
32
22
 
@@ -85,7 +75,6 @@ class EventMachine_t
85
75
  const unsigned long CreateTcpServer (const char *, int);
86
76
  const unsigned long OpenDatagramSocket (const char *, int);
87
77
  const unsigned long CreateUnixDomainServer (const char*);
88
- const unsigned long _OpenFileForWriting (const char*);
89
78
  const unsigned long OpenKeyboard();
90
79
  //const char *Popen (const char*, const char*);
91
80
  const unsigned long Socketpair (char* const*);
@@ -200,6 +189,8 @@ class EventMachine_t
200
189
  #endif
201
190
 
202
191
  private:
192
+ bool bTerminateSignalReceived;
193
+
203
194
  bool bEpoll;
204
195
  int epfd; // Epoll file-descriptor
205
196
  #ifdef HAVE_EPOLL
@@ -235,5 +226,3 @@ struct SelectData_t
235
226
  };
236
227
 
237
228
  #endif // __EventMachine__H_
238
-
239
- //#endif // OS_UNIX