????????????????

????????????????ж??????????????????????????????????????????????????????? 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;
}