Re: Flushing a FollowTail wheel.
by Rocco Caputo other posts by this author
Nov 24 2006 1:49PM messages near this date
Flushing a FollowTail wheel.
|
object_states 2
On Nov 21, 2006, at 21:18, Mark Swayne wrote:
> Is it possible to flush the contents of a POE::Wheel::FollowTail
> wheel?
>
> I am using one to monitor a file that is left with a non '\n'
> terminated line at when the process that creates it is finished.
>
> What I'd like to be able to do before closing is somthing like:
>
> sub finish_file {
> my $heap = $_[HEAP];
> $heap->{wheel}->flush; # this should generate an InputEvent with
> any dangling bits left in the buffer.
>
> # do other stuff here
> }
If Wheel::FollowTail had a set_filter() method, you could use it to
switch to POE::Filter::Stream. That would get you a final InputEvent
with whatever remained in the buffer. On your end, the code would be:
sub finish_file {
my $heap = $_[HEAP];
$heap-> {wheel}->set_filter( POE::Filter::Stream->new() );
# ...
}
I've attached an untested patch for set_filter(). Let me know if it
works, and I'll commit it.
--
Rocco Caputo - rcaputo@pobox.com
Thread:
Mark Swayne
Rocco Caputo
|