def add_observer(bsrver = nil, func = :update, &block)
      if observer && block
        raise ArgumentError, 'cannot provide both an observer and a block'
      end
      direct_notification = false

      if block
        observer = block
        func     = :call
      end

      mutex.synchronize do
        if event.set?
          direct_notification = true
        else
          observers.add_observer(observer, func)
        end
      end

      observer.send(func, Time.now, self.value, reason) if direct_notification
      observer
    end
def add_observer(bsrver = nil, func = :update, &block)
      if observer && block
        raise ArgumentError, 'cannot provide both an observer and a block'
      end
      direct_notification = false

      if block
        observer = block
        func     = :call
      end

      mutex.synchronize do
        if event.set?
          direct_notification = true
        else
          observers.add_observer(observer, func)
        end
      end

      observer.send(func, Time.now, self.value, reason) if direct_notification
      observer
    end
Create a new `IVar` in the `:pending` state with the (optional) initial
 value.

 @param [Object] value
   The initial value.

 @param [Hash] opts the options to create a message with.

 @option opts [String] :dup_on_deref (false)
   Call `#dup` before returning the data.

 @option opts [String] :freeze_on_deref (false)
   Call `#freeze` before returning the data.

 @option opts [String] :copy_on_deref (nil)
   Cll the given `Proc` passing the internal value and returning the value
   returned from the proc.

 Add an observer on this object that will receive notification on update.

 Upon completion the `IVar` will notify all observers in a thread-safe way.
 The `func` method of the observer will be called with three arguments: the
 `Time` at which the `Future` completed the asynchronous operation, the
 final `value` (or `nil` on rejection), and the final `reason` (or `nil` on
 fulfillment).

 @param [Object] observer
   The object that will be notified of changes.

 @param [Symbol] func
   Symbol naming the method to call when the `Observable` has changes`