Skip to content

Commit 136d9cc

Browse files
committed
Make VariantManager a singleton to remove a race condition
Currently, it's possibly for multiple classes to receive multiple instances of variant managers - each of which might try to allocate a new variant to the user concurrently.
1 parent 1b78832 commit 136d9cc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

app/src/main/java/com/duckduckgo/app/di/VariantModule.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ import com.duckduckgo.app.statistics.WeightedRandomizer
2222
import com.duckduckgo.app.statistics.store.StatisticsDataStore
2323
import dagger.Module
2424
import dagger.Provides
25+
import javax.inject.Singleton
2526

2627

2728
@Module
2829
class VariantModule {
2930

3031
@Provides
31-
fun variantManager(statisticsDataStore: StatisticsDataStore, weightedRandomizer: WeightedRandomizer): VariantManager = ExperimentationVariantManager(statisticsDataStore, weightedRandomizer)
32+
@Singleton
33+
fun variantManager(statisticsDataStore: StatisticsDataStore, weightedRandomizer: WeightedRandomizer): VariantManager =
34+
ExperimentationVariantManager(statisticsDataStore, weightedRandomizer)
3235

3336
@Provides
3437
fun weightedRandomizer() = WeightedRandomizer()

0 commit comments

Comments
 (0)