++ed by:
SHLOMIF PRAVUS DELON SZABGAB SKIM

23 PAUSE users
26 non-PAUSE users.

Rocco Caputo

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 BlockSize => $block_size
new

new() creates a new SysRW driver. It accepts one optional named parameter, BlockSize, which tells it how much information to read at a time. BlockSize defaults to 512 if it is omitted.

  my $driver = POE::Driver::SysRW->new( BlockSize => $block_size );

  my $driver = POE::Driver::SysRW->new;

syswrite() size defaults to the size of whatever is given to put().

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.