# File lib/Borges/RequestHandler/Session.rb, line 184
  def in_thread(&block)
    val = nil

    if Thread.current[:in_handler_thread] then
      val = block.call

    else
      if (not defined? @thread) or @thread.nil? or (not @thread.alive?) then
        start_handler_thread 
      end

      @session_mutex.synchronize do
        response_lock = Mutex.new.lock # unlocked by #perform_request
        #@thread[:request] = req
        @thread[:block] = block
        @thread[:response_done] = response_lock
        @thread_mutex.unlock
        response_lock.lock
        val = @thread[:return]
      end

    end

    return val
  end