An “Abort” is a special type of error in a system, usually injected by an external actor. In a multi-threaded application, managing abort requests becomes pain. I am sharing a few observations that could improve/minimize mistakes.
- Implement one single handler for abort requests
- Outside the handler, if a thread is going to wait, and abort may arrive in the meanwhile; then thread should check for abort as the first task
- Use locks if we are determining abort with a flag
- Never mix the abort path with a regular path in application. It is not wise to scatter abort related functionality among other threads