dugenkui03 commented on PR #4094: URL: https://github.com/apache/rocketmq/pull/4094#issuecomment-1108842641
@lwclover 非常感谢你的review. 首先`DefaultLitePullConsumerImpl`中的`serviceState`是可以通过`DefaultLitePullConsumer`被并发访问的,即使`DefaultLitePullConsumerImpl`是”非共享“的。 其次`#isCreateJust()`和`#getServiceState()`加锁最简单、重要的原因是:在`DefaultLitePullConsumerImpl`中对`serviceState`的访问、包括读写**之前都是加对象锁的,我推测可能是因为`#start()`和`#shutdown()`中包含 check-then-action 操作,最初的设计者想要避免程序读取到 action 之前的无效状态**。 综上,我认为`DefaultLitePullConsumerImpl`对`serviceState`在并发环境下的安全访问作出了承诺:开发者(包括源码维护者)可以安全的访问`serviceState`而无需自己做额外的同步策略去防止读取到无效状态。 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
