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

source_changes at macosforge.org source_changes at macosforge.org
Wed Jan 13 15:02:59 PST 2010


Revision: 3265
          http://trac.macosforge.org/projects/ruby/changeset/3265
Author:   ernest.prabhakar at gmail.com
Date:     2010-01-13 15:02:57 -0800 (Wed, 13 Jan 2010)
Log Message:
-----------
Udated docs for Dispatch::FileSource

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

Modified: MacRuby/trunk/gcd.c
===================================================================
--- MacRuby/trunk/gcd.c	2010-01-13 23:02:55 UTC (rev 3264)
+++ MacRuby/trunk/gcd.c	2010-01-13 23:02:57 UTC (rev 3265)
@@ -958,23 +958,26 @@
 {
     VALUE io = (VALUE)io_ptr;
     rb_vm_call(io, selClose, 0, NULL, NO);
+    //GC_RELEASE(io);
 }
 
 /* 
  *  call-seq:
- *    Dispatch::FileSource.new(type, handle, mask, queue) 
+ *    Dispatch::FileSource.new(type, io, mask, queue) 
  *     {|src| block} => Dispatch::Source
  *
- *  Like Dispatch::Source.new, except that it automatically creates
- *  a cancel handler that will close(2) that file descriptor
+ *  Like Dispatch::Source.new, except:
+ *     a) it takes an IO (File) object instead of an integer handle
+ *     b) it automatically creates a cancel handler that closes that object
  *  
  *     gcdq = Dispatch::Queue.new('doc')
  *     file = File.open("/etc/passwd", r)
  *     src = Dispatch::FileSource.new(Dispatch::Source::READ,
- *           file, 0, gcdq) { |s| s.cancel! }
+ *           file, 0, gcdq) { }
+ *     src.cancel!
+ *      @q.sync { }
+ *     @file.closed? # => true
  *
- *   Note that in this case you pass the File object instead of a descriptor
- *
  *   The type must be one of:
  *      - Dispatch::Source::READ
  *      - Dispatch::Source::WRITE
@@ -1000,6 +1003,7 @@
     rb_source_setup(self, sel, type, handle, mask, queue);
     rb_source_t *src = RSource(self);            
     dispatch_set_context(src->source, (void*)io); // should this be retained?
+    //GC_RETAIN(io);
     dispatch_source_set_cancel_handler_f(src->source, rb_source_close_handler);
     rb_dispatch_resume(self, 0);
     return self;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100113/00d7226b/attachment.html>


More information about the macruby-changes mailing list