class ActiveSupport::Notifications::Fanout::Handle

end
handle.finish
ensure
# work to be instrumented
handle.start
begin
handle = ActiveSupport::Notifications.instrumenter.build_handle(“my.event”, {})
Handle is a low-level API intended for cases where the block form can’t be used.
Where possible, it’s best to use the block form: ActiveSupport::Notifications.instrument.
Both #start and #finish must each be called exactly once.
A Handle is used to record the start and finish time of event.

def ensure_state!(expected)

def ensure_state!(expected)
  if @state != expected
    raise ArgumentError, "expected state to be #{expected.inspect} but was #{@state.inspect}"
  end
end

def finish

def finish
  finish_with_values(@name, @id, @payload)
end

def finish_with_values(name, id, payload) # :nodoc:

:nodoc:
def finish_with_values(name, id, payload) # :nodoc:
  ensure_state! :started
  @state = :finished
  iterate_guarding_exceptions(@groups) do |group|
    group.finish(name, id, payload)
  end
end

def initialize(notifier, name, id, payload) # :nodoc:

:nodoc:
def initialize(notifier, name, id, payload) # :nodoc:
  @name = name
  @id = id
  @payload = payload
  @groups = notifier.groups_for(name).map do |group_klass, grouped_listeners|
    group_klass.new(grouped_listeners, name, id, payload)
  end
  @state = :initialized
end

def start

def start
  ensure_state! :initialized
  @state = :started
  iterate_guarding_exceptions(@groups) do |group|
    group.start(@name, @id, @payload)
  end
end