Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

TimeZoneInfo Cleanup #2408

Merged
merged 1 commit into from
Dec 24, 2016
Merged

TimeZoneInfo Cleanup #2408

merged 1 commit into from
Dec 24, 2016

Conversation

justinvp
Copy link
Contributor

@justinvp justinvp commented Dec 24, 2016

Some cleanup in CoreRT's TimeZoneInfo implementation:

  • The CachedData locking is currently inconsistent. Some code is using a private Lock object with LockHolder.Hold, while other code is locking against the CachedData instance (via Monitor.Enter/Exit). This change removes the private Lock object and just locks against the CachedData instance throughout, which is consistent with the CoreCLR implementation.

  • TimeZoneInfoComparer is being used in two places in CoreRT to sort the list of system time zones, whereas it's only used in one place in CoreCLR. This change refactors the code to have a shared implementation of GetSystemTimeZones in CoreRT that handles the sorting in one place, allowing a single Comparison<T> lambda to be used, which matches the CoreCLR implementation. Now the single shared GetSystemTimeZones implementation calls a private static PopulateAllSystemTimeZones method, which has separate implementations for Win32/WinRT/Unix. This addresses porting Remove private TimeZoneInfoComparer coreclr#8512.

  • The WinRT implementation of FindSystemTimeZoneById was accessing the cached data without any locking. Added locking.

cc: @tarekgh, @jkotas

Fixes #2388

Some cleanup in CoreRT's TimeZoneInfo implementation:

- The CachedData locking is currently inconsistent. Some code is using a
private Lock object with LockHolder.Hold, while other code is locking
against the CachedData instance. This change removes the private Lock
object and just locks against the CachedData instance throughout, which
is consistent with the CoreCLR implementation.

- TimeZoneInfoComparer is being used in two places in CoreRT to sort the
list of system time zones, whereas it's only used in one place in
CoreCLR. This change refactors the code to have a shared implementation
of GetSystemTimeZones in CoreRT that handles the sorting in one place,
allowing a single Comparison<T> lambda to be used, which matches the
CoreCLR implementation. Now there is a single shared GetSystemTimeZones
implementation which calls a private static PopulateAllSystemTimeZones
method, which is implemented separately for Win32/WinRT/Unix.

- The WinRT implementation of FindSystemTimeZoneById was accessing the
cached data without any locking. Added locking.
@tarekgh
Copy link
Member

tarekgh commented Dec 24, 2016

LGTM.

@jkotas PTAL.

@jkotas
Copy link
Member

jkotas commented Dec 24, 2016

Looks great! @justinvp Thanks a lot for going an extra mile to clean it up.

@jkotas jkotas merged commit 345928d into dotnet:master Dec 24, 2016
@justinvp justinvp deleted the tzi_comparison branch December 24, 2016 04:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants