Skip to content

Commit

Permalink
#inspect should not output negative object IDs.
Browse files Browse the repository at this point in the history
It might happen that object ID is 'negative', since Ruby tries to avoid Bignums:

https://bugs.ruby-lang.org/issues/13397
  • Loading branch information
voxik committed Apr 27, 2017
1 parent aa2b811 commit 82b1214
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/concurrent/edge/processing_actor.rb
Expand Up @@ -146,7 +146,7 @@ def ask(message, answer = Promises.resolvable_future)

# @return [String] string representation.
def inspect
format '<#%s:0x%x termination:%s>', self.class, object_id << 1, termination.state
format '%s termination:%s>', super[0..-2], termination.state
end

private
Expand Down
6 changes: 1 addition & 5 deletions lib/concurrent/map.rb
Expand Up @@ -210,12 +210,8 @@ def marshal_load(hash)
undef :freeze

# @!visibility private
DEFAULT_OBJ_ID_STR_WIDTH = 0.size == 4 ? 7 : 14 # we want to look "native", 7 for 32-bit, 14 for 64-bit
# override default #inspect() method: firstly, we don't want to be spilling our guts (i-vars), secondly, MRI backend's
# #inspect() call on its @backend i-var will bump @backend's iter level while possibly yielding GVL
def inspect
id_str = (object_id << 1).to_s(16).rjust(DEFAULT_OBJ_ID_STR_WIDTH, '0')
"#<#{self.class.name}:0x#{id_str} entries=#{size} default_proc=#{@default_proc.inspect}>"
format '%s entries=%d default_proc=%s>', to_s[0..-2], size.to_s, @default_proc.inspect
end

private
Expand Down

0 comments on commit 82b1214

Please sign in to comment.