C++ ?????????????
???????????? ???????[ 2012/11/28 10:29:26 ] ????????
????????????????
????????????????ж??????????????????????????????????????????????????????? AMD ????? 2012-2013 ??????·??????????????????????????????? 2013 ??? 20 ?????????????? CPU ?????????????ò?????????????? C++ ??????????????????????????????????????????????????飬????????????????????????Щ?????????????????????????????????????Щ???????????????????????????? Erlang?????????????????????Theron ??????????
???????? Theron??
????Theron ???????????????? C++ ????? Theron ??????????????????и???????????磺??????楨????????Theron ??? Actor ??????????????????????
???????? Actor ????
????Erlang ?????????????????????????????????????????????????????? Actor ?????? Actor ????????????????????????????????????? Object ????Object ???????????н?? Object?????????? Actor ??????????н?? Actor??Actor ????У?Actor ?????????????????????? Object ???????????????????????? Actor ???????????????????????? Object ????е??????????á?????????????????????????????????????????????????????????????????????÷???????????????????????????????
????A::a() ?????? objB.b()????? A::a() ?????? B::b() ?????????????С??? Actor ????У???????????? Actor A ?? Actor B ??????????????????????? Actor A ???????????????????? Actor B ??????????????? Actor A ????????????
????Theron ?е???? Actor ????????????????? Actor ??????????????????????? Actor ?????????????С????????????????????????? Actor ????????????? Actor ????“???”??????????????????? Actor ?????????????С??????? Theron ???????????????????? Actor ??????????????“???”????У?????? Actor ??????С?
????Hello Theron
????????????????????????????????? Theron ????????????????????????????????http://www.theron-library.com/????????? Theron ???°棬Theron ???? makefile ???? gcc ????????????? Windows ??????? Visual Studio solution ??? Theron.sln ??????? Theron?????? Theron ?????????????????????????????????? Theron ????????????????Theron ???????????std::thread??C++11 ?????????Boost.Thread ?? Windows threads????? makefile ?????????? threads ?????????????????? Visual Studio ?????????????????? Solution configuration ?????????????????????????????????????
#include <stdio.h>
#include <Theron/Framework.h>
#include <Theron/Actor.h>
// ??????????????
// ?? Theron ?У??κ???????????????????????
// ????????????????????????????????
// ???????????????????????????
struct StringMessage
{
char m_string[64];
};
// ???????? Actor ?????????? Theron::Actor
// ??? Actor ????ó???????????????????????????
class Actor : public Theron::Actor
{
public:
inline Actor()
{
// ??????????????
RegisterHandler(this?? &Actor::Handler);
}
private:
// ??????????????????????????????????????
inline void Handler(const StringMessage& message?? const Theron::Address from)
{
printf("%s
"?? message.m_string);
if (!Send(message?? from))
printf("Failed to send message to address %d
"?? from.AsInteger());
}
};
int main()
{
// Framework ??????????? Actors
Theron::Framework framework;
// ??? Framework ??????? Actor ???????????????
// Actor ???????????? Java??C# ???????е?????????
// Theron::ActorRef ???????ü????????????????? boost::shared_ptr
Theron::ActorRef simpleActor(framework.CreateActor<Actor>());
// ??????? Receiver ??????? Actor ????????
// ??????? Actor ?????У????? main ?????У??? Actor ???
Theron::Receiver receiver;
// ???????
StringMessage message;
strcpy(message.m_string?? "Hello Theron!");
// ??? Actor ??????????????? Actor ?????????
if (!framework.Send(message?? receiver.GetAddress()?? simpleActor.GetAddress()))
printf("Failed to send message!
");
// ??? Actor ?????????????????????
receiver.Wait();
return 0;
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11