Created
January 2, 2009 11:49
-
-
Save nrk/42514 to your computer and use it in GitHub Desktop.
Problems with Mutex and ConditionVariable under IronRuby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WEAK_TABLE: IronRuby.Runtime.WeakTable`2[[System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[IronRuby.Runtime.RubyInstanceData, IronRuby, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] | |
UPDATED: Object SetMixins affected=7 total=1 | |
UPDATED: Object CreateInstanceSingleton affected=38 total=2 | |
UPDATED: Object CreateInstanceSingleton affected=40 total=3 | |
INITED: File | |
INITED: File::Constants | |
INITED: IO | |
INITED: Kernel | |
INITED: Object | |
INITED: Process | |
INITED: Errno | |
UPDATED: Object CreateInstanceSingleton affected=188 total=4 | |
INITED: <anonymous> | |
LOAD_COMPILED: 1: C:/Sviluppo/ironruby/SVN/trunk/lib/IronRuby\thread.rb | |
LOADER: Loading assembly 'IronRuby.Libraries' and type 'IronRuby.StandardLibrary.Threading.ThreadingLibraryInitializer' | |
INITED: <anonymous> | |
INITED: Class | |
INITED: Module | |
UPDATED: Class UndefineMethodNoEvent affected=84 total=5 | |
INITED: <anonymous> | |
INITED: <anonymous> | |
UPDATED: Class UndefineMethodNoEvent affected=84 total=6 | |
UPDATED: Class UndefineMethodNoEvent affected=84 total=7 | |
INITED: <anonymous> | |
INITED: <anonymous> | |
INITED: Mutex | |
INITED: <anonymous> | |
INITED: ConditionVariable | |
INITED: <anonymous> | |
INITED: Thread | |
A first chance exception of type 'System.Threading.SynchronizationLockException' occurred in mscorlib.dll | |
THREAD: Object synchronization method was called from an unsynchronized block of code. | |
in System.Threading.Monitor.ObjPulse(Object obj) | |
in System.Threading.Monitor.Pulse(Object obj) | |
in IronRuby.StandardLibrary.Threading.RubyConditionVariable.Signal(RubyConditionVariable self) in C:\Sviluppo\ironruby\SVN\trunk\src\IronRuby.Libraries\Thread\RubyConditionVariable.cs:riga 32 | |
in _stub_$26(Closure , CallSite , RubyBlockScope , Object ) | |
in System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) in C:\Sviluppo\ironruby\SVN\trunk\src\Microsoft.Scripting.Core\Actions\UpdateDelegates.Generated.cs:riga 343 | |
in ;T002.rb;16$5(Closure , BlockParam , Object ) | |
in IronRuby.Runtime.Calls.BlockDispatcher0.Invoke(BlockParam param, Object self) in C:\Sviluppo\ironruby\SVN\trunk\src\ironruby\Runtime\Calls\BlockDispatchers.cs:riga 40 | |
in IronRuby.Runtime.RubyOps.Yield0(Object self, BlockParam blockParam) in C:\Sviluppo\ironruby\SVN\trunk\src\ironruby\Runtime\RubyOps.cs:riga 294 | |
in IronRuby.Runtime.BlockParam.Yield(Object& blockResult) in C:\Sviluppo\ironruby\SVN\trunk\src\ironruby\Runtime\BlockParam.cs:riga 135 | |
in IronRuby.StandardLibrary.Threading.RubyMutex.Synchronize(BlockParam criticalSection, RubyMutex self) in C:\Sviluppo\ironruby\SVN\trunk\src\IronRuby.Libraries\Thread\RubyMutex.cs:riga 70 | |
in _stub_$22(Closure , CallSite , RubyBlockScope , Object , Proc ) | |
in System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) in C:\Sviluppo\ironruby\SVN\trunk\src\Microsoft.Scripting.Core\Actions\UpdateDelegates.Generated.cs:riga 461 | |
in ;T002.rb;15$4(Closure , BlockParam , Object ) | |
in IronRuby.Runtime.Calls.BlockDispatcher0.Invoke(BlockParam param, Object self) in C:\Sviluppo\ironruby\SVN\trunk\src\ironruby\Runtime\Calls\BlockDispatchers.cs:riga 40 | |
in IronRuby.Runtime.RubyOps.Yield0(Object self, BlockParam blockParam) in C:\Sviluppo\ironruby\SVN\trunk\src\ironruby\Runtime\RubyOps.cs:riga 294 | |
in IronRuby.Runtime.BlockParam.Yield(Object[] args, Object& blockResult) in C:\Sviluppo\ironruby\SVN\trunk\src\ironruby\Runtime\BlockParam.cs:riga 157 | |
in IronRuby.Builtins.ThreadOps.<>c__DisplayClass1.<CreateThread>b__0() in C:\Sviluppo\ironruby\SVN\trunk\src\IronRuby.Libraries\Builtins\ThreadOps.cs:riga 419 | |
mscorlib:0:in `ObjPulse'mscorlib:0:in `Pulse'C:\Sviluppo\ironruby\SVN\trunk\src\IronRuby.Libraries\Thread\RubyConditionVariable.cs:32:in `signal'T002.rb:16C:\Sviluppo\ironruby\SVN\trunk\src\IronRuby.Libraries\Thread\RubyMutex.cs:70:in `synchronize'T002.rb:15mscorlib:0:in `Run'mscorlib:0:in `ThreadStart' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# code taken from http://www.rubycentral.com/pickaxe/tut_threads.html#UF | |
require 'thread' | |
mutex = Mutex.new | |
cv = ConditionVariable.new | |
a = Thread.new { | |
mutex.synchronize { | |
puts "A: I have critical section, but will wait for cv" | |
cv.wait(mutex) | |
puts "A: I have critical section again! I rule!" | |
} | |
} | |
puts "(Later, back at the ranch...)" | |
b = Thread.new { | |
mutex.synchronize { | |
puts "B: Now I am critical, but am done with cv" | |
cv.signal | |
puts "B: I am still critical, finishing up" | |
} | |
} | |
a.join | |
b.join |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment