|
Boost : |
From: Kowalke Oliver (QD IT PA AS) (Oliver.Kowalke_at_[hidden])
Date: 2008-04-08 02:43:52
> On Mon, 07 Apr 2008 11:40:48 +0200, Sebastian Redl
> <sebastian.redl_at_[hidden]> wrote:
>
> > Boris wrote:
> >> I ask as I was trying to extend Boost.Asio and add support for
> >> C++ standard streams on the weekend. I came to the conclusion that
> >> C++ this
> >> is
> >> impossible (as calls to C++ standard streams block and there is no
> >> way to interrupt a blocking call, at least not in a portable way).
> >>
> > The only way to simulate asynchronous I/O using blocking
> calls is to
> > use a separate thread for every I/O object.
>
> This doesn't work either as you can't interrupt the blocking
> call if you want to close the stream.
Two ways:
1.) use asynchronous I/O with aio-system calls (UNIX: aio_read/aio_write, ... whith aiocb struct; AFAIK not supported by boost::asio)
Note: AIO is not supported on all systems (for instance on LINUX aio doesn't realy support sockets) and other I/O techniques maybe faster and more efficient.
2.) use synchronous I/O with non-blocking descriptors, demultiplexing techniques (select, epoll, kqueue,...) and threads (==the way boost::asio works).
regards, Oliver
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk