POE-0.26 > POE::Driver::SysRW

名前

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

POE::Driver::SysRW - アブストラクトsysread/syswriteファイルドライバ

概要

  $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();

説明

This driver implements an abstract interface to sysread and syswrite.

このドライバはsysreadと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.

new()は新しいSysRWドライバを生成します。オプショナルの名前付き引数 BlockSizeを1つ受け取ります。BlockSizeは一度にどれだけの情報を読むかを伝 えます。BlockSizeは省略された場合512がデフォルトになります。

  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().

syswrite()のサイズは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.

Driver::SysRWは出力メッセージのキューを使います。これは書き込みに対して BLOCK_SIZEを使わないことを意味します。正確に言えば、ドライバを通して put()される各メッセージはそれ全体が書き込まれるか、あるいは失敗すれば全 く何も書かれません。これはしばしば必要とされるよりも多くsyswrite()が呼 び出されることを意味しますが、メモリ管理をより簡単にします。

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.

もしドライバが出力にスカラバッファを使うとすると、データが書き込まれた 後にバッファの先頭を取り除くためにsubstr()を使う必要があるでしょう。各 substr()呼び出しはその文字列の最後を先頭まで動かす必要があります。それ は大量のメモリコピーです。

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.

POEのSEE ALSOセクションがPOEのディストリビューション全体をカバーする 目次を含んでいます。

AUTHORS & COPYRIGHTS

Please see POE for more information about authors and contributors.

作者と貢献者についての詳しい情報はPOEを参照してください。

Translators

井上 謙次 <deq@oct.zaq.ne.jp>