GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Description: Resource-oriented open source Ruby framework for Web apps.
Homepage: http://rubywaves.com/
Clone URL: git://github.com/dyoder/waves.git
thread test redux, plus cleanup tweaks
automatthew (author)
Wed Sep 24 15:48:14 -0700 2008
commit  7d1bcc59c474b00429dc1eda69623f74979c80f2
tree    6cace33db6caf0917ffbacbbd928bc3329e33e16
parent  6610ec6a4db7d7e3a24e8c063dba1fff920b57db
...
10
11
12
13
 
 
14
15
16
17
 
18
19
20
...
23
24
25
 
26
27
28
...
67
68
69
70
71
72
73
 
 
 
 
 
 
 
74
75
 
76
 
77
...
10
11
12
 
13
14
15
16
17
 
18
19
20
21
...
24
25
26
27
28
29
30
...
69
70
71
 
 
 
 
72
73
74
75
76
77
78
79
 
80
81
82
83
0
@@ -10,11 +10,12 @@ end
0
 describe "Waves::Cache::File" do
0
 
0
   before do
0
- @cache = Waves::Cache::File.new :dir => '/tmp'
0
+ FileUtils.mkdir '/tmp/waves_cache' unless File.exist?('/tmp/waves_cache')
0
+ @cache = Waves::Cache::File.new :dir => '/tmp/waves_cache'
0
   end
0
 
0
   after do
0
- @cache.clear
0
+ FileUtils.rm_rf '/tmp/waves_cache'
0
   end
0
   
0
   it "can find a value in the cache" do
0
@@ -23,6 +24,7 @@ describe "Waves::Cache::File" do
0
   end
0
 
0
   it "can delete (multiple) values from the cache" do
0
+ @cache[:a] = 1
0
     @cache[:a].should == 1
0
     @cache[:b] = 2
0
     @cache.delete :a, :b
0
@@ -67,11 +69,15 @@ describe "Waves::Cache::File" do
0
 
0
   it "can synchronize" do
0
     @cache[:a] = 0
0
- threads=[]; 5.times do |x| threads << Thread.new do
0
- Thread.stop
0
- @cache[:a] = x
0
- end; end
0
+ threads=[]
0
+ 90.times do |x|
0
+ threads << Thread.new do
0
+ Thread.stop; sleep rand / 100
0
+ @cache[:a] = @cache[:a] + 1
0
+ end
0
+ end
0
     threads.each {|thread| thread.run; thread.join }
0
- @cache[:a].should == 5
0
+ @cache[:a].should == 90
0
   end
0
+
0
 end

Comments

    No one has commented yet.