In this tutorial you'll learn to
- add headers and tredzone namespace in order to use Simplx
- define a simple actor
- instantiate the actor by inserting it in the StartSequence and then starting the engine
- block the main thread until user types the Enter key
- build using cmake, make or a g++ onle-liner
The API is defined in the topmost header "simplx.h"; including it should be all that is required.
To use shorter symbol names, it's convenient to use the tredzone namespace
#include "simplx.h"
using namespace tredzone;
using namespace std;
To define an actor, just inherit from the Actor class
class HelloActor: public Actor
...
First, a StartSequence must be instantiated.
Next, we add actor classes into the StartSequence, specifying the core on which it must be run (here the core number 1).
Finally, we instantiate actors that were added to the StartSequence by creating an Engine. Here we wait for suser input since we want the Engine not to destroy immediately after instantiation.
Engine::StartSequence startSequence;
startSequence.addActor<HelloActor>(1);
Engine engine(startSequence);
cout << "Press enter to exit...";
cin.get();
mkdir build && cd build
cmake ..
make
make
While using CMake to build largish projects is easier, here is the g++ command to build this small tutorial:
g++ -std=c++11 -pthread -I ../../include/ ../../src/engine/actor.cpp ../../src/engine/e2e_stub.cpp ../../src/engine/engine.cpp ../../src/engine/node.cpp ../../src/engine/RefMapper.cpp ../../src/engine/parallel/parallel_xplat.cpp ../../src/engine/linux/platform_linux.cpp ../../src/engine/linux/platform_gcc.cpp hello_actor.cpp -o hello_actor.bin