Created
January 14, 2013 04:29
-
-
Save bleonard/4527771 to your computer and use it in GitHub Desktop.
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
def commits(&block) | |
queue = self.sha_list | |
self.thread_count.times.map { | |
Thread.new do | |
while sha = mutex.synchronize { queue.shift } | |
hash = fetch_sha(sha) | |
commit = Commit.new(hash, repo_name, username) | |
mutex.synchronize { block.call commit } | |
end | |
end | |
}.each(&:join) | |
end | |
def sha_list | |
queue = self.generate_sha_windows | |
result = [] | |
self.thread_count.times.map { | |
Thread.new do | |
while window = mutex.synchronize { queue.shift } | |
since_time, until_time = window | |
list = commits_window(since_time, until_time) | |
mutex.synchronize { result.concat list } | |
end | |
end | |
}.each(&:join) | |
end | |
result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment