摘自: http://pocoproject.org/docs/00100-GuidedTour.html
Active object is an object that has methods executing in their own
thread. This makes asynchronous member function calls possible — call a
java对象的定义、member function, while the function executes, do a bunch of other
things, and, eventually, obtain the function's return value. The
following example shows how this is done in POCO. The ActiveAdder
class in defines an active method add()
java调用另一个类的成员变量。, implemented by the addImpl()
member function. Invoking the active method in main()
yields
an Poco::ActiveResult
java对象是什么,(also known as a
future), that eventually receives the function's return value.
#include "Poco/ActiveMethod.h"
#include "Poco/ActiveResult.h"
java中类和对象的关系、#include
using Poco::ActiveMethod;
using Poco::ActiveResult;
class ActiveAdder
java策略模式?{
public:
ActiveObject(): activeAdd(this, &ActiveAdder::add)
{
java创建对象,}
ActiveMethod, ActiveAdder> add;
private:
int addImpl(const std::pair& args)
java序列化、{
return args.first + args.second;
}
};
int main(int argc, char** argv)
{
ActiveAdder adder;
ActiveResult sum = adder.add(std::make_pair(1, 2));
// do other things
sum.wait();
std::cout << sum.data() << std::endl;
return 0;
}
分享到:
2010-06-22 14:12
浏览 299
评论
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态