Created
June 30, 2020 12:54
-
-
Save ioquatix/f918ee907a0107255c08a2aa93af5491 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'thread/local' | |
class Searchable | |
extend Thread::Local | |
def initialize | |
@index = "rubygems" | |
end | |
def index(value) | |
@index = value | |
end | |
def lookup(query) | |
puts "execute #{query} on #{@index}" | |
end | |
end | |
def run_tests | |
Searchable.instance.lookup("hello world") | |
end | |
8.times.map do |index| | |
Thread.new do | |
# Before running tests: | |
searchable = Searchable.instance | |
# searchable.index "rubygems-#{index}" | |
run_tests | |
end | |
end.each(&:join) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment