cycr 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ 0.2.6
2
+ - fix deadlock in cache
1
3
  0.2.5
2
4
  - Escape backslash and quote in string literals
3
5
  0.2.3
@@ -117,7 +117,7 @@ if defined? Cyc::Connection::SynchronyDriver
117
117
  it "should have consistent results running long query in separate fibers" do
118
118
  @fiber = Fiber.current
119
119
  done = 0
120
- size = ('A'..'Z').to_a.each do |char|
120
+ size = ('A'..'C').to_a.each do |char|
121
121
  Fiber.new do
122
122
  result_size = @client.fi_complete(char).each do |value|
123
123
  value.to_s[0].upcase.should == char
@@ -154,7 +154,7 @@ describe "client thread concurrency" do
154
154
  it "should have consistent results running long query in separate threads" do
155
155
  results = {}
156
156
  mutex = Mutex.new
157
- ('A'..'Z').map do |char|
157
+ ('A'..'C').map do |char|
158
158
  Thread.new do
159
159
  Thread.pass
160
160
  result = @client.fi_complete char
@@ -24,15 +24,28 @@ module Cyc
24
24
  end
25
25
  @in_progress[key] = monitor = ConditionVariable.new
26
26
  end
27
- value = yield
28
- @lock.synchronize do
29
- self[key] = value
30
- @in_progress.delete key
31
- monitor.broadcast
27
+ begin
28
+ value = yield
29
+ value_set = true
30
+ ensure
31
+ @lock.synchronize do
32
+ self[key] = value if value_set
33
+ @in_progress.delete key
34
+ monitor.broadcast
35
+ end
32
36
  end
33
37
  value
34
38
  end
35
39
 
40
+ # Clear the cache.
41
+ def clear
42
+ @lock.synchronize do
43
+ @soft_references.clear
44
+ @hard_references.clear
45
+ end
46
+ end
47
+
48
+ private
36
49
  # Get a value from cache.
37
50
  def [](key)
38
51
  if @hard_references.has_key?(key)
@@ -53,13 +66,5 @@ module Cyc
53
66
  @soft_references[key] = value
54
67
  end
55
68
  end
56
-
57
- # Clear the cache.
58
- def clear
59
- @lock.synchronize do
60
- @soft_references.clear
61
- @hard_references.clear
62
- end
63
- end
64
69
  end
65
70
  end
@@ -1,3 +1,3 @@
1
1
  module Cyc
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cycr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-01-23 00:00:00.000000000 Z
13
+ date: 2014-04-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -126,3 +126,4 @@ test_files:
126
126
  - spec/conversion.rb
127
127
  - integration/assertion.rb
128
128
  - integration/client.rb
129
+ has_rdoc: true