Closed ethanhua closed 4 years ago
thanks for your great project, i found the problem that the "wait" api not work when i apply it to my app, I fixed it and you can check it and if it works you can merge it in
I think this logic is not a problem, because if it callCreateOnMainThread() == true
, that the component is initialized in the main thread, and the main thread is blocked by default, so there's no need to call mNeedAwaitCount.IncrementAndGet()
wait for additional jam.
However, the await()
method is somewhat problematic, and I guess the problem you are experiencing is caused by the following reasons.
The cause should be this code in StartupManagerDispatcher
:
override fun notifyChildren(dependencyParent: Startup<*>, result: Any?, sortStore: StartupSortStore) {
// immediately notify main thread,Unblock the main thread.
if (dependencyParent.waitOnMainThread()) {
needAwaitCount.incrementAndGet()
awaitCountDownLatch?.countDown()
}
...
}
It should be amended to:
override fun notifyChildren(dependencyParent: Startup<*>, result: Any?, sortStore: StartupSortStore) {
// immediately notify main thread,Unblock the main thread.
if (dependencyParent.waitOnMainThread() && !dependencyParent.callCreateOnMainThread()) {
needAwaitCount.decrementAndGet()
awaitCountDownLatch?.countDown()
}
...
}
Will this solve your problems?
I thought carefully that it would be all right for you to change it this way,in my way it's also can work
Thank you for your pr.
the countdown create logic not match that task complete and reduce count logic