IO.pipe issues -- related to RubyIO

0 views
Skip to first unread message

Michael Chen

unread,
May 19, 2007, 12:39:33 PM5/19/07
to xruby...@googlegroups.com
Hi,

As a new comer I don't know I am fortunate enough or not...I picked
the test_io.rb as my starting point to do some work for xruby. And I
found a bunch of issues, so I post here looking for advice/help.

First of all, current IO module highly depends on RandomAccessFile,
aka real file. it's true under unix/linux 'cause everyting is file.
But in JVM I think they have seperate it mainly into two parts, the
File and the Streams. We have InputStream/InputReader/Channel...to
have different ways doing IO. Current RubyIO implementation can not
meet the requirement.

OK, let's see the IO.pipe. As we know in Java before jdk1.4, we do
pipe like this:

pr = new PipeReader();
pw = new PipeWriter(pr);
printWriter = new PrintWriter(pw);
printWriter.write("xxxx");

while (pr.read() !=-1) { ... }

Or, from JDK1.4 NIO:

pipe = Pipe.open();
pipe.sink().write...
pipe.source().read...

They have no direct relationship with File.

and more, the ruby's $stdin, $stdout and $stderr are directly binding
to system input/output/error, I don't know how to create a file for
them.

So what I am thinking about is, refactory the RubyIO to an abstract
class, have the basic operations(read, write, gets, puts...) only, and
have FileRubyIO(aka RubyFile, yes), StreamRubyIO(or ReaderRubyIO),
PipedRubyIO inherited. the class hierarchy is like below:

RubyIO
- FileRubyIO(RubyFile)
- StreamRubyIO
- PipedRubyIO

We can also map the global variables $stdin, $stdout, $stderr to
StreamRubyIO, constructed with System.in, System,out and System.err.

I have just went thru the code for about one day. If I have something
wrong please let me know, thanks.

--
Michael Chen
--------------------------------
Blog: http://michael.nona.name
MSN: jzch...@hotmail.com

Xue Yong Zhi

unread,
May 19, 2007, 11:40:56 PM5/19/07
to xruby...@googlegroups.com
Hello Michael,
Thank you for taking a look of the issue. Actually I am planning to
rewrite RubyIO completely with java's nio. Besides all the problems you
found, the current implmentation is very limited and slow.
If you want to help us to improve it, I would be very happy to add you as
a project memeber.

_________________________________________________________________
PC Magazine’s 2007 editors’ choice for best Web mail—award-winning Windows
Live Hotmail.
http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_pcmag_0507

Michael Chen

unread,
May 20, 2007, 3:01:32 AM5/20/07
to xruby...@googlegroups.com
Hi Yongzhi,

I have done some work and make the test_io.rb passed. I will refactory
the code and make a patch late today or tommorow. As I think rewrite
the whole RubyIO is a huge work for me(not only the work effort, but
also there are may be many thin unknown to me), I would prefer make
the IO#pipe work and then move further. I am quite sure that you or
other developers have your own concern/design thoughts on that. May be
we could have a discussion.

Xue Yong Zhi

unread,
May 20, 2007, 6:58:52 AM5/20/07
to xruby...@googlegroups.com
Hey Michael,
Thanks. It is very good news as IO#pipe is used in several ruby test
cases.

You can either submit the patch or check in the code directly. Please
login http://code.google.com/p/xruby/source to find your SVN password. For
timezone difference (I live in Maryland), feel free to contact other team
members if you need help while I am offline.

IO is one of the most important parts of library and our current
implementation is weak. I will think more about the problem and be very
happy to hear insights from you.

(btw, I am on the road this weekend, will back to the project work soon.)

>From: "Michael Chen" <mech...@gmail.com>
>Reply-To: xruby...@googlegroups.com
>To: xruby...@googlegroups.com
>Subject: [xruby-devel] Re: IO.pipe issues -- related to RubyIO
>Date: Sun, 20 May 2007 15:01:32 +0800
>
>
>Hi Yongzhi,
>
>I have done some work and make the test_io.rb passed. I will refactory
>the code and make a patch late today or tommorow. As I think rewrite
>the whole RubyIO is a huge work for me(not only the work effort, but
>also there are may be many thin unknown to me), I would prefer make
>the IO#pipe work and then move further. I am quite sure that you or
>other developers have your own concern/design thoughts on that. May be
>we could have a discussion.
>

_________________________________________________________________

Reply all
Reply to author
Forward
0 new messages