|
Boost : |
From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2007-06-08 09:36:38
On Mon, 4 Jun 2007 03:12:08 +0700,
"Владислав
Чернышов"
<carter.subscribe_at_[hidden]> said:
> OK, I got it. By "async requests" I mean requests running concurrently,
> and I don't have to wait others to process available data. Am I right?
Yes.
> Does asio use POSIX AIO in Linux implementation? I mean librt functions.
No, it uses epoll and non-blocking I/O to emulate asynchronous
operations.
> How to make some other work while doing i/o operations in single threaded
> program?
Here are two different approaches you could take:
- If your program has given over control to io_service::run(), use a
chain of posts() or maybe a deadline_timer to perform the work in small
chunks. E.g.:
void do_some_work()
{
// perform a small amount of work here
// post this function again to do a bit more work.
io_service.post(do_some_work);
}
- If you want the main program control to be your "other work",
periodically call io_service::poll() to check for completed I/O
operations and invoke the associated handlers.
Cheers,
Chris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk