Skip to content

Commit

Permalink
Move timeout into a native library; passes all specs, tests I could f…
Browse files Browse the repository at this point in the history
…ind.
  • Loading branch information
headius committed Apr 25, 2009
1 parent 8a6baf6 commit ca77164
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 230 deletions.
122 changes: 0 additions & 122 deletions lib/ruby/1.8/timeout.rb

This file was deleted.

108 changes: 0 additions & 108 deletions lib/ruby/1.9/timeout.rb

This file was deleted.

1 change: 1 addition & 0 deletions spec/jruby.1.8.mspec
Expand Up @@ -57,6 +57,7 @@ class MSpecScript
DIR + '/ruby/library/stringscanner',
DIR + '/ruby/library/tempfile',
DIR + '/ruby/library/time',
DIR + '/ruby/library/timeout',
DIR + '/ruby/library/tmpdir',
DIR + '/ruby/library/uri',
DIR + '/ruby/library/yaml',
Expand Down
1 change: 1 addition & 0 deletions src/org/jruby/Ruby.java
Expand Up @@ -1289,6 +1289,7 @@ private void initBuiltins() {
addLazyBuiltin("io/wait.so", "io/wait", "org.jruby.libraries.IOWaitLibrary");
addLazyBuiltin("etc.so", "etc", "org.jruby.libraries.EtcLibrary");
addLazyBuiltin("weakref.rb", "weakref", "org.jruby.ext.WeakRef$WeakRefLibrary");
addLazyBuiltin("timeout.rb", "timeout", "org.jruby.ext.Timeout");
addLazyBuiltin("socket.so", "socket", "org.jruby.ext.socket.RubySocket$Service");
addLazyBuiltin("rbconfig.rb", "rbconfig", "org.jruby.libraries.RbConfigLibrary");
addLazyBuiltin("jruby/serialization.rb", "serialization", "org.jruby.libraries.JRubySerializationLibrary");
Expand Down
15 changes: 15 additions & 0 deletions src/org/jruby/RubyThread.java
Expand Up @@ -636,6 +636,21 @@ public IRubyObject raise(IRubyObject[] args, Block block) {
return this;
}

/**
* This is intended to be used to raise exceptions in Ruby threads from non-
* Ruby threads like Timeout's thread.
*
* @param args Same args as for Thread#raise
* @param block Same as for Thread#raise
*/
public void internalRaise(IRubyObject[] args) {
Ruby runtime = getRuntime();

IRubyObject exception = prepareRaiseException(runtime, args, Block.NULL_BLOCK);

receiveMail(new ThreadService.Event(this, this, ThreadService.Event.Type.RAISE, exception));
}

private IRubyObject prepareRaiseException(Ruby runtime, IRubyObject[] args, Block block) {
if(args.length == 0) {
IRubyObject lastException = errorInfo;
Expand Down

0 comments on commit ca77164

Please sign in to comment.