-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Note: I'm not asking that the library be upgraded to Swift 6, or that all the types be made Sendable
. I know why they aren't.
The specific issue here is that in FHIRDateComponents
, there is a static var calendar = Calendar(identifier: .gregorian)
, which seems to be used only by some of the static methods on the type.
we observe regular crashes in our codebase, when attempting to have multiple threads perform (independent!) operations that use the FHIRModels types (some of which in turn internally use the FHIRDateComponents
, which then cause a crash, presumably due to the concurrent accesses to the global mutable variable)
since creating Calendar
s isn't overly expensive, IMO, these static functions should simply obtain a temporary Calendar
object and use that, instead of having a global variable.
(unless there was a specific reason for not implementing it this way in the first place, though even then there probably exists a better solution than the current approach.)