@@ -56,6 +56,12 @@ mc_owner_p(struct rb_monitor *mc)
5656 return mc -> owner == rb_fiber_current ();
5757}
5858
59+ /*
60+ * call-seq:
61+ * try_enter -> true or false
62+ *
63+ * Attempts to enter exclusive section. Returns +false+ if lock fails.
64+ */
5965static VALUE
6066monitor_try_enter (VALUE monitor )
6167{
@@ -72,6 +78,12 @@ monitor_try_enter(VALUE monitor)
7278 return Qtrue ;
7379}
7480
81+ /*
82+ * call-seq:
83+ * enter -> nil
84+ *
85+ * Enters exclusive section.
86+ */
7587static VALUE
7688monitor_enter (VALUE monitor )
7789{
@@ -85,6 +97,7 @@ monitor_enter(VALUE monitor)
8597 return Qnil ;
8698}
8799
100+ /* :nodoc: */
88101static VALUE
89102monitor_check_owner (VALUE monitor )
90103{
@@ -95,6 +108,12 @@ monitor_check_owner(VALUE monitor)
95108 return Qnil ;
96109}
97110
111+ /*
112+ * call-seq:
113+ * exit -> nil
114+ *
115+ * Leaves exclusive section.
116+ */
98117static VALUE
99118monitor_exit (VALUE monitor )
100119{
@@ -112,13 +131,15 @@ monitor_exit(VALUE monitor)
112131 return Qnil ;
113132}
114133
134+ /* :nodoc: */
115135static VALUE
116136monitor_locked_p (VALUE monitor )
117137{
118138 struct rb_monitor * mc = monitor_ptr (monitor );
119139 return rb_mutex_locked_p (mc -> mutex );
120140}
121141
142+ /* :nodoc: */
122143static VALUE
123144monitor_owned_p (VALUE monitor )
124145{
@@ -166,6 +187,7 @@ monitor_enter_for_cond(VALUE v)
166187 return Qnil ;
167188}
168189
190+ /* :nodoc: */
169191static VALUE
170192monitor_wait_for_cond (VALUE monitor , VALUE cond , VALUE timeout )
171193{
@@ -193,6 +215,14 @@ monitor_sync_ensure(VALUE monitor)
193215 return monitor_exit (monitor );
194216}
195217
218+ /*
219+ * call-seq:
220+ * synchronize { } -> result of the block
221+ *
222+ * Enters exclusive section and executes the block. Leaves the exclusive
223+ * section automatically when the block exits. See example under
224+ * +MonitorMixin+.
225+ */
196226static VALUE
197227monitor_synchronize (VALUE monitor )
198228{
0 commit comments