1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/thread/thread.c: [DOC] This patch accomplishes the following:

- Teach RDoc about ConditionVariable
  - Teach RDoc about Queue
  - Teach RDoc about SizedQueue
  - Use fully-qualified namespace for Document-method
    This is necessary to separate definitions between classes
  - Fix rdoc bug in call_seq vs. call-seq
  - Correct doc for SizedQueue#pop patch by @jackdanger [Bug #8988]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
zzak 2013-11-13 17:37:47 +00:00
parent 62d3853475
commit af5e21292c
2 changed files with 73 additions and 57 deletions

View file

@ -1,3 +1,15 @@
Thu Nov 14 02:37:14 2013 Zachary Scott <e@zzak.io>
* ext/thread/thread.c: [DOC] This patch accomplishes the following:
- Teach RDoc about ConditionVariable
- Teach RDoc about Queue
- Teach RDoc about SizedQueue
- Use fully-qualified namespace for Document-method
This is necessary to separate definitions between classes
- Fix rdoc bug in call_seq vs. call-seq
- Correct doc for SizedQueue#pop patch by @jackdanger [Bug #8988]
Thu Nov 14 01:11:54 2013 Zachary Scott <e@zzak.io> Thu Nov 14 01:11:54 2013 Zachary Scott <e@zzak.io>
* ext/bigdecimal/lib/bigdecimal/util.rb: [DOC] +precision+ is required * ext/bigdecimal/lib/bigdecimal/util.rb: [DOC] +precision+ is required

View file

