def if_state(*expected_states)
      mutex.lock
      raise ArgumentError, 'no block given' unless block_given?

      if expected_states.include? @state
        yield
      else
        false
      end
    ensure
      mutex.unlock
    end
def if_state(*expected_states)
      mutex.lock
      raise ArgumentError, 'no block given' unless block_given?

      if expected_states.include? @state
        yield
      else
        false
      end
    ensure
      mutex.unlock
    end
executes the block within mutex if current state is included in
 expected_states

 @return block value if executed, false otherwise

 @!visibility private