baidu / sofa-pbrpc

A light-weight RPC implement of google protobuf RPC framework.
Other
2.13k stars 655 forks source link

关于volatile变量相关的问题 #242

Open pengwang7 opened 2 years ago

pengwang7 commented 2 years ago

看了代码中有很多volatile修饰的变量,目的是什么,为了statistics更加准确以及为了使用sofa-pbrpc中提供的原子操作吗? 代码中有这样的注释: // And here we need not lock "_pending_lock" because the "_pending_message_count" is // an volatile value. 请教一下volatile与锁有关系吗?