* lib/sync.rb (Sync_m#sync_synchronize): add Thread.async_interrupt_timing

for protecting from async interrupt.
* lib/sync.rb (Sync_m#sync_lock): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kosaki 2012-11-30 18:55:28 +00:00
parent 028ca79f98
commit c62ec3ae1a
2 changed files with 29 additions and 20 deletions

View File

@ -1,3 +1,9 @@
Sat Dec 1 03:49:45 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* lib/sync.rb (Sync_m#sync_synchronize): add Thread.async_interrupt_timing
for protecting from async interrupt.
* lib/sync.rb (Sync_m#sync_lock): ditto.
Sat Dec 1 03:38:04 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* lib/thread.rb (ConditionVariable#broadcast): s/RuntimeError/StandardError/

View File

@ -135,7 +135,7 @@ module Sync_m
def sync_lock(m = EX)
return unlock if m == UN
Thread.async_interrupt_timing(StandardError => :on_blocking) do
while true
@sync_mutex.synchronize do
begin
@ -157,6 +157,7 @@ module Sync_m
end
end
end
end
self
end
@ -226,6 +227,7 @@ module Sync_m
end
def sync_synchronize(mode = EX)
Thread.async_interrupt_timing(StandardError => :on_blocking) do
sync_lock(mode)
begin
yield
@ -233,6 +235,7 @@ module Sync_m
sync_unlock
end
end
end
attr_accessor :sync_mode