On Tue, Dec 21, 2004 at 08:39:53PM -0800, Dan McCormick wrote: > So consider this: > > I have a stream of data, which I'm sending to the POE::Wheel::Run process. > At an arbitrary time I can get a signal that the stream has ended, at which > point I want to shutdown the process's STDIN. > > If I knew the last bit of data sent was going to be the last bit of data, I > could set a flag as I send it to the POE::Wheel::Run process, and then the > next StdinEvent could call stdin_shutdown. But I don't know which bit of > data is going to be the last. > > So when I receive the signal to shutdown STDIN, I don't know if the STDIN > buffer is flushed or not (do I?). I can set a flag, but if it's already > flushed, the StdinEvent will never get called. > > It seems I need a way to tell if there's anything pending in the buffer. > > Checking $wheel->get_stdin_filter->get_pending() seems like a good bet, but > doesn't seem to be working -- it always seems to return false, even though > if I then call stdin_shutdown the data never arrives at my process. > > Any suggestions? Am I missing something?
Yep! The child's STDIN is the wheel's otput buffer. Whenever you put() something to a wheel, you're writing whole "things" (where "thing" is defined by the filter you're using). Since things are sent whole, filters don't need to buffer them for output. Rather, they convert them and return them right away. The serialized "things" are sent to the driver for flushing "in a little while". Anyway, most wheels have get_driver_out_octets() methods that tell you how many octets are waiting in the driver to be flushed. I think that's what you're looking for. -- Rocco Caputo - http://poe.perl.org/