Open rohitpai opened 10 months ago
@rohitpai
I'm not sure what the issue is on your platform. Running your reproduction program on Linux w/ Boost.asio 1.83 terminates after the 12.2 seconds as you expect:
at 0ms - tid:1 Worker thread enter
at 0ms - tid:2 Worker thread enter
at 0ms - tid:3 App started :8
at 100ms - tid:1 Start Task1: Success
at 200ms - tid:2 Start Task2: Success
at 12200ms - tid:2 Worker thread exit
at 12200ms - tid:1 Worker thread exit
at 12200ms - tid:3 All worker threads joined.
It's a bit odd to see sleep()
in an async program. These could be replaced with more steady timers to allow other work to be completed while those strands wait. Maybe replacing those will prove better results.
Sorry that I don't have anything to help - maybe try updating asio, as I'm testing with an updated version compared to you. The classic phrase: "it works on my machine"
I am using boost version 1.79 on embedded linux 5.15 platform which is running on Dual Core Cortex A7 hardware. I have the below code which I am testing to check sharing same IO context with multiple threads (which execute io.run)
Output
The program never terminates and need to be killed. One worker thread seem to hang and only one worker thread is picking up both timer callbacks serially. I am not able to understand the behavior. As per this article both the threads should run concurrently and pickup the handlers. Why one worker thread executing ioContext.run() always hangs in the above example. Need your help to understand if its a bug in the library or something wrong in the test code.
GDB back trace of the thread that hangs