This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit c556f68e45e774abbe8f88a6faf84c53439a4443
tree 08d21b3665fbbe1c7d27d8b7cf21eb9de5a75bcf
parent 464bd4c3c7f7d0e88c74413c818ed0245ac1773a
tree 08d21b3665fbbe1c7d27d8b7cf21eb9de5a75bcf
parent 464bd4c3c7f7d0e88c74413c818ed0245ac1773a
| name | age | message | |
|---|---|---|---|
| |
.gitignore | ||
| |
CHANGELOG | ||
| |
LICENSE | ||
| |
README | ||
| |
Rakefile | ||
| |
lib/ | ||
| |
test/ | ||
| |
thread_pool.gemspec |
README
This code is still pretty early, and not yet used in production. That said, I am interested in feedback. You can send me a message on GitHub's internal messaging system (http://github.com/inbox/new/fizx). A simple executor-style ThreadPool for Ruby (with tests, yay!) Usage: require "rubygems" require "thread_pool" pool = ThreadPool.new(threads = 10) pool.execute { puts "I'm writing from a thread" } pool.join It's often useful to make sure that the properties of Ruby's blocks don't bite you. The following code will usually print three nils, because n keeps changing. pool = ThreadPool.new(threads = 10) numbers = [1, 2, 3] while n = numbers.shift pool.execute { puts n.inspect } end pool.join Passing arguments to execute avoids this. i.e.: pool = ThreadPool.new(threads = 10) numbers = [1, 2, 3] while n = numbers.shift pool.execute(n) {|local| puts local.inspect } end pool.join








