2013-10-10 20:01:51 -04:00
|
|
|
class Philo : public QActive { // derives from QActive
|
2012-08-14 18:00:48 -04:00
|
|
|
private:
|
2013-10-10 20:01:51 -04:00
|
|
|
uint8_t m_num; // number of this philosopher
|
|
|
|
QTimeEvt m_timeEvt; // to timeout thining or eating
|
2012-08-14 18:00:48 -04:00
|
|
|
|
|
|
|
public:
|
2019-03-28 11:59:31 -04:00
|
|
|
Philo::Philo() // constructor
|
|
|
|
: QActive(&initial), // superclass' constructor
|
2013-10-10 20:01:51 -04:00
|
|
|
m_timeEvt(TIMEOUT_SIG, this, 0U)
|
2012-08-14 18:00:48 -04:00
|
|
|
{}
|
|
|
|
|
|
|
|
protected:
|
2019-03-28 11:59:31 -04:00
|
|
|
Q_STATE_DECL(initial);
|
|
|
|
Q_STATE_DECL(thinking);
|
|
|
|
Q_STATE_DECL(hungry);
|
|
|
|
Q_STATE_DECL(eating);
|
2012-08-14 18:00:48 -04:00
|
|
|
};
|