⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Backport187
All Projects
Ruby
»
Backport187
Overview
Activity
Issues
Like
Download (562 Bytes)
Backport #725
ยป test.rb
The code producing the error -
cenobyte (Sebastian Morawietz)
, 11/08/2008 10:40 PM
#!/usr/bin/env ruby
require
'thread'
class
MyTest
@@ids
=
{}
@@ids
.
instance_variable_set
(
"@mutex"
,
Mutex
.
new
)
def
@@ids
.
synchronize
@mutex
.
synchronize
do
yield
end
end
def
self
.
finalize
(
object_id
)
@@ids
.
synchronize
do
@@ids
.
delete
(
object_id
)
end
end
def
initialize
ObjectSpace
.
define_finalizer
(
self
,
self
.
class
.
method
(
:finalize
))
@@ids
.
synchronize
do
@@ids
[
object_id
]
=
"blah"
end
end
end
def
doit
100000
.
times
do
MyTest
.
new
end
end
10
.
times
do
Thread
.
new
do
doit
end
end
(1-1/1)
Loading...