关于ACE_Future的疑问
为什么ACE_Future赋值时,只有第一次set会成功,第二次set就不起作用了,也就是说ACE_Future只允许赋值一次?请问这个样做的原因什么?谢谢达人。 /*** Make the result available. Is used by the server thread to give
* the result to all waiting clients. Returns 0 for success, -1 on failure.
* This function only has an effect the first time it is called for
* the object (actually, the first time the underlying ACE_Future_Rep has a
* value assigned to it). Subsequent calls return 0 (success) but have no
* effect.
*/
看源代码的注释有强调这一点的。
个人认为,原因是这样的,
因为对于主动对象模式,client与work线程,会持两个ACE_Future,但是内部引用的是一个ACE_Future_Rep,
一般工作线程在执行返回之后会对ACE_Future赋值,客户端一般会通过观察者模式得到ACE_Future_Rep的改变。
这时通过重载观察着模式的udpate方法,我们会对得到的改变进行处理,
一般来说需要对ACE_Future赋值一次就足够满足应用需求了。
楼主可以说明一次,set两次的应用场景么?或者set之后问题出在哪里了么?
具体可以参考源代码ACE_Future.h/cpp
回复 #2 okibun0129 的帖子
非常感谢,没什么应用场景,只是学习的时候发现了这个问题
页:
[1]