This file contains hidden or 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' # for Mutex: Ruby doesn't provide out of the box thread-safe arrays | |
| # NOTE: Modifications from original: | |
| # => 1. The instance variable @running_threads has been removed, because | |
| # => the size of this array never decreases. | |
| # => 2. Did not need the #await_completion instance method | |
| # => 3. Added a class method #wait_for_threads that accepts an array of threads | |
| # and joins them | |
| class ThreadPool |