parallel_runner 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +4 -0
- data/README.rdoc +46 -0
- data/Rakefile +143 -0
- data/lib/parallel_runner.rb +26 -0
- metadata +79 -0
data/ChangeLog
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
= parallel-runner
|
2
|
+
|
3
|
+
"parallel-runner" is simple parallel processing support library.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
execute a command.
|
8
|
+
|
9
|
+
gem install parallel_runner
|
10
|
+
|
11
|
+
=== Usage
|
12
|
+
require 'parallel_runner'
|
13
|
+
Runner.parallel(list) do |elem|
|
14
|
+
# write processing
|
15
|
+
end
|
16
|
+
|
17
|
+
Please refer to sample/runner.rb
|
18
|
+
|
19
|
+
== Copyright
|
20
|
+
|
21
|
+
* Author:: mapserver2007(Ryuichi TANAKA) <mapserver2007@gmail.com>
|
22
|
+
* Copyright:: Copyright (c) 2010 mapserver2007
|
23
|
+
|
24
|
+
== License
|
25
|
+
|
26
|
+
(The MIT License)
|
27
|
+
|
28
|
+
Copyright (c) 2010 Ryuichi Tanaka
|
29
|
+
|
30
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
31
|
+
of this software and associated documentation files (the "Software"), to deal
|
32
|
+
in the Software without restriction, including without limitation the rights
|
33
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
34
|
+
copies of the Software, and to permit persons to whom the Software is
|
35
|
+
furnished to do so, subject to the following conditions:
|
36
|
+
|
37
|
+
The above copyright notice and this permission notice shall be included in
|
38
|
+
all copies or substantial portions of the Software.
|
39
|
+
|
40
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
41
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
42
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
43
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
44
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
45
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
46
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rake/packagetask'
|
6
|
+
require 'rake/gempackagetask'
|
7
|
+
require 'rake/rdoctask'
|
8
|
+
require 'rake/contrib/rubyforgepublisher'
|
9
|
+
require 'rake/contrib/sshpublisher'
|
10
|
+
require 'fileutils'
|
11
|
+
include FileUtils
|
12
|
+
|
13
|
+
NAME = "parallel_runner"
|
14
|
+
AUTHOR = "mapserver2007"
|
15
|
+
EMAIL = "mapserver2007@gmail.com"
|
16
|
+
DESCRIPTION = "simple parallel processing library."
|
17
|
+
RUBYFORGE_PROJECT = "parallel_runner"
|
18
|
+
HOMEPATH = "http://github.com/#{AUTHOR}/#{NAME}"
|
19
|
+
BIN_FILES = %w( )
|
20
|
+
VERS = '0.0.1'
|
21
|
+
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
22
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
23
|
+
RDOC_OPTS = [
|
24
|
+
'--title', "#{NAME} documentation",
|
25
|
+
"--charset", "utf-8",
|
26
|
+
"--opname", "index.html",
|
27
|
+
"--line-numbers",
|
28
|
+
"--main", "README.rdoc",
|
29
|
+
"--inline-source",
|
30
|
+
]
|
31
|
+
|
32
|
+
task :default => [:test]
|
33
|
+
task :package => [:clean]
|
34
|
+
|
35
|
+
Rake::TestTask.new("test") do |t|
|
36
|
+
t.libs << "test"
|
37
|
+
t.pattern = "test/**/*_test.rb"
|
38
|
+
t.verbose = true
|
39
|
+
end
|
40
|
+
|
41
|
+
spec = Gem::Specification.new do |s|
|
42
|
+
s.name = NAME
|
43
|
+
s.version = VERS
|
44
|
+
s.platform = Gem::Platform::RUBY
|
45
|
+
s.has_rdoc = true
|
46
|
+
s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
|
47
|
+
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
|
48
|
+
s.summary = DESCRIPTION
|
49
|
+
s.description = DESCRIPTION
|
50
|
+
s.author = AUTHOR
|
51
|
+
s.email = EMAIL
|
52
|
+
s.homepage = HOMEPATH
|
53
|
+
s.executables = BIN_FILES
|
54
|
+
s.rubyforge_project = RUBYFORGE_PROJECT
|
55
|
+
s.bindir = "bin"
|
56
|
+
s.require_path = "lib"
|
57
|
+
#s.autorequire = ""
|
58
|
+
s.test_files = Dir["spec/*.rb"]
|
59
|
+
#s.test_files = Dir["test/*_test.rb"]
|
60
|
+
|
61
|
+
#s.add_dependency('activesupport', '>=1.3.1')
|
62
|
+
#s.required_ruby_version = '>= 1.8.2'
|
63
|
+
|
64
|
+
s.files = %w(README.rdoc ChangeLog Rakefile) +
|
65
|
+
Dir.glob("{bin,doc,test,lib,templates,generator,extras,website,script}/**/*") +
|
66
|
+
Dir.glob("ext/**/*.{h,c,rb}") +
|
67
|
+
Dir.glob("examples/**/*.rb") +
|
68
|
+
Dir.glob("tools/*.rb") +
|
69
|
+
Dir.glob("rails/*.rb")
|
70
|
+
|
71
|
+
s.extensions = FileList["ext/**/extconf.rb"].to_a
|
72
|
+
end
|
73
|
+
|
74
|
+
Rake::GemPackageTask.new(spec) do |p|
|
75
|
+
p.need_tar = true
|
76
|
+
p.gem_spec = spec
|
77
|
+
end
|
78
|
+
|
79
|
+
task :install do
|
80
|
+
name = "#{NAME}-#{VERS}.gem"
|
81
|
+
sh %{rake package}
|
82
|
+
sh %{sudo gem install pkg/#{name}}
|
83
|
+
end
|
84
|
+
|
85
|
+
task :uninstall => [:clean] do
|
86
|
+
sh %{sudo gem uninstall #{NAME}}
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
Rake::RDocTask.new do |rdoc|
|
91
|
+
rdoc.rdoc_dir = 'html'
|
92
|
+
rdoc.options += RDOC_OPTS
|
93
|
+
rdoc.template = "resh"
|
94
|
+
#rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
95
|
+
if ENV['DOC_FILES']
|
96
|
+
rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
|
97
|
+
else
|
98
|
+
rdoc.rdoc_files.include('README.rdoc', 'ChangeLog')
|
99
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
100
|
+
rdoc.rdoc_files.include('ext/**/*.c')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
desc "Publish to RubyForge"
|
105
|
+
task :rubyforge => [:rdoc, :package] do
|
106
|
+
require 'rubyforge'
|
107
|
+
Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, 'stay').upload
|
108
|
+
end
|
109
|
+
|
110
|
+
desc 'Package and upload the release to rubyforge.'
|
111
|
+
task :release => [:clean, :package] do |t|
|
112
|
+
v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
|
113
|
+
abort "Versions don't match #{v} vs #{VERS}" unless v == VERS
|
114
|
+
pkg = "pkg/#{NAME}-#{VERS}"
|
115
|
+
|
116
|
+
require 'rubyforge'
|
117
|
+
rf = RubyForge.new.configure
|
118
|
+
puts "Logging in"
|
119
|
+
rf.login
|
120
|
+
|
121
|
+
c = rf.userconfig
|
122
|
+
# c["release_notes"] = description if description
|
123
|
+
# c["release_changes"] = changes if changes
|
124
|
+
c["preformatted"] = true
|
125
|
+
|
126
|
+
files = [
|
127
|
+
"#{pkg}.tgz",
|
128
|
+
"#{pkg}.gem"
|
129
|
+
].compact
|
130
|
+
|
131
|
+
puts "Releasing #{NAME} v. #{VERS}"
|
132
|
+
rf.add_release RUBYFORGE_PROJECT, NAME, VERS, *files
|
133
|
+
end
|
134
|
+
|
135
|
+
desc 'Show information about the gem.'
|
136
|
+
task :debug_gem do
|
137
|
+
puts spec.to_ruby
|
138
|
+
end
|
139
|
+
|
140
|
+
desc 'Update gem spec'
|
141
|
+
task :gemspec do
|
142
|
+
open("#{NAME}.gemspec", 'w').write spec.to_ruby
|
143
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'thread'
|
2
|
+
|
3
|
+
module Runner
|
4
|
+
def self.parallel(list, concurency = 10, qsize = nil)
|
5
|
+
q = qsize ? SizedQueue.new(qsize) : Queue.new
|
6
|
+
threads = []
|
7
|
+
producer = Thread.start(q, concurency) do |pq, pc|
|
8
|
+
list.each do |elem|
|
9
|
+
pq.enq([elem, true])
|
10
|
+
end
|
11
|
+
pc.times{pq.enq([nil, false])}
|
12
|
+
end
|
13
|
+
workers = []
|
14
|
+
concurency.times do
|
15
|
+
workers << Thread.start(q) do |wq|
|
16
|
+
elem, flg = wq.deq
|
17
|
+
while flg
|
18
|
+
yield elem
|
19
|
+
elem, flg = wq.deq
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
producer.join
|
24
|
+
workers.each{|w| w.join}
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: parallel_runner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- mapserver2007
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-12-24 00:00:00 +09:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: simple parallel processing library.
|
22
|
+
email: mapserver2007@gmail.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- README.rdoc
|
29
|
+
- ChangeLog
|
30
|
+
files:
|
31
|
+
- README.rdoc
|
32
|
+
- ChangeLog
|
33
|
+
- Rakefile
|
34
|
+
- lib/parallel_runner.rb
|
35
|
+
has_rdoc: true
|
36
|
+
homepage: http://github.com/mapserver2007/parallel_runner
|
37
|
+
licenses: []
|
38
|
+
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options:
|
41
|
+
- --title
|
42
|
+
- parallel_runner documentation
|
43
|
+
- --charset
|
44
|
+
- utf-8
|
45
|
+
- --opname
|
46
|
+
- index.html
|
47
|
+
- --line-numbers
|
48
|
+
- --main
|
49
|
+
- README.rdoc
|
50
|
+
- --inline-source
|
51
|
+
- --exclude
|
52
|
+
- ^(examples|extras)/
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project: parallel_runner
|
74
|
+
rubygems_version: 1.3.7
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: simple parallel processing library.
|
78
|
+
test_files: []
|
79
|
+
|