Skip to content

Commit

Permalink
[Truffle] Fix location of Rubinius and rubinius-core-api thread.rb code.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Mar 17, 2015
1 parent 3ea1da0 commit 8e37042
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
1 change: 1 addition & 0 deletions truffle/src/main/ruby/core.rb
Expand Up @@ -70,6 +70,7 @@
require_relative 'core/rubinius/common/signal'
require_relative 'core/rubinius/common/splitter'
require_relative 'core/rubinius/common/mutex'
require_relative 'core/rubinius/common/thread'
require_relative 'core/rubinius/common/throw_catch'
require_relative 'core/rubinius/common/time'
require_relative 'core/rubinius/common/true'
Expand Down
Expand Up @@ -41,10 +41,6 @@ class Thread
# recurse back to :foo, it could require making
# the tables independant.

def randomizer
@randomizer ||= Rubinius::Randomizer.new
end

def self.recursion_guard(obj)
id = obj.object_id
objects = current.recursive_objects
Expand Down
41 changes: 41 additions & 0 deletions truffle/src/main/ruby/core/rubinius/common/thread.rb
@@ -0,0 +1,41 @@
# Copyright (c) 2007-2014, Evan Phoenix and contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Rubinius nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Only part of Rubinius' thread.rb

#--
# Be very careful about calling raise in here! Thread has its own
# raise which, if you're calling raise, you probably don't want. Use
# Kernel.raise to call the proper raise.
#++

class Thread

def randomizer
@randomizer ||= Rubinius::Randomizer.new
end

end

4 comments on commit 8e37042

@chrisseaton
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lucasallan this is how it should be - randomizer is only present in Rubinius, and not rubinius-core-api.

@lucasallan
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Did you have the chance to review the whole thread.rb? I think we might have to move some code to here.

@chrisseaton
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only want to pull stuff in as we need it - rather than pull in the whole file - for classes were some of it is implement in Java. Otherwise you risk overwriting Java methods which is a pain to debug.

@lucasallan
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrisseaton I know, but you moved randomizer from api/kernel/common/thread.rb
to rubinius/common/thread.rb.

However, randomizer was extracted from https://github.com/rubinius/rubinius/blob/v2.4.1/kernel/common/thread.rb#L123 kernel/common/thread.rb.

There are more methods who were extracted from https://github.com/rubinius/rubinius/blob/v2.4.1/kernel/common/thread.rb but they are still on api/kernel/common/thread.rb.

So if we move randomizer than we should move all the others methods as well (like recursion_guard).

Please sign in to comment.