@ -79,10 +79,9 @@ wakeup_all_threads(VALUE list)
*/ */
/* /*
* Document-method: new * Document-method: ConditionVariable::new
* call-seq: new
* *
* Creates a new condvar. * Creates a new condition variable instance.
*/ */
static VALUE static VALUE
@ -113,7 +112,7 @@ delete_current_thread(VALUE ary)
} }
/* /*
* Document-method: wait * Document-method: ConditionVariable#wait
* call-seq: wait(mutex, timeout=nil) * call-seq: wait(mutex, timeout=nil)
* *
* Releases the lock held in +mutex+ and waits; reacquires the lock on wakeup. * Releases the lock held in +mutex+ and waits; reacquires the lock on wakeup.
@ -140,8 +139,7 @@ rb_condvar_wait(int argc, VALUE *argv, VALUE self)
} }
/* /*
* Document-method: signal * Document-method: ConditionVariable#signal
* call-seq: signal
* *
* Wakes up the first thread in line waiting for this lock. * Wakes up the first thread in line waiting for this lock.
*/ */
@ -154,8 +152,7 @@ rb_condvar_signal(VALUE self)
} }
/* /*
* Document-method: broadcast * Document-method: ConditionVariable#broadcast
* call-seq: broadcast
* *
* Wakes up all threads waiting for this lock. * Wakes up all threads waiting for this lock.
*/ */
@ -196,10 +193,9 @@ rb_condvar_broadcast(VALUE self)
*/ */
/* /*
* Document-method: new * Document-method: Queue::new
* call-seq: new
* *
* Creates a new queue. * Creates a new queue instance.
*/ */
static VALUE static VALUE
@ -219,10 +215,10 @@ queue_do_push(VALUE self, VALUE obj)
} }
/* /*
* Document-method: push * Document-method: Queue#push
* call-seq: push(obj) * call-seq: push(object)
* *
* Pushes +obj+ to the queue. * Pushes the given +object+ to the queue.
*/ */
static VALUE static VALUE
@ -297,12 +293,14 @@ queue_pop_should_block(int argc, VALUE *argv)
} }
/* /*
* Document-method: pop * Document-method: Queue#pop
* call_seq: pop(non_block=false) * call-seq: pop(non_block=false)
* *
* Retrieves data from the queue. If the queue is empty, the calling thread is * Retrieves data from the queue.
* suspended until data is pushed onto the queue. If +non_block+ is true, the *
* thread isn't suspended, and an exception is raised. * If the queue is empty, the calling thread is suspended until data is pushed
* onto the queue. If +non_block+ is true, the thread isn't suspended, and an
* exception is raised.
*/ */
static VALUE static VALUE
@ -313,7 +311,7 @@ rb_queue_pop(int argc, VALUE *argv, VALUE self)
} }
/* /*
* Document-method: empty? * Document-method: Queue#empty?
* call-seq: empty? * call-seq: empty?
* *
* Returns +true+ if the queue is empty. * Returns +true+ if the queue is empty.
@ -326,8 +324,7 @@ rb_queue_empty_p(VALUE self)
} }
/* /*
* Document-method: clear * Document-method: Queue#clear
* call-seq: clear
* *
* Removes all objects from the queue. * Removes all objects from the queue.
*/ */
@ -340,8 +337,7 @@ rb_queue_clear(VALUE self)
} }
/* /*
* Document-method: length * Document-method: Queue#length
* call-seq: length
* *
* Returns the length of the queue. * Returns the length of the queue.
*/ */
@ -354,8 +350,7 @@ rb_queue_length(VALUE self)
} }
/* /*
* Document-method: num_waiting * Document-method: Queue#num_waiting
* call-seq: num_waiting
* *
* Returns the number of threads waiting on the queue. * Returns the number of threads waiting on the queue.
*/ */
@ -377,7 +372,7 @@ rb_queue_num_waiting(VALUE self)
*/ */
/* /*
* Document-method: new * Document-method: SizedQueue::new
* call-seq: new(max) * call-seq: new(max)
* *
* Creates a fixed-length queue with a maximum size of +max+. * Creates a fixed-length queue with a maximum size of +max+.
@ -402,8 +397,7 @@ rb_szqueue_initialize(VALUE self, VALUE vmax)
} }
/* /*
* Document-method: max * Document-method: SizedQueue#max
* call-seq: max
* *
* Returns the maximum size of the queue. * Returns the maximum size of the queue.
*/ */
@ -415,10 +409,10 @@ rb_szqueue_max_get(VALUE self)
} }
/* /*
* Document-method: max= * Document-method: SizedQueue#max=
* call-seq: max=(n) * call-seq: max=(number)
* *
* Sets the maximum size of the queue. * Sets the maximum size of the queue to the given +number+.
*/ */
static VALUE static VALUE
@ -441,11 +435,12 @@ rb_szqueue_max_set(VALUE self, VALUE vmax)
} }
/* /*
* Document-method: push * Document-method: SizedQueue#push
* call-seq: push(obj) * call-seq: push(object)
* *
* Pushes +obj+ to the queue. If there is no space left in the queue, waits * Pushes +object+ to the queue.
* until space becomes available. *
* If there is no space left in the queue, waits until space becomes available.
*/ */
static VALUE static VALUE
@ -475,10 +470,14 @@ szqueue_do_pop(VALUE self, VALUE should_block)
} }
/* /*
* Document-method: pop * Document-method: SizedQueue#pop
* call_seq: pop(non_block=false) * call-seq: pop(non_block=false)
* *
* Returns the number of threads waiting on the queue. * Retrieves data from the queue.
*
* If the queue is empty, the calling thread is suspended until data is pushed
* onto the queue. If +non_block+ is true, the thread isn't suspended, and an
* exception is raised.
*/ */
static VALUE static VALUE
@ -489,8 +488,7 @@ rb_szqueue_pop(int argc, VALUE *argv, VALUE self)
} }
/* /*
* Document-method: pop * Document-method: SizedQueue#num_waiting
* call_seq: pop(non_block=false)
* *
* Returns the number of threads waiting on the queue. * Returns the number of threads waiting on the queue.
*/ */
@ -536,6 +534,12 @@ Init_thread(void)
"SizedQueue", rb_cQueue, rb_struct_alloc_noinit, "SizedQueue", rb_cQueue, rb_struct_alloc_noinit,
"que", "waiters", "queue_waiters", "size", NULL); "que", "waiters", "queue_waiters", "size", NULL);
#if 0
rb_cConditionVariable = rb_define_class("ConditionVariable", rb_cObject); /* teach rdoc ConditionVariable */
rb_cQueue = rb_define_class("Queue", rb_cObject); /* teach rdoc Queue */
rb_cSizedQueue = rb_define_class("SizedQueue", rb_cObject); /* teach rdoc SizedQueue */
#endif
id_sleep = rb_intern("sleep"); id_sleep = rb_intern("sleep");
rb_define_method(rb_cConditionVariable, "initialize", rb_condvar_initialize, 0); rb_define_method(rb_cConditionVariable, "initialize", rb_condvar_initialize, 0);