Skip to content

Instantly share code, notes, and snippets.

@bleonard
Created January 14, 2013 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bleonard/4527771 to your computer and use it in GitHub Desktop.
Save bleonard/4527771 to your computer and use it in GitHub Desktop.
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