make task management methods thread safe
Merge pull request #318 from whirm/task_manager

cancel_pending_task should always be called from the reactor