mirror of
https://github.com/QuantumLeaps/qpcpp.git
synced 2025-01-14 05:42:57 +08:00
18 lines
567 B
C++
18 lines
567 B
C++
class Philo : public QActive { // derives from QActive
|
|
private:
|
|
uint8_t m_num; // number of this philosopher
|
|
QTimeEvt m_timeEvt; // to timeout thining or eating
|
|
|
|
public:
|
|
Philo::Philo()
|
|
: QActive(Q_STATE_CAST(&Philo::initial)),
|
|
m_timeEvt(TIMEOUT_SIG, this, 0U)
|
|
{}
|
|
|
|
protected:
|
|
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);
|
|
};
|