Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use multithreading #24

Open
timbru31 opened this issue May 30, 2017 · 1 comment
Open

Use multithreading #24

timbru31 opened this issue May 30, 2017 · 1 comment

Comments

@timbru31
Copy link
Owner

Examine how to check multiple mp3 files at the same time.

@timbru31 timbru31 changed the title Using multithreading Use multithreading May 30, 2017
@timbru31
Copy link
Owner Author

Example could be something like this:

POOL_SIZE = 10

jobs = Queue.new

10_0000.times{|i| jobs.push i}

workers = (POOL_SIZE).times.map do
  Thread.new do
    begin      
      while x = jobs.pop(true)
        Mailer.deliver do 
          from    "eki_#{x}@eqbalq.com"
          to      "jill_#{x}@example.com"
          subject "Threading and Forking (#{x})"
          body    "Some content"
        end        
      end
    rescue ThreadError
    end
  end
end

workers.map(&:join)

(https://www.toptal.com/ruby/ruby-concurrency-and-parallelism-a-practical-primer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant