|
Boost Users : |
From: Richard Hodges (hodges.r_at_[hidden])
Date: 2020-09-02 08:02:21
On Wed, 2 Sep 2020 at 06:59, lampahome <pahome.chen_at_[hidden]> wrote:
>
>
> Richard Hodges via Boost-users <boost-users_at_[hidden]> æ¼ 2020å¹´9æ1æ¥
> é±äº ä¸å6:54寫éï¼
>
>> Asio certainly has support for asynchronous file IO. I have used it on
>> linux systems for a multitude of file handle types, including console I/O.
>>
>> Is there any function can handle the finished IO operation?
>
> Assume I have two threads. One is only submit async io to file, and
> another one is only handle event of those executed io.
> I only find handler function but wonder if any easier handler to handle
> all.
>
I'm not quite sure why you'd need two threads. But if you did, asio allows
you to bind handlers to executors prior to submission to asynchronous
initiating functions.
The handler will be executed by its associated executor, which could if you
require be running in a different thread.
e.g.
async_write(f, buf, asio::bind_executor(other_executor,
[](error_code ec, std::size_t written) {
// handler now executed by other_executor
});
If submitting across threads you'd want to be sure to protect access to
the file object with a mutex or a strand.
>
> thanks
>
-- Richard Hodges hodges.r_at_[hidden] office: +442032898513 home: +376841522 mobile: +376380212
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net