Is coercible thread-safe at an instance level, or should we use a new coercible instance per thread?
Specifically when running JRuby which has real threads without an interpreter lock.
Using the example below:
coercer = Coercible::Coercer.new
# coerce a string to a date
coercer[String].to_date('2012/12/25')
# Fetch the string coercer once
string_coercer = coercer[String]
string_coercer.to_date('2012/12/25')
Can one store the 'coercer' instance above into a class or global variable and then use it concurrently from multiple threads?
Also, can multiple threads access the same 'string_coercer' instance across threads?
@reidmorrison From what I know: Coercible does not have mutable state at the instance level. All intermediaries (if any) are stored on the stack. So it should be thread-save / re-entrant.
Is coercible thread-safe at an instance level, or should we use a new coercible instance per thread?
Specifically when running JRuby which has real threads without an interpreter lock.
Using the example below:
Can one store the 'coercer' instance above into a class or global variable and then use it concurrently from multiple threads?
Also, can multiple threads access the same 'string_coercer' instance across threads?