Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/celluloid/celluloid-io in…
Browse files Browse the repository at this point in the history
…to nonblock_without_exception

Conflicts:
	lib/celluloid/io/stream.rb
	spec/celluloid/io/actor_spec.rb
	spec/celluloid/io/dns_resolver_spec.rb
	spec/celluloid/io/mailbox_spec.rb
	spec/celluloid/io/ssl_server_spec.rb
	spec/celluloid/io/ssl_socket_spec.rb
	spec/celluloid/io/tcp_server_spec.rb
	spec/celluloid/io/tcp_socket_spec.rb
	spec/celluloid/io/udp_socket_spec.rb
	spec/celluloid/io/unix_server_spec.rb
	spec/celluloid/io/unix_socket_spec.rb
	spec/celluloid/io_spec.rb
  • Loading branch information
Tiago Cardoso committed Jan 8, 2016
2 parents 5321f59 + 002de5e commit 8098ebc
Show file tree
Hide file tree
Showing 47 changed files with 1,184 additions and 535 deletions.
4 changes: 4 additions & 0 deletions .env-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CELLULOID_SPECS_LOG_STRATEGY=stderr
CELLULOID_SPECS_LOG_LEVEL=3
CELLULOID_SPECS_LOG_FILE=log/ci.log
CELLULOID_SPECS_LOG_SYNC=false
4 changes: 4 additions & 0 deletions .env-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CELLULOID_SPECS_LOG_STRATEGY=single
CELLULOID_SPECS_LOG_FILE=log/test.log
CELLULOID_SPECS_LOG_LEVEL=0
CELLULOID_SPECS_LOG_SYNC=true
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "culture"]
path = culture
url = http://github.com/celluloid/culture.git
7 changes: 4 additions & 3 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
--color
--format documentation
--color
--format documentation
--backtrace
--default_path spec
--order random
--warnings
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
inherit_from:
- culture/rubocop/rubocop.yml
35 changes: 29 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
script: rake ci
language: ruby
rvm:
- 1.9.3
- rbx-2
- jruby
- 2.3.0
- 2.2.2
- 2.2.0
- 2.1.4
- 2.0.0
- 2.1.0
- 1.9.3
- ruby-head
- jruby
- jruby-head
- rbx

matrix:
fast_finish: true
allow_failures:
- rvm: 1.9.3
- rvm: ruby-head
- rvm: jruby
- rvm: jruby-head
- rvm: rbx
- env: CELLULOID_BACKPORTED=true
- env: CELLULOID_BACKPORTED=false CELLULOID_TASK_CLASS=Threaded
- env: CELLULOID_BACKPORTED=true CELLULOID_TASK_CLASS=Threaded

env:
global:
- NUMBER_OF_PROCESSORS=4 CELLULOID_CONFIG_FILE=.env-ci
matrix:
- CELLULOID_BACKPORTED=true
- CELLULOID_BACKPORTED=false
- CELLULOID_BACKPORTED=false CELLULOID_TASK_CLASS=Threaded
- CELLULOID_BACKPORTED=true CELLULOID_TASK_CLASS=Threaded

notifications:
irc: "irc.freenode.org#celluloid"

before_install:
# Only use 1 job until Travis fixes the rbx --jobs issue.
- if [ "$TRAVIS_RUBY_VERSION" == "rbx-2" ] ; then export BUNDLE_JOBS=1 ; else export BUNDLE_JOBS=4; fi

sudo: false
install: bundle install --without=development
44 changes: 35 additions & 9 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,52 @@
HEAD
----
0.17.2 (2015-09-30)
-----
* Revamped test suite, using shared RSpec configuration layer provided by Celluloid itself.
* Updated gem dependencies provided by Celluloid::Sync... extraneous gems removed, or marked as development dependencies.

0.17.1 (2015-08-24)
-----
* Minor bug fixes. Synchronize gem dependencies.

0.17.0 (2015-08-07)
-----
* Compatibility with Celluloid 0.17.0+
* Adjust class name for Celluloid::Mailbox::Evented, per 0.17.0 of Celluloid.

0.16.2 (2015-01-30)
-----
* More TCPSocket compatibility fixes
* Ensure monitors are closed when tasks resume
* Fix Errno::EAGAIN handling in Stream#syswrite

0.16.1 (2014-10-08)
-----
* Revert read/write interest patch as it caused file descriptor leaks

0.16.0 (2014-09-04)
-----
* Fix bug handling simultaneous read/write interests
* Use Resolv::DNS::Config to obtain nameservers
* Celluloid::IO.copy_stream support (uses a background thread)

0.15.0 (2013-09-04)
-------------------
-----
* Improved DNS resolver with less NIH and more Ruby stdlib goodness
* Better match Ruby stdlib TCPServer API
* Add missing #send and #recv on Celluloid::IO::TCPSocket
* Add missing #setsockopt method on Celluloid::IO::TCPServer
* Add missing #peeraddr method on Celluloid::IO::SSLSocket

0.14.0 (2013-05-07)
-------------------
-----
* Add `close_read`/`close_write` delegates for rack-hijack support
* Depend on EventedMailbox from core

0.13.1
------
-----
* Remove overhead for `wait_readable`/`wait_writable`

0.13.0
------
-----
* Support for many, many more IO methods, particularly line-oriented
methods like #gets, #readline, and #readlines
* Initial SSL support via Celluloid::IO::SSLSocket and
Expand All @@ -30,15 +56,15 @@ HEAD
* Celluloid 0.13 compatibility fixes

0.12.0
------
-----
* Tracking release for Celluloid 0.12.0

0.11.0
------
-----
* "Unofficial" SSL support (via nio4r 0.4.0)

0.10.0
------
-----
* Read/write operations are now atomic across tasks
* True non-blocking connect support
* Non-blocking DNS resolution support
Expand Down
6 changes: 2 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
source 'https://rubygems.org'
gemspec
require File.expand_path("../culture/sync", __FILE__)

gem 'coveralls', require: false
gem 'celluloid', github: 'celluloid/celluloid', branch: 'master'
Celluloid::Sync::Gemfile[self]
4 changes: 2 additions & 2 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
guard 'rspec', :cli => '--format documentation' do
guard "rspec", cli: "--format documentation" do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec/" }
watch("spec/spec_helper.rb") { "spec/" }
end
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env rake
require 'bundler/gem_tasks'
require "bundler/gem_tasks"
Dir["tasks/**/*.task"].each { |task| load task }

task :default => :spec
task :ci => %w(spec benchmark)
task default: :spec
task ci: %w(spec benchmark)
7 changes: 4 additions & 3 deletions benchmarks/actor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
require 'celluloid/io'
require 'benchmark/ips'

class ExampleActor
#de TODO: Consolidate with Celluloid benchmarking actor.
class BenchmarkingActor
include Celluloid::IO

def initialize
Expand All @@ -23,7 +24,7 @@ def wait_until_finished
end
end

example_actor = ExampleActor.new
example_actor = BenchmarkingActor.new
mailbox = Celluloid::IO::Mailbox.new

latch_in, latch_out = Queue.new, Queue.new
Expand All @@ -36,7 +37,7 @@ def wait_until_finished
end

Benchmark.ips do |ips|
ips.report("spawn") { ExampleActor.new.terminate }
ips.report("spawn") { BenchmarkingActor.new.terminate }

ips.report("calls") { example_actor.example_method }

Expand Down
21 changes: 9 additions & 12 deletions celluloid-io.gemspec
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/celluloid/io/version', __FILE__)
require File.expand_path("../culture/sync", __FILE__)

Gem::Specification.new do |gem|
gem.name = "celluloid-io"
gem.version = Celluloid::IO::VERSION
gem.license = 'MIT'
gem.authors = ["Tony Arcieri"]
gem.email = ["[email protected]"]
gem.license = "MIT"
gem.authors = ["Tony Arcieri", "Donovan Keme"]
gem.email = ["[email protected]", "[email protected]"]
gem.description = "Evented IO for Celluloid actors"
gem.summary = "Celluloid::IO allows you to monitor multiple IO objects within a Celluloid actor"
gem.homepage = "http://github.com/celluloid/celluloid-io"

gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
gem.require_paths = ["lib"]

gem.add_dependency 'celluloid', '>= 0.16.0.pre'
gem.add_dependency 'nio4r', '>= 1.0.0'
Celluloid::Sync::Gemspec[gem]

gem.add_development_dependency 'rake'
gem.add_development_dependency 'rspec'
gem.add_development_dependency 'benchmark_suite'
gem.add_development_dependency 'guard-rspec'
gem.add_development_dependency 'rb-fsevent', '~> 0.9.1' if RUBY_PLATFORM =~ /darwin/
gem.add_dependency "nio4r", ">= 1.1"

gem.add_development_dependency "rb-fsevent", "~> 0.9.1" if RUBY_PLATFORM =~ /darwin/
end
1 change: 1 addition & 0 deletions culture
Submodule culture added at d76f77
7 changes: 3 additions & 4 deletions examples/echo_client.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env ruby

require 'rubygems'
require 'bundler/setup'
require 'celluloid/io'
require "rubygems"
require "bundler/setup"
require "celluloid/io"

class EchoClient
include Celluloid::IO
Expand All @@ -18,7 +18,6 @@ def echo(s)
@socket.write(s)
@socket.readpartial(4096)
end

end

client = EchoClient.new("127.0.0.1", 1234)
Expand Down
4 changes: 2 additions & 2 deletions examples/echo_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
# Run this as: bundle exec examples/echo_server.rb

require 'bundler/setup'
require 'celluloid/io'
require "bundler/setup"
require "celluloid/io"

class EchoServer
include Celluloid::IO
Expand Down
5 changes: 2 additions & 3 deletions examples/echo_unix_client.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'bundler/setup'
require 'celluloid/io'
require "bundler/setup"
require "celluloid/io"

class EchoUNIXClient
include Celluloid::IO
Expand All @@ -22,7 +22,6 @@ def echo(msg)
def finalize
@socket.close if @socket
end

end

c = EchoUNIXClient.new("/tmp/sock_test")
Expand Down
5 changes: 2 additions & 3 deletions examples/echo_unix_server.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'bundler/setup'
require 'celluloid/io'
require "bundler/setup"
require "celluloid/io"

class EchoUNIXServer
include Celluloid::IO
Expand Down Expand Up @@ -38,7 +38,6 @@ def finalize
File.delete(@socket_path)
end
end

end

supervisor = EchoUNIXServer.supervise("/tmp/sock_test")
Expand Down
31 changes: 16 additions & 15 deletions lib/celluloid/io.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
require 'celluloid/io/version'
require "celluloid/io/version"

require 'celluloid'
require 'celluloid/io/dns_resolver'
require 'celluloid/io/mailbox'
require 'celluloid/io/reactor'
require 'celluloid/io/stream'
require "celluloid"
require "celluloid/io/dns_resolver"
require "celluloid/io/mailbox"
require "celluloid/io/reactor"
require "celluloid/io/socket"
require "celluloid/io/stream"

require 'celluloid/io/tcp_server'
require 'celluloid/io/tcp_socket'
require 'celluloid/io/udp_socket'
require 'celluloid/io/unix_server'
require 'celluloid/io/unix_socket'
require "celluloid/io/tcp_server"
require "celluloid/io/tcp_socket"
require "celluloid/io/udp_socket"
require "celluloid/io/unix_server"
require "celluloid/io/unix_socket"

require 'celluloid/io/ssl_server'
require 'celluloid/io/ssl_socket'
require "celluloid/io/ssl_server"
require "celluloid/io/ssl_socket"

module Celluloid
# Actors with evented IO support
Expand All @@ -30,13 +31,13 @@ def self.evented?
actor = Thread.current[:celluloid_actor]
actor && actor.mailbox.is_a?(Celluloid::IO::Mailbox)
end

def self.try_convert(src)
::IO.try_convert(src)
end

def self.copy_stream(src, dst, copy_length = nil, src_offset = nil)
raise NotImplementedError, "length/offset not supported" if copy_length || src_offset
fail NotImplementedError, "length/offset not supported" if copy_length || src_offset

src, dst = try_convert(src), try_convert(dst)

Expand Down
Loading

0 comments on commit 8098ebc

Please sign in to comment.