From: Robert Klemme Date: 2008-01-09T07:00:04+09:00 Subject: Re: Marshal Pipe On 08.01.2008 20:01, Carlos J. Hernandez wrote: > Ara: > > Yaml is find over internet connection where transmission time is high > compared to cpu time, and > where human readability is a plus. > For my case, separate programs/processes on the same machine working > very closely > as if a single program in a pipe architecture... Marshal is better. > In fact, if Marshal is a bit of a Hybrid (don't know the details), then > what I really want is pure binary, I think. > > Anyways, for a bit more details of my implementation, > taking out the specifics of my application and including Roberts' > comments, > I now have: > > class MarshalPipe > def self.puts(data) > Marshal.dump( data, $stdout ) > end > > def _pipe > data = nil > while data = Marshal.load($stdin) do > pipe(data) What does #pipe do? Why don't you use a block for the processing of the data? For a general (aka library) solution it would also be much better to pass the IO as an argument, in case there are more pipes to work with. > break if $stdin.eof? > end > end > end > > I don't know why this did not work: > > until $stdin.eof do > data = Marshal.load($stdin) > pipe( data ) > end Probably because this is not the same as my code (hint: punctuation matters). Bte, I am still interested to learn the use case where your solution is significantly better than an in process solution with Threads and a Queue... Regards robert