Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ProducerReady #2633

Closed
wants to merge 2 commits into from
Closed

fix: ProducerReady #2633

wants to merge 2 commits into from

Conversation

cssxsh
Copy link
Contributor

@cssxsh cssxsh commented Apr 17, 2023

按照状态图的设计,Producer 线程的启动时间点应为 ProducerReady -> Producing
故将原本 init 的行为改为主动调用

close #2623

} catch (e: Exception) {
finishExceptionally(e)
}
val ready = coroutineScope.launch(start = CoroutineStart.LAZY) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
val ready = coroutineScope.launch(start = CoroutineStart.LAZY) {
private val ready = coroutineScope.launch(start = CoroutineStart.LAZY) {

@@ -104,6 +95,8 @@ internal class CoroutineOnDemandValueScope<T, V>(
val deferred = CompletableDeferred<V>(coroutineScope.coroutineContext.job)
if (!compareAndSetState(state, ProducerState.Producing(state.producer, deferred))) {
deferred.cancel() // avoid leak
} else {
(state.producer as Producer).ready.start()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这句话是线程不安全的, 之后我想想改怎么改

@lanybass
Copy link

想好没。。。

@Him188
Copy link
Member

Him188 commented Apr 21, 2023

最近太忙

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.

更新到mirai 2.15.0-M1后无法进入登录验证
3 participants