I am planning on using ActiveSupport::Notifications and have a question
about threading. For the purposes of this question I am assuming
config.threadsafe! is enabled.
Will a subscriber execute in the same thread as the code that caused it
be triggered or do they run in separate threads?
The reason I ask is that I would like to do something like
In Controller Code:
Module.events[Thread.current] = Event.new # Module.events returns a
rest of action code
do |name, start, finish, id, payload|
event = Module.events[Thread.current] # returns the Event that was
created in the controller.
Do processing on event
Obviously if the Subscriber runs in a different thread then this will
work since Thread.current will not match so I wanted to check. Note that
this case I do not want to pass the Event as part of the payload because
want to be able to use existing rails built-in notifications without
to modify them.