qpcpp/doxygen/snippets/qf_qactive.cpp

18 lines
567 B
C++
Raw Normal View History

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:
2013-10-10 20:01:51 -04:00
Philo::Philo()
: QActive(Q_STATE_CAST(&Philo::initial)),
m_timeEvt(TIMEOUT_SIG, this, 0U)
2012-08-14 18:00:48 -04:00
{}
protected:
2013-10-10 20:01:51 -04:00
static QState initial (Philo * const me, QEvt const *e);
static QState thinking(Philo * const me, QEvt const *e);
static QState hungry (Philo * const me, QEvt const *e);
static QState eating (Philo * const me, QEvt const *e);
2012-08-14 18:00:48 -04:00
};