Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implement Thread.exclusive for 1.9

  • Loading branch information...
commit 49f9e3a540e458112f9511bc7733d4efab3c74f9 1 parent 3eb353d
John Firebaugh jfirebaugh authored
1  kernel/common/load_order19.txt
View
@@ -108,6 +108,7 @@ symbol19.rbc
thread.rbc
thread_group.rbc
mutex.rbc
+thread19.rbc
throw_catch.rbc
throw_catch19.rbc
time.rbc
7 kernel/common/thread19.rb
View
@@ -0,0 +1,7 @@
+class Thread
+ MUTEX_FOR_THREAD_EXCLUSIVE = Mutex.new
+
+ def Thread.exclusive
+ MUTEX_FOR_THREAD_EXCLUSIVE.synchronize { yield }
+ end
+end
16 lib/19/thread.rb
View
@@ -12,22 +12,6 @@
Thread.abort_on_exception = true
end
-class Thread
- #
- # Wraps a block in Thread.critical, restoring the original value upon exit
- # from the critical section.
- #
- def Thread.exclusive
- _old = Thread.critical
- begin
- Thread.critical = true
- return yield
- ensure
- Thread.critical = _old
- end
- end
-end
-
#
# ConditionVariable objects augment class Mutex. Using condition variables,
# it is possible to suspend while in the middle of a critical section until a
Please sign in to comment.
Something went wrong with that request. Please try again.