Skip to content

Commit

Permalink
fix(spec): multithreading array access fail (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr authored Mar 25, 2024
1 parent d8fa90f commit 269ed63
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion spec/hash_generator_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ describe Collision::Checksum do
channel = Channel(Hash(String, String)).new

Collision::CLIPBOARD_HASH.keys.each do |x|
hashes[x] = ""
Collision.spawn do
hashes[x] = Collision::Checksum.new.calculate(x, path.to_s)
end
end

safe_stop = Time.utc.to_unix_ms
loop do
break if Collision::CLIPBOARD_HASH.size == hashes.size || Time.utc.to_unix_ms - safe_stop > Collision::CLIPBOARD_HASH.size * 5000
break if Collision::CLIPBOARD_HASH.keys.size == hashes.reject { |k, v| v == "" }.keys.size || Time.utc.to_unix_ms - safe_stop > Collision::CLIPBOARD_HASH.size * 5000
end

Collision::CLIPBOARD_HASH.each do |k, v|
Expand Down

0 comments on commit 269ed63

Please sign in to comment.