java对象的定义,java主动对象模式_POCO的主动对象

 2023-09-23 阅读 18 评论 0

摘要:摘自: http://pocoproject.org/docs/00100-GuidedTour.htmlActive object is an object that has methods executing in their ownthread. This makes asynchronous member function calls possible — call ajava对象的定义、member function, while the function exe

摘自: 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;

}

分享到:

18e900b8666ce6f233d25ec02f95ee59.png

72dd548719f0ace4d5f9bca64e1d7715.png

2010-06-22 14:12

浏览 299

评论

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/5/90714.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息