Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/concurrent-ruby/concurrent/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module Concurrent
# Various classes within allows for +nil+ values to be stored,
# so a special +NULL+ token is required to indicate the "nil-ness".
# @!visibility private
NULL = ::Object.new
NULL = ::Object.new.freeze

end
22 changes: 22 additions & 0 deletions spec/concurrent/map_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,28 @@ module Concurrent
expect(map.keys).to eq [3]
end

if defined?(Ractor)
it 'works in a Ractor' do
ractor = Ractor.new do
inner_map = Concurrent::Map.new do |map, key|
map.compute_if_absent(key) { key * 2 }
end

inner_map[3]
inner_map
end

map = if ractor.respond_to?(:take)
ractor.take
else
ractor.value # Ruby 4.0
end

expect(map[3]).to eq 6
expect(map.keys).to eq [3]
end
end

it 'common' do
with_or_without_default_proc do
expect_size_change(3) do
Expand Down