summaryrefslogtreecommitdiff
path: root/include/ruby/internal/intern/thread.h
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2021-03-24 09:21:58 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2021-09-10 20:00:06 +0900
commit0ea157136f1b255321722db1acd0be3c6229a77a (patch)
tree1c25cd985a4f2a535c7b4135200a755395452506 /include/ruby/internal/intern/thread.h
parentce54282b75761b97ea961ea5fe19cef244f82f97 (diff)
postscript about rb_mutex_sleep
Asked ko1 about the design. [ci skip]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4815
Diffstat (limited to 'include/ruby/internal/intern/thread.h')
-rw-r--r--include/ruby/internal/intern/thread.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/include/ruby/internal/intern/thread.h b/include/ruby/internal/intern/thread.h
index c9f476744a..294e552fe9 100644
--- a/include/ruby/internal/intern/thread.h
+++ b/include/ruby/internal/intern/thread.h
@@ -463,8 +463,17 @@ VALUE rb_mutex_unlock(VALUE mutex);
*
* This function is called from `ConditionVariable#wait`. So it is not a
* deprecated feature. However @shyouhei have never seen any similar mutex
- * primitive available in any other language than Ruby. Is this a right
- * design? Maybe isn't it too complex a primitive?
+ * primitive available in any other languages than Ruby.
+ *
+ * EDIT: In 2021, @shyouhei asked @ko1 in person about this API. He answered
+ * that it is his invention. The motivation behind its design is to eliminate
+ * needs of condition variables as primitives. Unlike other languages, Ruby's
+ * `ConditionVariable` class was written in pure-Ruby initially. We don't have
+ * to implement machine-native condition variables in assembly each time we
+ * port Ruby to a new architecture. This function made it possible. "I felt I
+ * was a genius when this idea came to me", said @ko1.
+ *
+ * `rb_cConditionVariable` is now written in C for speed, though.
*/
VALUE rb_mutex_sleep(VALUE self, VALUE timeout);