Skip to content

Commit 6b3b0fd

Browse files
committed
Remove explicit synchronization from lazy initialization
This is because the default behavior of `lazy` in Kotlin is already synchronized, ensuring thread safety without the need for explicit specification.
1 parent 621fe4a commit 6b3b0fd

File tree

7 files changed

+8
-17
lines changed

7 files changed

+8
-17
lines changed

gradle/libs.versions.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@ metalava = "0.3.5"
1111
compose-multiplatform = "1.7.0"
1212
cacheFixPlugin = "3.0.1"
1313
dokka = "1.9.20"
14-
coroutines = "1.9.0"
14+
coroutines = "1.10.1"
1515
androidx-core-ktx = "1.15.0"
16-
androidx-activity-compose = "1.9.3"
16+
androidx-activity-compose = "1.10.0"
1717
material = "1.12.0"
1818
appcompat = "1.7.0"
1919
accompanist-permissions = "0.34.0"
2020
navigation-compose = "2.8.0-alpha09" # Make use of type-safe compose navigation
2121
kotlinx-serializer = "1.7.3"
2222
lifecycle-viewmodel-compose = "2.8.0"
2323
kermit = "2.0.5"
24-
moko-permissions = "0.18.0"
2524
kotlinx-collections-immutable = "0.3.8"
2625
kotlinx-datetime = "0.6.1"
2726
sqldelight = "2.0.2"

kanalytics-viewer/src/androidMain/kotlin/com/addhen/kanalytics/viewer/app/NotificationManager.android.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ internal class NotificationManagerImpl : NotificationManager {
9898
}
9999

100100
internal companion object {
101-
val Instance: NotificationManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
102-
NotificationManagerImpl()
103-
}
101+
val Instance: NotificationManager by lazy { NotificationManagerImpl() }
104102
}
105103
}

kanalytics-viewer/src/commonMain/kotlin/com/addhen/kanalytics/KAnalyticsCollector.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ internal class KAnalyticsCollector(
5050
}
5151

5252
companion object {
53-
val instance: KAnalyticsCollector by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
53+
val instance: KAnalyticsCollector by lazy {
5454
KAnalyticsCollector(
5555
repository = EventDataRepository.Instance,
5656
)

kanalytics-viewer/src/commonMain/kotlin/com/addhen/kanalytics/viewer/app/shared/AppCoroutineDispatchers.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ public data class AppCoroutineDispatchers(
1919
) {
2020

2121
internal companion object {
22-
val Instance by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
23-
AppCoroutineDispatchers()
24-
}
22+
val Instance by lazy { AppCoroutineDispatchers() }
2523
}
2624
}
2725

kanalytics-viewer/src/commonMain/kotlin/com/addhen/kanalytics/viewer/app/shared/data/database/EventDataDao.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ internal class EventDataDao(
7878
}
7979

8080
internal companion object {
81-
val Instance: EventDataDao by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
81+
val Instance: EventDataDao by lazy {
8282
EventDataDao(
8383
database = createDatabase(),
8484
appCoroutineDispatchers = AppCoroutineDispatchers(),

kanalytics-viewer/src/commonMain/kotlin/com/addhen/kanalytics/viewer/app/shared/data/repository/EventDataRepository.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ internal class EventDataRepository(
7777
}
7878

7979
internal companion object {
80-
val Instance by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
81-
EventDataRepository(
82-
eventDataDao = EventDataDao.Instance,
83-
)
84-
}
80+
val Instance by lazy { EventDataRepository(eventDataDao = EventDataDao.Instance) }
8581
}
8682
}

kanalytics-viewer/src/commonMain/kotlin/com/addhen/kanalytics/viewer/app/shared/ui/settings/DefaultViewerAppPreferences.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ internal class DefaultViewerAppPreference(
124124
internal companion object {
125125
val SUBSCRIBED_TIMEOUT = 20.seconds
126126

127-
val Instance: ViewerAppPreferences by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
127+
val Instance: ViewerAppPreferences by lazy {
128128
DefaultViewerAppPreference(
129129
provideObservableSettings(),
130130
applicationCoroutineScope,

0 commit comments

Comments
 (0)