Waits for task's completion with timeout. Tries to retract the task and execute it in-place, if failed - blocks until the task is completed by another thread. If timeout is zero, tries to retract the task and returns immedially after that.