Skip to content

Conversation

didiergarcia
Copy link
Contributor

Remove synchronize {} from all Mediator functions. Replaced the MutableList with a CopyOnWriteArrayList, that will allow multiple readers of list at once and caller that modifies the list (add,remove, etc) will get a new copy of the list that will automatically synchronized by the JVM in a safe way.

See: https://developer.android.com/reference/kotlin/java/util/concurrent/CopyOnWriteArrayList

Note: It looks to me that this has greatly sped up sending events through the timeline.

@didiergarcia didiergarcia requested a review from wenxi-zeng March 7, 2023 05:18
@codecov-commenter
Copy link

codecov-commenter commented Mar 7, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.03 ⚠️

Comparison is base (108a98f) 78.34% compared to head (de63541) 78.32%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #141      +/-   ##
============================================
- Coverage     78.34%   78.32%   -0.03%     
- Complexity      492      493       +1     
============================================
  Files            73       73              
  Lines          6036     6030       -6     
  Branches        757      757              
============================================
- Hits           4729     4723       -6     
+ Misses          711      710       -1     
- Partials        596      597       +1     
Impacted Files Coverage Δ
...segment/analytics/kotlin/core/platform/Mediator.kt 86.20% <100.00%> (-5.23%) ⬇️
...segment/analytics/kotlin/core/platform/Timeline.kt 90.90% <100.00%> (ø)
...core/platform/plugins/DestinationMetadataPlugin.kt 78.78% <0.00%> (-3.04%) ⬇️
...alytics/kotlin/core/utilities/EventsFileManager.kt 95.94% <0.00%> (+2.70%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@didiergarcia didiergarcia changed the title Use a CopyOnWriteArrayList in Mediator instead of synchronize {}. Use a CopyOnWriteArrayList in Mediator instead of synchronized {}. Mar 7, 2023
@didiergarcia didiergarcia merged commit ac026ec into main Mar 7, 2023
@didiergarcia didiergarcia deleted the feature/remove-mediator-synchronize branch March 7, 2023 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants