man POE::Driver::SysRW () - an abstract sysread/syswrite file driver

NAME

POE::Driver::SysRW - an abstract sysread/syswrite file driver

SYNOPSIS

  $driver = POE::Driver::SysRW->new();
  $arrayref_of_data_chunks = $driver->get($filehandle);
  $queue_octets = $driver->put($arrayref_of_data_chunks);
  $queue_octets = $driver->flush($filehandle);
  $queue_messages = $driver->get_out_messages_buffered();

DESCRIPTION

This driver implements an abstract interface to sysread and syswrite.

PUBLIC METHODS

new
new() creates a new SysRW driver. It accepts one optional named parameter, BlockSize, which indicates the maximum number of octets it will read at a time. For speed, syswrite() tries to send as much information as it can. BlockSize defaults to 65536 if it is omitted. Higher values improve performance in high-throughput applications at the expense of consuming more resident memory. Lower values reduce memory consumption with corresponding throughput penalties.
  my $driver = POE::Driver::SysRW->new( BlockSize => $block_size );
  my $driver = POE::Driver::SysRW->new;

DESIGN NOTES

Driver::SysRW uses a queue of output messages. This means that BLOCK_SIZE is not used for writing. Rather, each message put() through the driver is written in its entirety (or not, if it fails). This often means more syswrite() calls than necessary, however it makes memory management much easier.

If the driver used a scalar buffer for output, it would be necessary to use substr() to remove the beginning of it after it was written. Each substr() call requires the end of the string be moved down to its beginning. That is a lot of memory copying.

The buffer could be allowed to grow until it has flushed entirely. This would be eliminate extra memory copies entirely, but it would then be possible to create programs where the buffer was not allowed to shrink at all. That would quickly become bad.

Better ideas are welcome.

SEE ALSO

POE::Driver.

The SEE ALSO section in POE contains a table of contents covering the entire POE distribution.

AUTHORS & COPYRIGHTS

Please see POE for more information about authors and contributors.