Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
318 views
in Technique[技术] by (71.8m points)

c++ - What's the difference between boost::io_service poll_one and run_one?

io_service::poll_one Run the io_service object's event processing loop to execute one ready handler.

vs

io_service::run_one Run the io_service object's event processing loop to execute at most one handler.

From that explanation it would seem poll_one could execute more than one handler? Does run_one or poll_one use any thread that's called run() or only the thread that calls poll_one/run_one?

The documentation for ASIO is very sparse.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

poll_one will return immediately (non-blocking) in case there is no event to process.

run_one will block the calling thread until one event is ready to process.

You could also check some documentation here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...