def task_finished(task, &block)
      @mutex.synchronize {
        ret = block.call if block  # TODO is this ought to be synchronized?
        if task == @task
          @task = nil
        end
        ret
      }
    end
def task_finished(task, &block)
      @mutex.synchronize {
        ret = block.call if block  # TODO is this ought to be synchronized?
        if task == @task
          @task = nil
        end
        ret
      }
    end
callback