Commit 1bc73535 authored by neverlord's avatar neverlord

fsm_actor in cppa.hpp

parent f6042822
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include "cppa/scheduler.hpp" #include "cppa/scheduler.hpp"
#include "cppa/to_string.hpp" #include "cppa/to_string.hpp"
#include "cppa/any_tuple.hpp" #include "cppa/any_tuple.hpp"
#include "cppa/fsm_actor.hpp"
#include "cppa/local_actor.hpp" #include "cppa/local_actor.hpp"
#include "cppa/exit_reason.hpp" #include "cppa/exit_reason.hpp"
#include "cppa/invoke_rules.hpp" #include "cppa/invoke_rules.hpp"
......
...@@ -30,11 +30,10 @@ ...@@ -30,11 +30,10 @@
#include <vector> #include <vector>
#include <chrono> #include <chrono>
#include <iostream>
#include <sstream> #include <sstream>
#include <iostream>
#include "cppa/cppa.hpp" #include "cppa/cppa.hpp"
#include "cppa/fsm_actor.hpp"
using std::cout; using std::cout;
using std::endl; using std::endl;
...@@ -133,6 +132,8 @@ struct philosopher : fsm_actor<philosopher> ...@@ -133,6 +132,8 @@ struct philosopher : fsm_actor<philosopher>
( (
on(atom("taken"), what) >> [=]() on(atom("taken"), what) >> [=]()
{ {
// create message in memory to avoid interleaved
// messages on the terminal
std::ostringstream oss; std::ostringstream oss;
oss << name oss << name
<< " has picked up chopsticks with IDs " << " has picked up chopsticks with IDs "
...@@ -198,7 +199,7 @@ struct philosopher : fsm_actor<philosopher> ...@@ -198,7 +199,7 @@ struct philosopher : fsm_actor<philosopher>
become(&thinking); become(&thinking);
} }
); );
// philosopher obtained both chopsticsk and eats (for five seconds) // philosopher obtained both chopstick and eats (for five seconds)
eating = eating =
( (
on(atom("think")) >> [=]() on(atom("think")) >> [=]()
...@@ -225,7 +226,7 @@ struct philosopher : fsm_actor<philosopher> ...@@ -225,7 +226,7 @@ struct philosopher : fsm_actor<philosopher>
}; };
int main() int main(int, char**)
{ {
// create five chopsticks // create five chopsticks
cout << "chopstick ids:"; cout << "chopstick ids:";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment