fastthread 1.0.1-i386-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +3 -0
- data/CHANGELOG +3 -0
- data/Manifest +9 -0
- data/ext/fastthread/extconf.rb +3 -0
- data/ext/fastthread/fastthread.c +1186 -0
- data/fastthread.gemspec +67 -0
- data/lib/fastthread.so +0 -0
- data/setup.rb +1585 -0
- data/test/test_all.rb +6 -0
- data/test/test_condvar.rb +34 -0
- data/test/test_mutex.rb +74 -0
- data/test/test_queue.rb +79 -0
- metadata +101 -0
- metadata.gz.sig +0 -0
data/test/test_all.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'thread'
|
3
|
+
if RUBY_PLATFORM != "java"
|
4
|
+
$:.unshift File.expand_path( File.join( File.dirname( __FILE__ ), "../ext/fastthread" ) )
|
5
|
+
require 'fastthread'
|
6
|
+
end
|
7
|
+
|
8
|
+
class TestCondVar < Test::Unit::TestCase
|
9
|
+
def test_signal
|
10
|
+
s = ""
|
11
|
+
m = Mutex.new
|
12
|
+
cv = ConditionVariable.new
|
13
|
+
ready = false
|
14
|
+
|
15
|
+
t = Thread.new do
|
16
|
+
nil until ( Thread.pass ; m.synchronize { ready } )
|
17
|
+
m.synchronize { s << "b" }
|
18
|
+
cv.signal
|
19
|
+
end
|
20
|
+
|
21
|
+
m.synchronize do
|
22
|
+
s << "a"
|
23
|
+
ready = true
|
24
|
+
cv.wait m
|
25
|
+
assert m.locked?
|
26
|
+
s << "c"
|
27
|
+
end
|
28
|
+
|
29
|
+
t.join
|
30
|
+
|
31
|
+
assert_equal "abc", s
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
data/test/test_mutex.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'thread'
|
3
|
+
if RUBY_PLATFORM != "java"
|
4
|
+
$:.unshift File.expand_path( File.join( File.dirname( __FILE__ ), "../ext/fastthread" ) )
|
5
|
+
require 'fastthread'
|
6
|
+
end
|
7
|
+
|
8
|
+
class TestMutex < Test::Unit::TestCase
|
9
|
+
def self.mutex_test( name, &body )
|
10
|
+
define_method( "test_#{ name }" ) do
|
11
|
+
body.call( self, Mutex.new, "" )
|
12
|
+
end
|
13
|
+
# at one time we also tested Mutex_m here, but it's no longer
|
14
|
+
# part of fastthread
|
15
|
+
end
|
16
|
+
|
17
|
+
mutex_test( :locked_p ) do |test, m, prefix|
|
18
|
+
test.instance_eval do
|
19
|
+
assert_equal false, m.send( "#{ prefix }locked?" )
|
20
|
+
m.send "#{ prefix }lock"
|
21
|
+
assert_equal true, m.send( "#{ prefix }locked?" )
|
22
|
+
m.send "#{ prefix }unlock"
|
23
|
+
assert_equal false, m.send( "#{ prefix }locked?" )
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
mutex_test( :synchronize ) do |test, m, prefix|
|
28
|
+
test.instance_eval do
|
29
|
+
assert !m.send( "#{ prefix }locked?" )
|
30
|
+
m.send "#{ prefix }synchronize" do
|
31
|
+
assert m.send( "#{ prefix }locked?" )
|
32
|
+
end
|
33
|
+
assert !m.send( "#{ prefix }locked?" )
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
mutex_test( :synchronize_exception ) do |test, m, prefix|
|
38
|
+
test.instance_eval do
|
39
|
+
assert !m.send( "#{ prefix }locked?" )
|
40
|
+
assert_raise ArgumentError do
|
41
|
+
m.send "#{ prefix }synchronize" do
|
42
|
+
assert m.send( "#{ prefix }locked?" )
|
43
|
+
raise ArgumentError
|
44
|
+
end
|
45
|
+
end
|
46
|
+
assert !m.send( "#{ prefix }locked?" )
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
mutex_test( :mutual_exclusion ) do |test, m, prefix|
|
51
|
+
test.instance_eval do
|
52
|
+
s = ""
|
53
|
+
|
54
|
+
("a".."c").map do |c|
|
55
|
+
Thread.new do
|
56
|
+
Thread.pass
|
57
|
+
5.times do
|
58
|
+
m.send "#{ prefix }synchronize" do
|
59
|
+
s << c
|
60
|
+
Thread.pass
|
61
|
+
s << c
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end.each do |thread|
|
66
|
+
thread.join
|
67
|
+
end
|
68
|
+
|
69
|
+
assert_equal 30, s.length
|
70
|
+
assert s.match( /^(aa|bb|cc)+$/ )
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
data/test/test_queue.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'thread'
|
3
|
+
if RUBY_PLATFORM != "java"
|
4
|
+
$:.unshift File.expand_path( File.join( File.dirname( __FILE__ ), "../ext/fastthread" ) )
|
5
|
+
require 'fastthread'
|
6
|
+
end
|
7
|
+
|
8
|
+
class TestQueue < Test::Unit::TestCase
|
9
|
+
def check_sequence( q )
|
10
|
+
range = "a".."f"
|
11
|
+
|
12
|
+
s = ""
|
13
|
+
e = nil
|
14
|
+
|
15
|
+
t = Thread.new do
|
16
|
+
begin
|
17
|
+
for c in range
|
18
|
+
q.push c
|
19
|
+
s << c
|
20
|
+
Thread.pass
|
21
|
+
end
|
22
|
+
rescue Exception => e
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
for c in range
|
27
|
+
unless t.alive?
|
28
|
+
raise e if e
|
29
|
+
assert_equal range.to_a.join, s, "expected all values pushed"
|
30
|
+
end
|
31
|
+
x = q.shift
|
32
|
+
assert_equal c, x, "sequence error: expected #{ c } but got #{ x }"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_queue
|
37
|
+
check_sequence( Queue.new )
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_sized_queue_full
|
41
|
+
check_sequence( SizedQueue.new( 6 ) )
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_sized_queue_half
|
45
|
+
check_sequence( SizedQueue.new( 3 ) )
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_sized_queue_one
|
49
|
+
check_sequence( SizedQueue.new( 1 ) )
|
50
|
+
end
|
51
|
+
|
52
|
+
def check_serialization( k, *args )
|
53
|
+
q1 = k.new *args
|
54
|
+
%w(a b c d e f).each { |c| q1.push c }
|
55
|
+
q2 = Marshal.load(Marshal.dump(q1))
|
56
|
+
assert( ( q1.size == q2.size ), "queues are same size" )
|
57
|
+
q1.size.times do
|
58
|
+
assert( ( q1.pop == q2.pop ), "same data" )
|
59
|
+
end
|
60
|
+
[ q1, q2 ]
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_queue_serialization
|
64
|
+
check_serialization Queue
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_sized_queue_serialization
|
68
|
+
(q1, q2) = check_serialization SizedQueue, 20
|
69
|
+
assert( ( q1.max == q2.max ), "maximum sizes equal" )
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_sized_queue_size
|
73
|
+
q = SizedQueue.new 3
|
74
|
+
assert_equal 3, q.max, "queue has expected max (3)"
|
75
|
+
q.max = 5
|
76
|
+
assert_equal 5, q.max, "queue has expected max (5)"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
4
|
+
name: fastthread
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 1.0.1
|
7
|
+
date: 2007-12-20 00:00:00 -03:00
|
8
|
+
summary: Optimized replacement for thread.rb primitives
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
- ext
|
12
|
+
email: ""
|
13
|
+
homepage: ""
|
14
|
+
rubyforge_project: mongrel
|
15
|
+
description: Optimized replacement for thread.rb primitives
|
16
|
+
autorequire:
|
17
|
+
default_executable:
|
18
|
+
bindir: bin
|
19
|
+
has_rdoc: true
|
20
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">"
|
23
|
+
- !ruby/object:Gem::Version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BzYHc0Ii2uLu3Pv4
|
62
|
+
jOmwvJlYZ30ccBh0G86ngtlOpZNrdcnXgRKXADGnxPickYZMdIHPPykIeR6Im0sR
|
63
|
+
hCq6hsHkuWQU6CuwqTtGErw6uwIDAQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQE
|
64
|
+
AwIEsDAdBgNVHQ4EFgQUkz5QYICmPVaUs8rhPOQmhrDosCUwDQYJKoZIhvcNAQEF
|
65
|
+
BQADggEBAMVgi+dtUNn1WNgsrkDi8wPkBbTj4qvTdu/mLncUD/wSNEfaf0ADiycu
|
66
|
+
W9x8imY3UmSyyc2HO+/Wnf6/PkbaoAcUZxl/7a60UDqSyTpdpfB3moA7z9+j+Kyp
|
67
|
+
nVFr7JVQG3SSNC/y0XrYf6J0DCgpLwOqLSes/KaQOtJlXl/xV37AHXEnAPjwJyCD
|
68
|
+
qafzGwoObqIf7Vj8IzU/eoCx/SxAYnaevry1bls58eb28FKGuq7bWyJuDrFu1H8m
|
69
|
+
mPG0Kv6rJ8vKyQiYZMAKm+XpuDZ09rnGm3ytdeEpXDfF5osSDDBSlWox82z2ulMd
|
70
|
+
knPjAuGZt50yNl1teBnVEZkty2RINfo=
|
71
|
+
-----END CERTIFICATE-----
|
72
|
+
|
73
|
+
post_install_message:
|
74
|
+
authors:
|
75
|
+
- MenTaLguY <mental@rydia.net>
|
76
|
+
files:
|
77
|
+
- test/test_queue.rb
|
78
|
+
- test/test_mutex.rb
|
79
|
+
- test/test_condvar.rb
|
80
|
+
- test/test_all.rb
|
81
|
+
- setup.rb
|
82
|
+
- Manifest
|
83
|
+
- ext/fastthread/fastthread.c
|
84
|
+
- ext/fastthread/extconf.rb
|
85
|
+
- CHANGELOG
|
86
|
+
- fastthread.gemspec
|
87
|
+
- lib/fastthread.so
|
88
|
+
test_files:
|
89
|
+
- test/test_all.rb
|
90
|
+
rdoc_options: []
|
91
|
+
|
92
|
+
extra_rdoc_files: []
|
93
|
+
|
94
|
+
executables: []
|
95
|
+
|
96
|
+
extensions: []
|
97
|
+
|
98
|
+
requirements: []
|
99
|
+
|
100
|
+
dependencies: []
|
101
|
+
|
metadata.gz.sig
ADDED
Binary file
|