peper0
peper0

Reputation: 3223

Is it guaranteed that handler of async_* in boost::asio will be always called?

I call boost::asio::serial_port::async_write_some() and asio::io_service::run() in the other thread. There is a callback given to "async_write_some". Can I safely assume, that this callback will be eventually called (possibly with some error code)? Under what circumstances it's not true?

Upvotes: 2

Views: 304

Answers (2)

Igor R.
Igor R.

Reputation: 15075

As long as io_service runs, a completion handler is guaranteed to get invoked after the async operation is completed (either successfully or not).

Upvotes: 3

megabyte1024
megabyte1024

Reputation: 8660

Can I safely assume, that this callback will be eventually called (possibly with some error code)?

I think no.

Under what circumstances it's not true?

The io_service::stop method is called before data is sent.

Upvotes: 4

Related Questions