Skip to content

Commit

Permalink
Add Rakefile, gemspec, LICENSE, include case gem, and get rid of Reva…
Browse files Browse the repository at this point in the history
…ctor::ANY_MESSAGE in lieu of Object
  • Loading branch information
Tony Arcieri committed Jan 16, 2008
1 parent 14d6b37 commit ac6f511
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 4 deletions.
58 changes: 58 additions & 0 deletions LICENSE
@@ -0,0 +1,58 @@
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.co.jp>.
You can redistribute it and/or modify it under either the terms of the GPL
(see COPYING.txt file), or the conditions below:

1. You may make and give away verbatim copies of the source form of the
software without restriction, provided that you duplicate all of the
original copyright notices and associated disclaimers.

2. You may modify your copy of the software in any way, provided that
you do at least ONE of the following:

a) place your modifications in the Public Domain or otherwise
make them Freely Available, such as by posting said
modifications to Usenet or an equivalent medium, or by allowing
the author to include your modifications in the software.

b) use the modified software only within your corporation or
organization.

c) rename any non-standard executables so the names do not conflict
with standard executables, which must also be provided.

d) make other distribution arrangements with the author.

3. You may distribute the software in object code or executable
form, provided that you do at least ONE of the following:

a) distribute the executables and library files of the software,
together with instructions (in the manual page or equivalent)
on where to get the original distribution.

b) accompany the distribution with the machine-readable source of
the software.

c) give non-standard executables non-standard names, with
instructions on where to get the original software distribution.

d) make other distribution arrangements with the author.

4. You may modify and include the part of the software into any other
software (possibly commercial). But some files in the distribution
are not written by the author, so that they are not under this terms.

They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
files under the ./missing directory. See each file for the copying
condition.

5. The scripts and library files supplied as input to or produced as
output from the software do not automatically fall under the
copyright of the software, but belong to whomever generated them,
and may be sold commercially, and may be aggregated with this
software.

6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.

48 changes: 48 additions & 0 deletions Rakefile
@@ -0,0 +1,48 @@
require 'rake'
require 'rake/rdoctask'
require 'rake/gempackagetask'
load 'revactor.gemspec'

# Default Rake task
task :default => :rdoc

# RDoc
Rake::RDocTask.new(:rdoc) do |task|
task.rdoc_dir = 'doc'
task.title = 'Revactor'
task.options = %w(--title Revactor --main README --line-numbers)
task.rdoc_files.include('bin/**/*.rb')
task.rdoc_files.include('lib/**/*.rb')
task.rdoc_files.include('README')
end

# Gem
Rake::GemPackageTask.new(GEMSPEC) do |pkg|
pkg.need_tar = true
end

# RSpec
begin
require 'spec/rake/spectask'

SPECS = FileList['spec/**/*_spec.rb']

Spec::Rake::SpecTask.new(:spec) do |task|
task.spec_files = SPECS
end

namespace :spec do
Spec::Rake::SpecTask.new(:print) do |task|
task.spec_files = SPECS
task.spec_opts="-f s".split
end

Spec::Rake::SpecTask.new(:rcov) do |task|
task.spec_files = SPECS
task.rcov = true
task.rcov_opts = ['--exclude', 'spec']
end
end

rescue LoadError
end
1 change: 1 addition & 0 deletions lib/revactor.rb
Expand Up @@ -6,6 +6,7 @@

require 'rubygems'
require 'rev'
require 'case'

# This is mostly in hopes of a bright future with Rubinius
# The recommended container for all datagrams sent between
Expand Down
3 changes: 0 additions & 3 deletions lib/revactor/actor.rb
Expand Up @@ -27,9 +27,6 @@ class ActorError < StandardError; end
#
class Actor < Fiber
include Enumerable

# Actor::ANY_MESSAGE can be used in a filter match any message
ANY_MESSAGE = Object unless defined? Actor::ANY_MESSAGE
@@registered = {}

class << self
Expand Down
2 changes: 1 addition & 1 deletion lib/revactor/server.rb
Expand Up @@ -54,7 +54,7 @@ def start
@running = true
while @running do
Actor.receive do |filter|
filter.when(Actor::ANY_MESSAGE) { |message| handle_message(message) }
filter.when(Object) { |message| handle_message(message) }
filter.after(@timeout) { stop(:timeout) } if @timeout
end
end
Expand Down
27 changes: 27 additions & 0 deletions revactor.gemspec
@@ -0,0 +1,27 @@
require 'rubygems'

GEMSPEC = Gem::Specification.new do |s|
s.name = "revactor"
s.version = "0.1.0"
s.authors = "Tony Arcieri"
s.email = "tony@medioh.com"
s.date = "2008-1-15"
s.summary = "Revactor is an Actor implementation for writing high performance concurrent programs"
s.platform = Gem::Platform::RUBY

# Gem contents
s.files = Dir.glob("{bin,lib,conf,status}/**/*") + ['Rakefile', 'revactor.gemspec']

# Dependencies
s.add_dependency("rev", ">= 0.1.2")
s.add_dependency("case", ">= 0.1")

# RubyForge info
s.homepage = "http://revactor.org"
s.rubyforge_project = "revactor"

# RDoc settings
s.has_rdoc = true
s.rdoc_options = %w(--title Revactor --main README --line-numbers)
s.extra_rdoc_files = ["LICENSE", "README", "CHANGES"]
end
33 changes: 33 additions & 0 deletions tools/messaging_throughput.rb
@@ -0,0 +1,33 @@
require File.dirname(__FILE__) + '/../lib/revactor'

NTIMES=100000

begin_time = Time.now

puts "#{begin_time.strftime('%H:%M:%S')} -- Sending #{NTIMES} messages"

Actor.start do
parent = Actor.current
child = Actor.spawn do
(NTIMES / 2).times do
Actor.receive do |f|
f.when(:foo) { parent << :bar }
end
end
end

child << :foo
(NTIMES / 2).times do
Actor.receive do |f|
f.when(:bar) { child << :foo }
end
end
end

end_time = Time.now
duration = end_time - begin_time
throughput = NTIMES / duration

puts "#{end_time.strftime('%H:%M:%S')} -- Finished"
puts "Duration: #{sprintf("%0.2f", duration)} seconds"
puts "Throughput: #{sprintf("%0.2f", throughput)} messages per second"

0 comments on commit ac6f511

Please sign in to comment.