bunch 1.0.0pre2 → 1.0.0pre3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d5aba69bf87251e2474a2b0851ef99d5d85b7ef
4
- data.tar.gz: c4583b708490467740c0846b67e7413a6af5b5a9
3
+ metadata.gz: a37d91d1930ff1ac34b123a971d142fa3d55bb52
4
+ data.tar.gz: 58e981014d925670a9cfba1bea8e724166e8cb2b
5
5
  SHA512:
6
- metadata.gz: 3f1aa8c5167f12b45e444c0568b615a6e287809496054a0bc21f48c22ba243c17b5289292fe40ad2bb4e49478ae615a4199040a4dc97d0d965bb777f513ee144
7
- data.tar.gz: f806f3cb5188661a16d3f889fab249e74a8cd0bfb2711a1e886bc41dec87b367daa0f54a3143d4d3624b2defba2daf77754c1ebaaef3a52ee439d373d72ff13a
6
+ metadata.gz: e54d84f5412f4487384e0bfa433df0b60320b64b499812db97fdd56936d15013ad30d6ba775b5f970735a36f1941420befc2baf196eae0c986ce283e86ef4e93
7
+ data.tar.gz: 848abb8159a204f5b3467a2c64069d18d2fbf7427e413ce45e4ac4a6966e284c66e6e5718f210a933949b449ff9f7759299c332d40ab3f5d641bf01119e7072e
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "digest/md5"
4
4
  require "fileutils"
5
+ require "thread"
5
6
  require "yaml"
6
7
 
7
8
  module Bunch
@@ -15,18 +16,22 @@ module Bunch
15
16
  def initialize(processor_class, input_dir, *args)
16
17
  @processor_class, @args = processor_class, args
17
18
  @cache_name = "#{processor_class}-#{input_dir}"
19
+ @mutex = Mutex.new
18
20
  end
19
21
 
20
22
  def new(tree)
21
- cache = load_cache
22
- partition = Partition.new(tree, cache)
23
+ result = nil
24
+ @mutex.synchronize do
25
+ cache = load_cache
26
+ partition = Partition.new(tree, cache)
23
27
 
24
- partition.process!
28
+ partition.process!
25
29
 
26
- processor = @processor_class.new(partition.pending, *@args)
27
- result = TreeMerge.new(partition.cached, processor.result).result
30
+ processor = @processor_class.new(partition.pending, *@args)
31
+ result = TreeMerge.new(partition.cached, processor.result).result
28
32
 
29
- save_cache tree, result
33
+ save_cache tree, result
34
+ end
30
35
  Result.new(result)
31
36
  end
32
37
 
@@ -1,5 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
+ require "thread"
4
+
3
5
  module Bunch
4
6
  def self.SimpleCache(*args)
5
7
  SimpleCache.new(*args)
@@ -12,15 +14,20 @@ module Bunch
12
14
  @processor_class, @args = processor_class, args
13
15
  @cache = nil
14
16
  @hache = nil
17
+ @mutex = Mutex.new
15
18
  end
16
19
 
17
20
  def new(tree)
18
- check_cache!(tree)
19
- @cache ||= begin
20
- processor = @processor_class.new(tree, *@args)
21
- processor.result
21
+ result = nil
22
+ @mutex.synchronize do
23
+ check_cache!(tree)
24
+ @cache ||= begin
25
+ processor = @processor_class.new(tree, *@args)
26
+ processor.result
27
+ end
28
+ result = @cache.dup
22
29
  end
23
- Result.new(@cache.dup)
30
+ Result.new(result)
24
31
  end
25
32
 
26
33
  private
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Bunch
4
- VERSION = "1.0.0pre2"
4
+ VERSION = "1.0.0pre3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0pre2
4
+ version: 1.0.0pre3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Fitzgerald
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-15 00:00:00.000000000 Z
11
+ date: 2013-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types