[macruby-changes] [2690] MacRuby/trunk/gcd.c

source_changes at macosforge.org source_changes at macosforge.org
Wed Sep 30 07:45:29 PDT 2009


Revision: 2690
          http://trac.macosforge.org/projects/ruby/changeset/2690
Author:   pthomson at apple.com
Date:     2009-09-30 07:45:26 -0700 (Wed, 30 Sep 2009)
Log Message:
-----------
Added documentation for Dispatch::Source.for_reading.

Modified Paths:
--------------
    MacRuby/trunk/gcd.c

Modified: MacRuby/trunk/gcd.c
===================================================================
--- MacRuby/trunk/gcd.c	2009-09-30 14:08:38 UTC (rev 2689)
+++ MacRuby/trunk/gcd.c	2009-09-30 14:45:26 UTC (rev 2690)
@@ -638,6 +638,27 @@
     return (VALUE)source;
 }
 
+/* 
+ *  call-seq:
+ *    Dispatch::Source.for_reading(queue, io, &block)    =>  Dispatch::Source
+ *
+ *  Returns a Source that monitors the passed IO object for pending data. 
+ *	When provided with a valid on_event handler, the source will call the 
+ *	handler on the provided queue whenever it sees that data becomes available from the source's
+ *	underlying file descriptor. If the on_event handler takes a parameter,
+ *	that parameter will be an integer corresponding to an estimated number of
+ *	bytes available to be read. See the dispatch_source_create(3) manpage for details.
+ *  All Sources start out suspended; in order to activate them, call <code>resume!</code>.
+ *	If for_reading is given a block, the block shall be registered as the 
+ *  source's event handler.
+ *
+ *  
+ *     file = File.new('testfile')
+ *	   queue = Queue.new('org.macruby.documentation')
+ *	   reader = Source.for_reading(queue, file) do { |x| puts "#{x} bytes available"}
+ *
+ */
+
 static VALUE
 rb_source_new_for_reading(VALUE klass, SEL sel, VALUE queue, VALUE io)
 {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090930/a3f93153/attachment.html>


More information about the macruby-changes mailing list