Re: [asio-users] Questions about file io when using boost.asio
Brought to you by:
chris_kohlhoff
From: lampahome <pah...@mi...> - 2020-09-01 09:46:36
|
> > > program event-based or is it just that you have one file operation that > needs to be async? > My program is event-based 2. If io_service.run() failed, is there any queue to let me know which job > failed? Or it only jump exception? > > What do you mean by failed? The io_service probably didn't fail, it's > some task you asked it to do that failed. In that case, you probably meant > to catch the failure yourself. I.e., instead of your task being > My mistake. I mean the io operation failed. It seems read/write handler can handle failed situations, but is there a centralized queue(? or something) can collect these failed or all operations? I want to do is like libaio in unix system and want to find some library to reach that easier. I have two threads(or one is main thread) and one thread will submit io of file as more as it can, and another one thread will check the execution state(i.e. return code) of each io. I thought this design pattern will improve my program. Looks like the io_context, async_read, and async_write will help me, but the handler in Doc seems naive? void handle_write_error(const boost::system::error_code& ec, std::size_t){...} Every document told above handler, but it seems can only two arguments? Maybe some misunderstand, thank u. |