tubes 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/tubes.rb +6 -6
  2. metadata +3 -2
data/lib/tubes.rb CHANGED
@@ -4,12 +4,12 @@ class Tube
4
4
  attr :dir
5
5
  attr :ended_at
6
6
  attr :exception
7
- attr :lock
8
7
  attr :name
9
8
  attr :order
10
9
  attr :output
11
10
  attr :started_at
12
11
  attr :stats
12
+ attr :thread_lock
13
13
  attr :threads
14
14
 
15
15
  def initialize(dir=nil, options={})
@@ -19,7 +19,7 @@ class Tube
19
19
  @serial_count = 0
20
20
  @parallel_count = 0
21
21
 
22
- @lock = @parent ? @parent.lock : Mutex.new
22
+ @thread_lock = @parent ? @parent.thread_lock : Mutex.new
23
23
  @stats = @parent ? @parent.stats : {}
24
24
 
25
25
  @name = underscore self.class.name.split('::')[-1]
@@ -78,7 +78,7 @@ class Tube
78
78
  if @type == :serial
79
79
  dispatch(segment, output_file, *args)
80
80
  elsif @type == :parallel
81
- thread = Thread.new(@lock) do |lock|
81
+ thread = Thread.new(@thread_lock) do |lock|
82
82
  Thread.current[:lock] = lock
83
83
  Thread.current.abort_on_exception = true
84
84
 
@@ -94,7 +94,7 @@ class Tube
94
94
 
95
95
 
96
96
  def puts(string="")
97
- @lock.synchronize do
97
+ @thread_lock.synchronize do
98
98
  if self.class == Tube
99
99
  Kernel.puts "\033[32m[#{@order}]\033[0m #{string}"
100
100
  else
@@ -112,7 +112,7 @@ class Tube
112
112
  begin
113
113
  case @type
114
114
  when :parallel # When inside parallel.
115
- thread = Thread.new(@lock) do |lock|
115
+ thread = Thread.new(@thread_lock) do |lock|
116
116
  Thread.current[:lock] = lock
117
117
  Thread.current.abort_on_exception = true
118
118
  child(mode, args).instance_eval &block
@@ -154,7 +154,7 @@ class Tube
154
154
  if @type == :serial
155
155
  @output = output
156
156
  elsif @type == :parallel
157
- @lock.synchronize do
157
+ @thread_lock.synchronize do
158
158
  @output << output
159
159
  end
160
160
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tubes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,8 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2012-09-23 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: A simple way to build a pipeline of tasks.
14
+ description: A simple way to build a pipeline of tasks. These tasks can be configured
15
+ to run in serial, parallel or any combination thereof.
15
16
  email: sujoyg@gmail.com
16
17
  executables: []
17
18
  extensions: []