is it `synchronized` / monitor expression?
# koin-contributors
a
is it
synchronized
/ monitor expression?
k
Yes
Koin inject implemented as
Copy code
inline fun <reified T : Any> ComponentCallbacks.inject(
        qualifier: Qualifier? = null,
        noinline parameters: ParametersDefinition? = null
) = lazy { get<T>(qualifier, parameters) }
That is the same
Copy code
lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
    get<T>(qualifier, parameters)
}
That implementation has impact on performance
We need options to use unsafe lazy (
lazy(LazyThreadSafetyMode.NONE)
) for injecting
a
on Android you mean?
k
On any platform
It’s not good always use synchronization
a
yes, I see
on one side, we don’t know if current environment is running multithread or not
but the other, we lock instance resolution in the tree ... then we should not be exposed to problem
and then we would allow LazyThreadSafetyMode.NONE
k
I think it will be good to have option for inject without thread safety
Resolution of an instance must be locked inside depencies tree, not via lazy resolution from client side (via lazy delegate)
a
sure
I’m reworking internal engine to clearly optimize just to lock in on tree resolution
k
👍
I can create issue for that on Github
Do you need it?
a
yes open a ticket
I can make some work around it directly 😉
k
I’m reworking internal engine to clearly optimize just to lock in on tree resolution
You need to lock only
scoped
and
single
dependncies, because factory need to be created every time and no need to lock thread for resolution
a
this is what this is in current engine version
check
SingleInstanceFactory
&
FactoryInstanceFactory
k
I’ll check it later today
Done
a
thanks